<?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('serenatas', function (Blueprint $table) {
            $table->string('external_reference', 120)->nullable()->after('code');
            $table->unique(['organization_id', 'external_reference']);
        });
    }

    public function down(): void
    {
        Schema::table('serenatas', function (Blueprint $table) {
            $table->dropUnique(['organization_id', 'external_reference']);
            $table->dropColumn('external_reference');
        });
    }
};
