<?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('marketplace_versions', function (Blueprint $table) {
            $table->uuid('id')->primary();
            $table->foreignUuid('item_id')->constrained('marketplace_items')->cascadeOnDelete();
            $table->string('version', 50);
            $table->text('changelog')->nullable();
            $table->string('file_path', 500)->nullable();
            $table->unsignedBigInteger('file_size')->default(0);
            $table->string('sha256', 64)->nullable();
            $table->timestamp('published_at')->nullable();
            $table->timestamps();

            $table->unique(['item_id', 'version']);
        });
    }

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