<?php

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

class CreateUserAccountLogsTable extends Migration
{

    /**
     * Run the migrations.
     * @return void
     */
    public function up()
    {
        Schema::create('user_account_logs', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('account_id');
            $table->unsignedBigInteger('rule_id');
            $table->string('type', 50)->nullable();
            $table->decimal('amount');
            $table->decimal('balance');
            $table->boolean('frozen')->default(0);
            $table->string('remark')->nullable();
            $table->json('source')->nullable();
            $table->timestamp('settle_at')->nullable()->comment('列入结算日期');
            $table->timestamp('frozen_at')->nullable()->comment('可解冻时间');
            $table->timestamps();
        });
    }

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

}
