4
0
Fork 0
dcat-admin-user/database/migrations/2022_08_11_110611_create_us...

73 lines
2.4 KiB
PHP

<?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('users', function (Blueprint $table) {
$table->id();
$table->string('username');
$table->string('password')->nullable();
$table->string('phone')->nullable();
$table->string('name')->nullable();
$table->string('gender')->nullable();
$table->string('avatar')->nullable();
$table->decimal('balance', 12, 2)->default(0)->comment('余额');
$table->string('invite_code')->comment('邀请码');
$table->unsignedBigInteger('inviter_id')->nullable()->comment('邀请人');
$table->string('inviter_path')->default('-')->comment('所有上级邀请人');
$table->timestamps();
$table->comment('用户表');
});
Schema::create('user_socialites', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('user_id');
$table->string('type');
$table->string('openid');
$table->string('unionid')->nullable();
$table->json('data')->nullable();
$table->timestamps();
$table->comment('用户-第三方登录');
});
Schema::create('user_balance_logs', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('user_id');
$table->string('user_name')->comment('用户名');
$table->string('cate')->comment('类别');
$table->string('description')->comment('描述');
$table->decimal('amount', 12, 2)->comment('变动数量, 正数为增加, 负数为减少');
$table->decimal('balance', 12, 2)->comment('变更后的余额');
$table->string('remarks')->nullable()->comment('备注');
$table->nullableMorphs('source');
$table->timestamps();
$table->comment('用户-余额流水记录');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('user_balance_logs');
Schema::dropIfExists('user_socialites');
Schema::dropIfExists('users');
}
};