<?php

declare(strict_types=1);

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use TechnoArtisan\FilamentCms\Database\BaseMigration;
use TechnoArtisan\FilamentCms\Enums\PhpType;

return new class extends BaseMigration {
    protected const string TABLE = 'fcms_website_settings';

    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create(self::TABLE, function (Blueprint $table): void {
            $this->basicTableSetup($table); // engine, charset, collation

            $table->bigIncrements('id'); // BIGINT (20) unsigned

            $table->tinyInteger('website_setting_group_id')->unsigned();

            $table->string('identifier', 64);
            $table->enum('value_type', PhpType::toArray());

            $table->timestamps();

            // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            // foreign key(s)
            $table->foreign('website_setting_group_id', 'FK01_website_setting_group_id__website_setting_group')
                ->references('id')
                ->on('fcms_website_setting_groups')
                ->onDelete('cascade')
                ->onUpdate('cascade');
        });
    }
};
