<?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 `qcmquestions` (
`id` int NOT NULL,
  `qcm_question_id` int NOT NULL,
  `question_id` int NOT NULL,
  `answer_a` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `answer_b` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `answer_c` text COLLATE utf8mb4_unicode_ci,
  `answer_d` text COLLATE utf8mb4_unicode_ci,
  `answer_e` text COLLATE utf8mb4_unicode_ci,
  `correct_answer` char(1) COLLATE utf8mb4_unicode_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
SQL
        );

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

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

    }

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