改进 迁移
This commit is contained in:
parent
0cdbe75340
commit
44b907818f
@ -14,7 +14,7 @@ public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
//
|
||||
$table->decimal('balances', 10)->default(0)->after('password');
|
||||
$table->decimal('balance', 10)->default(0)->after('password');
|
||||
|
||||
// drop column if exists
|
||||
if (Schema::hasColumn('users', 'drops')) {
|
||||
@ -32,7 +32,7 @@ public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
//
|
||||
$table->dropColumn('balances');
|
||||
$table->dropColumn('balance');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -14,7 +14,7 @@ public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
//
|
||||
$table->dateTime('banned_at')->nullable()->comment('封禁时间')->after('balances');
|
||||
$table->dateTime('banned_at')->nullable()->comment('封禁时间')->after('balance');
|
||||
// reason
|
||||
$table->string('banned_reason')->nullable()->after('banned_at');
|
||||
});
|
||||
|
@ -1,37 +0,0 @@
|
||||
<?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(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
|
||||
// if it has balances
|
||||
if (Schema::hasColumn('users', 'balances')) {
|
||||
$table->renameColumn('balances', 'balance');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('users', 'balance')) {
|
||||
$table->renameColumn('balance', 'balances');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue
Block a user