<?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('kylin_risk_black_white_list', function (Blueprint $table) {
            $table->id();
            $table->string('list_type', 20)->comment('名单类型：blacklist / whitelist');
            $table->string('target_type', 30)->comment('目标类型：user / ip / device / phone / fingerprint');
            $table->string('target_value', 255)->comment('目标值');
            $table->string('reason', 500)->comment('加入原因');
            $table->timestamp('expire_at')->nullable()->comment('过期时间，null 表示永久');
            $table->timestamps();

            $table->index(['list_type', 'target_type', 'target_value'], 'idx_list_type_target');
        });
    }

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