<?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 `badge_print_logs` (
`id` int UNSIGNED NOT NULL,
  `user_id` int NOT NULL,
  `printed_by` int DEFAULT NULL,
  `school_year` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `printed_at` datetime NOT NULL,
  `role` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `class_section_name` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `copies` int NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
SQL
        );

        App\Support\SqliteCompat::statement(<<<'SQL'
ALTER TABLE `badge_print_logs`
  ADD PRIMARY KEY (`id`),
  ADD KEY `user_id` (`user_id`),
  ADD KEY `school_year` (`school_year`);
SQL
        );

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

    }

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