<?php
namespace FleekDash\Database\Migrations;

use FleekDash\Database\Core\BaseMigration;
use FleekDash\Database\Core\TableBuilder;

/**
 * Create Text Overrides Table
 *
 * Stores custom text overrides for en_US locale
 * Converted to new format
 */
return new class extends BaseMigration {

    public function up(): void
    {
        $this->createTable('fleekdash_text_overrides', function (TableBuilder $table) {
            $table->id();
            $table->string('locale', 10)->default('en_US');
            $table->string('original_text', 500);
            $table->string('custom_text', 500);
            $table->string('context', 200)->nullable();
            $table->timestamps();

            $table->unique(['locale', 'original_text'], 'unique_locale_text');
            $table->index('locale');
        });

        update_option('fleekdash_text_overrides_version', '1.0.0');
    }

    public function down(): void
    {
        $this->dropTable('fleekdash_text_overrides');
        delete_option('fleekdash_text_overrides_version');
    }
};

