<?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 `class_prep_adjustments` (
`id` int UNSIGNED NOT NULL,
  `class_section_id` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL,
  `item_name` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL,
  `adjustment` int NOT NULL DEFAULT '0',
  `adjustable` tinyint(1) NOT NULL DEFAULT '1',
  `school_year` varchar(16) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
SQL
        );

        App\Support\SqliteCompat::statement(<<<'SQL'
ALTER TABLE `class_prep_adjustments`
  ADD PRIMARY KEY (`id`);
SQL
        );

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

    }

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