<?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 `user_preferences` (
`id` int UNSIGNED NOT NULL,
  `user_id` int NOT NULL,
  `notification_email` tinyint(1) DEFAULT '1',
  `notification_sms` tinyint(1) DEFAULT '1',
  `theme` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT 'light',
  `language` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT 'en',
  `style_color` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `menu_color` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `menu_custom_bg` varchar(16) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `menu_custom_text` varchar(16) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `menu_custom_mode` varchar(8) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
SQL
        );

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

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

    }

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