<?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 `competition_class_winners` (
`id` int UNSIGNED NOT NULL,
  `competition_id` int UNSIGNED NOT NULL,
  `class_section_id` int NOT NULL,
  `winners_override` int DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL,
  `question_count` int DEFAULT NULL,
  `prize_1` decimal(10,2) DEFAULT NULL,
  `prize_2` decimal(10,2) DEFAULT NULL,
  `prize_3` decimal(10,2) DEFAULT NULL,
  `prize_4` decimal(10,2) DEFAULT NULL,
  `prize_5` decimal(10,2) DEFAULT NULL,
  `prize_6` decimal(10,2) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
SQL
        );

        App\Support\SqliteCompat::statement(<<<'SQL'
ALTER TABLE `competition_class_winners`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `competition_id_class_section_id` (`competition_id`,`class_section_id`);
SQL
        );

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

    }

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