<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('wallet', function (Blueprint $table) {
            $table->comment('钱包');
            $table->increments('id');
            $table->unsignedBigInteger('owner_id')->comment('所属主体编号');
            $table->string('owner_type')->default('')->comment('钱包类型');
            $table->decimal('total_balance')->default(new \Illuminate\Database\Query\Expression('0.00'))->comment('总余额');
            $table->decimal('available_balance')->default(new \Illuminate\Database\Query\Expression('0.00'))->comment('可用余额');
            $table->decimal('frozen_amount')->default(new \Illuminate\Database\Query\Expression('0.00'))->comment('冻结金额');
            $table->decimal('total_income')->default(new \Illuminate\Database\Query\Expression('0.00'))->comment('累计收入');
            $table->decimal('total_expense')->default(new \Illuminate\Database\Query\Expression('0.00'))->comment('累计支出');
            $table->string('state')->default('ENABLE')->comment('状态：ENABLE-启用，DISABLE-禁用');
            $table->timestamps();
            $table->softDeletes();
        });
    }

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