<?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 `support_requests` (
`id` int UNSIGNED NOT NULL,
  `user_id` int NOT NULL,
  `subject` varchar(255) NOT NULL,
  `message` text NOT NULL,
  `status` varchar(25) NOT NULL DEFAULT 'open',
  `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 `teacher_attendance_data`
--


CREATE TABLE `teacher_attendance_data` (

`id` int UNSIGNED NOT NULL,

  `class_section_id` int UNSIGNED NOT NULL,

  `teacher_id` int UNSIGNED NOT NULL,

  `position` enum('main','ta') NOT NULL,

  `date` date NOT NULL,

  `semester` varchar(25) NOT NULL,

  `school_year` varchar(25) NOT NULL,

  `status` enum('present','absent','late') NOT NULL,

  `reason` varchar(255) DEFAULT NULL,

  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,

  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP

) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

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

--
-- Table structure for table `teacher_class`
--


CREATE TABLE `teacher_class` (

`id` int UNSIGNED NOT NULL,

  `class_section_id` int DEFAULT NULL,

  `teacher_id` int DEFAULT NULL,

  `position` enum('main','ta') COLLATE utf8mb4_general_ci DEFAULT NULL,

  `semester` varchar(25) COLLATE utf8mb4_general_ci NOT NULL,

  `school_year` varchar(25) COLLATE utf8mb4_general_ci DEFAULT NULL,

  `description` text COLLATE utf8mb4_general_ci,

  `created_at` datetime DEFAULT NULL,

  `updated_at` datetime DEFAULT NULL,

  `updated_by` int DEFAULT NULL

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

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

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

    }

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