Merge pull request #10799 from snipe/fixes/check_if_tables_exist_before_trying_to_create

Check if table exists before trying to create in migrations
This commit is contained in:
snipe 2022-03-07 20:22:28 -08:00 committed by GitHub
commit ed39df349f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 74 additions and 60 deletions

View file

@ -13,6 +13,7 @@ class CreateCheckoutAcceptancesTable extends Migration
*/ */
public function up() public function up()
{ {
if (!Schema::hasTable('checkout_acceptances')) {
Schema::create('checkout_acceptances', function (Blueprint $table) { Schema::create('checkout_acceptances', function (Blueprint $table) {
$table->increments('id'); $table->increments('id');
@ -28,6 +29,7 @@ class CreateCheckoutAcceptancesTable extends Migration
$table->softDeletes(); $table->softDeletes();
}); });
} }
}
/** /**
* Reverse the migrations. * Reverse the migrations.
@ -36,6 +38,8 @@ class CreateCheckoutAcceptancesTable extends Migration
*/ */
public function down() public function down()
{ {
if (Schema::hasTable('checkout_acceptances')) {
Schema::dropIfExists('checkout_acceptances'); Schema::dropIfExists('checkout_acceptances');
} }
}
} }

View file

@ -12,7 +12,7 @@ class AddKitsLicensesTable extends Migration {
*/ */
public function up() public function up()
{ {
// if (!Schema::hasTable('kits_licenses')) {
Schema::create('kits_licenses', function ($table) { Schema::create('kits_licenses', function ($table) {
$table->increments('id'); $table->increments('id');
$table->integer('kit_id')->nullable()->default(NULL); $table->integer('kit_id')->nullable()->default(NULL);
@ -21,6 +21,7 @@ class AddKitsLicensesTable extends Migration {
$table->timestamps(); $table->timestamps();
}); });
} }
}
/** /**
* Reverse the migrations. * Reverse the migrations.
@ -29,8 +30,9 @@ class AddKitsLicensesTable extends Migration {
*/ */
public function down() public function down()
{ {
// if (Schema::hasTable('kits_licenses')) {
Schema::drop('kits_licenses'); Schema::drop('kits_licenses');
} }
}
} }

View file

@ -12,13 +12,14 @@ class AddKitsTable extends Migration {
*/ */
public function up() public function up()
{ {
// if (!Schema::hasTable('kits')) {
Schema::create('kits', function ($table) { Schema::create('kits', function ($table) {
$table->increments('id'); $table->increments('id');
$table->string('name')->nullable()->default(NULL); $table->string('name')->nullable()->default(NULL);
$table->timestamps(); $table->timestamps();
$table->engine = 'InnoDB'; $table->engine = 'InnoDB';
}); });
}
} }
@ -29,8 +30,9 @@ class AddKitsTable extends Migration {
*/ */
public function down() public function down()
{ {
// if (Schema::hasTable('kits')) {
Schema::drop('kits'); Schema::drop('kits');
}
} }

View file

@ -12,7 +12,7 @@ class AddKitsModelsTable extends Migration {
*/ */
public function up() public function up()
{ {
// if (!Schema::hasTable('kits_models')) {
Schema::create('kits_models', function ($table) { Schema::create('kits_models', function ($table) {
$table->increments('id'); $table->increments('id');
$table->integer('kit_id')->nullable()->default(NULL); $table->integer('kit_id')->nullable()->default(NULL);
@ -21,6 +21,7 @@ class AddKitsModelsTable extends Migration {
$table->timestamps(); $table->timestamps();
}); });
} }
}
/** /**
* Reverse the migrations. * Reverse the migrations.
@ -29,8 +30,9 @@ class AddKitsModelsTable extends Migration {
*/ */
public function down() public function down()
{ {
// if (Schema::hasTable('kits_models')) {
Schema::drop('kits_models'); Schema::drop('kits_models');
} }
}
} }

View file

@ -13,7 +13,7 @@ class AddKitsConsumablesTable extends Migration
*/ */
public function up() public function up()
{ {
// if (!Schema::hasTable('kits_consumables')) {
Schema::create('kits_consumables', function ($table) { Schema::create('kits_consumables', function ($table) {
$table->increments('id'); $table->increments('id');
$table->integer('kit_id')->nullable()->default(NULL); $table->integer('kit_id')->nullable()->default(NULL);
@ -22,6 +22,7 @@ class AddKitsConsumablesTable extends Migration
$table->timestamps(); $table->timestamps();
}); });
} }
}
/** /**
* Reverse the migrations. * Reverse the migrations.
@ -30,7 +31,8 @@ class AddKitsConsumablesTable extends Migration
*/ */
public function down() public function down()
{ {
// if (Schema::hasTable('kits_consumables')) {
Schema::drop('kits_consumables'); Schema::drop('kits_consumables');
} }
}
} }

View file

@ -13,7 +13,7 @@ class AddKitsAccessoriesTable extends Migration
*/ */
public function up() public function up()
{ {
// if (!Schema::hasTable('kits_accessories')) {
Schema::create('kits_accessories', function ($table) { Schema::create('kits_accessories', function ($table) {
$table->increments('id'); $table->increments('id');
$table->integer('kit_id')->nullable()->default(NULL); $table->integer('kit_id')->nullable()->default(NULL);
@ -22,6 +22,7 @@ class AddKitsAccessoriesTable extends Migration
$table->timestamps(); $table->timestamps();
}); });
} }
}
/** /**
* Reverse the migrations. * Reverse the migrations.
@ -30,7 +31,8 @@ class AddKitsAccessoriesTable extends Migration
*/ */
public function down() public function down()
{ {
// if (Schema::hasTable('kits_accessories')) {
Schema::drop('kits_accessories'); Schema::drop('kits_accessories');
} }
}
} }