<?php

declare(strict_types=1);

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('revisions', function (Blueprint $table): void {
            $table->id();
            $table->string('revisable_type');
            $table->unsignedBigInteger('revisable_id');
            $table->unsignedBigInteger('user_id')->nullable();
            $table->json('revision_data');
            $table->timestamps();

            $table->index(
                ['revisable_type', 'revisable_id', 'created_at'],
                'revisions_revisable_created_idx'
            );
        });
    }
};
