<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        App\Support\SqliteCompat::statement(<<<'SQL'
CREATE TABLE `reimbursement_batch_admin_files` (
`id` int UNSIGNED NOT NULL,
  `batch_id` int UNSIGNED NOT NULL,
  `admin_id` int UNSIGNED NOT NULL DEFAULT '0',
  `filename` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `original_filename` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `uploaded_at` datetime NOT NULL,
  `uploaded_by` int UNSIGNED DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
SQL
        );

        App\Support\SqliteCompat::statement(<<<'SQL'
ALTER TABLE `reimbursement_batch_admin_files`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `batch_admin_unique` (`batch_id`,`admin_id`),
  ADD KEY `batch_id` (`batch_id`),
  ADD KEY `admin_id` (`admin_id`);
SQL
        );

        App\Support\SqliteCompat::statement(<<<'SQL'
ALTER TABLE `reimbursement_batch_admin_files`
  MODIFY `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;
SQL
        );

    }

    public function down(): void
    {
        Schema::dropIfExists('reimbursement_batch_admin_files');
    }
};