<?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_sensitive_words', function (Blueprint $table) {
            $table->id();
            $table->string('word')->comment('敏感词');
            $table->foreignId('category_id')->constrained('kylin_word_categories')->cascadeOnDelete();
            $table->string('severity', 10)->default('moderate')->comment('严重程度: low/moderate/high/severe');
            $table->boolean('is_variant')->default(false)->comment('是否为变体词');
            $table->foreignId('parent_id')->nullable()->constrained('kylin_sensitive_words')->nullOnDelete()->comment('原始词ID');
            $table->string('status', 10)->default('active')->comment('状态: active/disabled');
            $table->timestamps();
            $table->softDeletes();

            $table->index(['category_id', 'status']);
            $table->index('word');
            $table->index('parent_id');
        });
    }

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