<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('import_mappings', function (Blueprint $table) {
            $table->string('apply_mode', 10)->default('both')->after('transform');
            $table->index(['import_id', 'apply_mode']);
        });
    }

    public function down(): void
    {
        Schema::table('import_mappings', function (Blueprint $table) {
            if (Schema::hasColumn('import_mappings', 'apply_mode')) {
                $table->dropIndex(['import_id', 'apply_mode']);
                $table->dropColumn('apply_mode');
            }
        });
    }
};
