<?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
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('qz_certificates', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->text('public_certificate')->nullable();
            $table->string('private_key_path')->nullable();
            $table->string('fingerprint')->nullable();
            $table->string('algorithm')->nullable();
            $table->string('status')->default('not_generated'); // active, expired, invalid, not_generated
            $table->timestamp('expires_at')->nullable();
            $table->timestamp('last_used_at')->nullable();
            $table->foreignId('created_by')->nullable()->constrained('users')->onDelete('set null');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('qz_certificates');
    }
};
