<?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('macro_assignments', function (Blueprint $table) {
            $table->id();
            $table->enum('part_type', ['information', 'moderation', 'sermon', 'song', 'agenda_item']);
            $table->foreignId('macro_id')->constrained('macros')->restrictOnDelete();
            $table->enum('position', ['all_slides', 'first_slide', 'last_slide', 'by_label']);
            $table->foreignId('label_id')->nullable()->constrained('labels')->restrictOnDelete();
            $table->unsignedInteger('order')->default(0);
            $table->timestamps();
            $table->index(['part_type', 'order']);
        });
    }

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