<?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::create('song_arrangement_groups', function (Blueprint $table) {
            $table->id();
            $table->foreignId('song_arrangement_id')->constrained()->cascadeOnDelete();
            $table->foreignId('song_group_id')->constrained()->cascadeOnDelete();
            $table->unsignedInteger('order');
            $table->timestamps();

            $table->index('song_arrangement_id');
            $table->index('song_group_id');
            $table->unique(['song_arrangement_id', 'order']);
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('song_arrangement_groups');
    }
};
