<?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('kylin_guardians', function (Blueprint $table) {
            $table->id();
            $table->foreignId('user_id')->constrained()->cascadeOnDelete();
            $table->string('name', 50)->comment('监护人姓名');
            $table->string('phone', 20)->comment('手机号');
            $table->text('id_card')->nullable()->comment('身份证号(加密存储)');
            $table->string('relationship', 30)->comment('与未成年人关系');
            $table->boolean('verified')->default(false)->comment('是否已实名验证');
            $table->timestamp('verified_at')->nullable()->comment('验证时间');
            $table->timestamps();
            $table->softDeletes();

            $table->index('user_id');
            $table->index('phone');
        });
    }

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