<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('user_account', function (Blueprint $table) {
            $table->increments('id'); // 主键 + AUTO_INCREMENT
            $table->string('chat_id')->comment('隶属群ID');
            $table->string('user_id')->comment('tg的ID');
            $table->string('username')->nullable()->comment('用户名称');
            $table->dateTime('stime')->nullable()->comment('启用时间');
            $table->integer('bill_unit')->default(1)->comment('计费单位');     //0分1天2月
            $table->integer('bill_cycle')->default(1)->comment('计费周期');     //依照bill_unit赋值
            $table->decimal('amount', 12, 2)->default(0)->comment('费用');    //计费单位要收的费用
            $table->decimal('balance', 12, 2)->default(0)->comment('当前余额');
            $table->integer('tg_msg')->default('1')->comment('0不通知1通知');    //Tg消息通知
            $table->integer('auto_stop')->default('0')->comment('0不停1停止');      //欠费是否自动停止
            $table->string('subjection')->nullable()->comment('隶属管理机器人');
            $table->longText('memo')->nullable()->comment('备注说明');
            $table->dateTime('created_at')->useCurrent()->nullable();
            $table->dateTime('updated_at')->nullable()->useCurrentOnUpdate();
            $table->charset = 'utf8mb4';
            $table->collation = 'utf8mb4_0900_ai_ci';
            $table->comment('账户资料');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('user_account');
    }
};
