<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * 创建房间表（含 visit_num 人气字段 + announcement 公告字段，合并历次变更）
     */
    public function up(): void
    {
        Schema::create('rooms', function (Blueprint $table) {
            $table->id();
            $table->string('room_name', 10)->unique()->comment('房间标识/名称');
            $table->string('room_auto', 10)->nullable()->comment('房间别名/自动属性');
            $table->string('room_owner', 10)->nullable()->comment('房主');
            $table->string('room_des', 250)->nullable()->comment('房间描述');
            $table->string('announcement', 500)->nullable()->comment('房间公告/祝福语（滚动显示）');
            $table->string('room_top', 100)->nullable()->comment('置顶信息');
            $table->string('room_title', 250)->nullable()->comment('房间标题');
            $table->tinyInteger('room_keep')->default(0)->comment('是否保留');
            $table->dateTime('room_time')->nullable()->comment('建立/最后时间');
            $table->tinyInteger('room_tt')->default(0)->comment('相关开关');
            $table->tinyInteger('room_html')->default(0)->comment('是否允许HTML');
            $table->integer('room_exp')->default(0)->comment('所需经验');
            $table->dateTime('build_time')->nullable()->comment('建立时间');
            $table->tinyInteger('permit_level')->default(1)->comment('允许进入的最低等级');
            $table->tinyInteger('door_open')->default(1)->comment('大门是否开启 (1开 0关)');
            $table->integer('ooooo')->nullable()->comment('未知/扩展属性');
            $table->unsignedBigInteger('visit_num')->default(0)->comment('房间人气（总访问人次）');
            $table->timestamps();
        });
    }

    /**
     * 回滚：删除 rooms 表
     */
    public function down(): void
    {
        Schema::dropIfExists('rooms');
    }
};
