<?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::table('messages', function (Blueprint $table) {
            $table->string('retention_type', 30)
                ->default('user_chat')
                ->index()
                ->comment('消息保留类型：user_chat/system_notice/game_notice/ephemeral_notice');
        });
    }

    /**
     * 回滚迁移：移除聊天消息保留类型字段。
     */
    public function down(): void
    {
        Schema::table('messages', function (Blueprint $table) {
            $table->dropColumn('retention_type');
        });
    }
};
