<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::table('data_exports', function (Blueprint $table) {
            $table->string('scope', 20)->default('user')->after('tenant_id');
            $table->foreignId('event_id')->nullable()->after('scope')->constrained()->nullOnDelete();
            $table->boolean('include_media')->default(false)->after('event_id');

            $table->index(['scope']);
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('data_exports', function (Blueprint $table) {
            $table->dropIndex(['scope']);
            $table->dropColumn('include_media');
            $table->dropConstrainedForeignId('event_id');
            $table->dropColumn('scope');
        });
    }
};
