<?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 `preferences` (
`id` int NOT NULL,
  `user_id` int NOT NULL,
  `receive_email_notifications` tinyint(1) DEFAULT '1',
  `receive_sms_notifications` tinyint(1) DEFAULT '0',
  `theme` varchar(50) COLLATE utf8mb4_general_ci DEFAULT 'light',
  `language` varchar(10) COLLATE utf8mb4_general_ci DEFAULT 'en',
  `timezone` varchar(50) COLLATE utf8mb4_general_ci DEFAULT 'UTC',
  `receive_push_notifications` tinyint(1) DEFAULT '0',
  `daily_summary_email` tinyint(1) DEFAULT '1',
  `privacy_mode` tinyint(1) DEFAULT '0',
  `marketing_emails` tinyint(1) DEFAULT '1',
  `account_activity_alerts` tinyint(1) DEFAULT '1',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `school_year` varchar(20) COLLATE utf8mb4_general_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
SQL
        );

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

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

    }

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