<?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('block_manager_blocks', function (Blueprint $table) {
            $table->increments('id');
            $table->char('uuid', 36)->unique();
            $table->string('slug', 255)->unique();
            $table->string('name', 255);
            $table->text('description')->nullable();
            $table->unsignedInteger('category_id')->nullable();
            $table->string('icon', 100)->nullable();
            $table->longText('structure_json')->nullable();
            $table->timestamp('last_shipped_at')->nullable();
            $table->unsignedInteger('shipped_block_registry_id')->nullable();
            $table->timestamps();

            $table->index('slug');
            $table->index('category_id');
            $table->index('shipped_block_registry_id');
        });
    }

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