<?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('kc_cadpa_certs', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('tenant_id')->index();
            $table->unsignedBigInteger('game_id')->unique();
            $table->unsignedTinyInteger('age_rating')->comment('8/12/16');
            $table->string('publish_no', 64);
            $table->date('publish_date')->nullable();
            $table->string('publisher', 128)->nullable();
            $table->string('operator', 128)->nullable();
            $table->json('checklist')->comment('版号合规清单自检结果');
            $table->enum('status', ['draft', 'submitted', 'passed', 'expired'])->default('draft');
            $table->date('expires_at')->nullable();
            $table->timestamps();

            $table->index('publish_no');
        });
    }

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