<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

/**
 * Creates modpack_installations if it doesn't already exist.
 * This table is normally created by Pterodactyl's modpack installer,
 * but may be missing on panels without that feature.
 * Safe to run on panels that already have it.
 */
return new class extends Migration
{
    public function up(): void
    {
        if (!Schema::hasTable('modpack_installations')) {
            Schema::create('modpack_installations', function (Blueprint $table) {
                $table->unsignedBigInteger('server_id')->primary();
                $table->string('provider', 191);
                $table->string('modpack_id', 191);
                $table->tinyInteger('finalized')->default(0);
            });
        }
    }

    public function down(): void
    {
        // Don't drop — this may be a Pterodactyl-owned table
    }
};
