Add some if-statements to the migrations.

This commit is contained in:
James Cole 2021-04-05 10:56:56 +02:00
parent f5983f08fd
commit 1cf188ee08
No known key found for this signature in database
GPG Key ID: B5669F9493CDE38D

View File

@ -120,9 +120,11 @@ class ChangesForV550 extends Migration
// update budget / transaction journal table. // update budget / transaction journal table.
Schema::table( Schema::table(
'budget_transaction_journal', function (Blueprint $table) { 'budget_transaction_journal', function (Blueprint $table) {
if (!Schema::hasColumn('budget_transaction_journal', 'budget_limit_id')) {
$table->integer('budget_limit_id', false, true)->nullable()->default(null)->after('budget_id'); $table->integer('budget_limit_id', false, true)->nullable()->default(null)->after('budget_id');
$table->foreign('budget_limit_id', 'budget_id_foreign')->references('id')->on('budget_limits')->onDelete('set null'); $table->foreign('budget_limit_id', 'budget_id_foreign')->references('id')->on('budget_limits')->onDelete('set null');
} }
}
); );
// append budget limits table. // append budget limits table.
@ -130,12 +132,17 @@ class ChangesForV550 extends Migration
Schema::table( Schema::table(
'budget_limits', 'budget_limits',
static function (Blueprint $table) { static function (Blueprint $table) {
if (!Schema::hasColumn('budget_limits', 'period')) {
$table->string('period', 12)->nullable(); $table->string('period', 12)->nullable();
}
if (!Schema::hasColumn('budget_limits', 'generated')) {
$table->boolean('generated')->default(false); $table->boolean('generated')->default(false);
} }
}
); );
// new webhooks table // new webhooks table
if (!Schema::hasTable('webhooks')) {
Schema::create( Schema::create(
'webhooks', 'webhooks',
static function (Blueprint $table) { static function (Blueprint $table) {
@ -154,8 +161,10 @@ class ChangesForV550 extends Migration
$table->unique(['user_id', 'title']); $table->unique(['user_id', 'title']);
} }
); );
}
// new webhook_messages table // new webhook_messages table
if (!Schema::hasTable('webhook_messages')) {
Schema::create( Schema::create(
'webhook_messages', 'webhook_messages',
static function (Blueprint $table) { static function (Blueprint $table) {
@ -172,7 +181,9 @@ class ChangesForV550 extends Migration
$table->foreign('webhook_id')->references('id')->on('webhooks')->onDelete('cascade'); $table->foreign('webhook_id')->references('id')->on('webhooks')->onDelete('cascade');
} }
); );
}
if (!Schema::hasTable('webhook_attempts')) {
Schema::create( Schema::create(
'webhook_attempts', 'webhook_attempts',
static function (Blueprint $table) { static function (Blueprint $table) {
@ -190,3 +201,4 @@ class ChangesForV550 extends Migration
); );
} }
} }
}