<?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 `classes` (
`id` int UNSIGNED NOT NULL,
  `class_name` varchar(100) NOT NULL,
  `schedule` varchar(100) NOT NULL,
  `capacity` int NOT NULL,
  `semester` varchar(255) NOT NULL,
  `school_year` varchar(9) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `classSection`
--


CREATE TABLE `classSection` (

`id` int UNSIGNED NOT NULL,

  `class_id` int UNSIGNED NOT NULL,

  `class_section_id` int UNSIGNED NOT NULL,

  `class_section_name` varchar(100) NOT NULL,

  `created_at` datetime DEFAULT NULL,

  `updated_at` datetime DEFAULT NULL,

  `semester` varchar(255) NOT NULL,

  `school_year` varchar(9) DEFAULT NULL

) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `class_preparation_log`
--


CREATE TABLE `class_preparation_log` (

`id` int UNSIGNED NOT NULL,

  `class_section_id` int UNSIGNED NOT NULL,

  `class_section` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL,

  `school_year` varchar(9) COLLATE utf8mb4_general_ci NOT NULL,

  `prep_data` text COLLATE utf8mb4_general_ci NOT NULL,

  `created_at` datetime DEFAULT CURRENT_TIMESTAMP

) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
SQL
        );

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

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

    }

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