2023_05_08_112141_create_user_wallets_table.php 1.3 KB
<?php

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

class CreateUserWalletsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_wallets', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedBigInteger('user_id')->index()->comment('用户ID');
            $table->decimal('income', 11)->nullable()->default(0.00)->comment('累计总收益');
            $table->decimal('balance', 11)->nullable()->default(0.00)->comment('账户余额');
            $table->decimal('withdrawn', 11)->nullable()->default(0.00)->comment('已提现总额');
            $table->decimal('frozen', 11)->nullable()->default(0.00)->comment('冻结总额');

            $table->tinyInteger('status')->nullable()->default(1)->comment('状态:1-有效;0-无效');
            $table->timestamps();
            $table->softDeletes();
        });
        DB::statement("ALTER TABLE `user_wallets` comment '用户-钱包' ");
    }

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