<?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 `invoice_students_list` (
`id` int UNSIGNED NOT NULL,
  `invoice_id` int UNSIGNED NOT NULL,
  `student_id` int UNSIGNED NOT NULL,
  `student_firstname` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `student_lastname` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `school_id` int UNSIGNED NOT NULL,
  `enrolled` tinyint(1) DEFAULT '1',
  `school_year` varchar(9) COLLATE utf8mb4_general_ci NOT NULL,
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `semester` varchar(10) COLLATE utf8mb4_general_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
SQL
        );

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

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

    }

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