Skip to content

Commit

Permalink
修复数据库迁移
Browse files Browse the repository at this point in the history
  • Loading branch information
shebaoting committed Sep 2, 2024
1 parent 9cdfd8d commit 45c3fa2
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions migrations/2017_01_20_000000_add_money_to_users_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,20 @@

use Flarum\Database\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Builder;

return [
'up' => function (Builder $schema) {
$schema->table('users', function (Blueprint $table) {
if (!Schema::hasColumn('users', 'money')) {
$table->integer('money')->default(0); // 根据需要设置默认值
$schema->table('users', function (Blueprint $table) use ($schema) {
if (!$schema->hasColumn('users', 'money')) {
$table->integer('money')->nullable();
}
});
},

'down' => function (Builder $schema) {
$schema->table('users', function (Blueprint $table) {
if (Schema::hasColumn('users', 'money')) {
$table->dropColumn('money');
}
$table->dropColumn('money');
});
}
},
];

0 comments on commit 45c3fa2

Please sign in to comment.