<?php
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('certificates', function (Blueprint $table) {
            $table->id();
            $table->foreignId('enrollment_id')->constrained('enrollments')->cascadeOnDelete();
            $table->string('certificate_no')->unique();
            $table->date('issued_date')->nullable();
            $table->string('status')->default('Đã cấp');
            $table->text('note')->nullable();
            $table->timestamps();
            $table->unique('enrollment_id');
        });
    }
    public function down(): void { Schema::dropIfExists('certificates'); }
};
