Skip to content

Commit

Permalink
Updating database judgements
Browse files Browse the repository at this point in the history
  • Loading branch information
shebaoting committed Sep 1, 2024
1 parent 22ccb45 commit 9cdfd8d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"keywords": [
"flarum"
],
"version": "0.1.0",
"version": "0.2.0",
"type": "flarum-extension",
"license": "MIT",
"require": {
Expand Down
22 changes: 19 additions & 3 deletions migrations/2017_01_20_000000_add_money_to_users_table.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
<?php

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

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

0 comments on commit 9cdfd8d

Please sign in to comment.