<?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('builder_roles', function (Blueprint $table): void {
            $table->id();
            $table->string('name')->unique();
            $table->string('display_name')->nullable();
            $table->text('description')->nullable();
            $table->timestamps();
        });

        Schema::create('builder_role_user', function (Blueprint $table): void {
            $table->foreignId('user_id')->constrained()->cascadeOnDelete();
            $table->foreignId('builder_role_id')->constrained()->cascadeOnDelete();
            $table->primary(['user_id', 'builder_role_id']);
        });
    }

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