Check if table exists before trying to create

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2022-03-07 20:13:10 -08:00
parent e30d814ece
commit 86a2312a31
6 changed files with 74 additions and 60 deletions

View file

@ -13,20 +13,22 @@ class CreateCheckoutAcceptancesTable extends Migration
*/
public function up()
{
Schema::create('checkout_acceptances', function (Blueprint $table) {
$table->increments('id');
if (!Schema::hasTable('checkout_acceptances')) {
Schema::create('checkout_acceptances', function (Blueprint $table) {
$table->increments('id');
$table->morphs('checkoutable');
$table->integer('assigned_to_id')->nullable();
$table->morphs('checkoutable');
$table->integer('assigned_to_id')->nullable();
$table->string('signature_filename')->nullable();
$table->string('signature_filename')->nullable();
$table->timestamp('accepted_at')->nullable();
$table->timestamp('declined_at')->nullable();
$table->timestamp('accepted_at')->nullable();
$table->timestamp('declined_at')->nullable();
$table->timestamps();
$table->softDeletes();
});
$table->timestamps();
$table->softDeletes();
});
}
}
/**
@ -36,6 +38,8 @@ class CreateCheckoutAcceptancesTable extends Migration
*/
public function down()
{
Schema::dropIfExists('checkout_acceptances');
if (Schema::hasTable('checkout_acceptances')) {
Schema::dropIfExists('checkout_acceptances');
}
}
}

View file

@ -12,14 +12,15 @@ class AddKitsLicensesTable extends Migration {
*/
public function up()
{
//
Schema::create('kits_licenses', function ($table) {
$table->increments('id');
$table->integer('kit_id')->nullable()->default(NULL);
$table->integer('license_id')->nullable()->default(NULL);
$table->integer('quantity')->default(1);
$table->timestamps();
});
if (!Schema::hasTable('kits_licenses')) {
Schema::create('kits_licenses', function ($table) {
$table->increments('id');
$table->integer('kit_id')->nullable()->default(NULL);
$table->integer('license_id')->nullable()->default(NULL);
$table->integer('quantity')->default(1);
$table->timestamps();
});
}
}
/**
@ -29,8 +30,9 @@ class AddKitsLicensesTable extends Migration {
*/
public function down()
{
//
Schema::drop('kits_licenses');
if (Schema::hasTable('kits_licenses')) {
Schema::drop('kits_licenses');
}
}
}

View file

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

View file

@ -12,14 +12,15 @@ class AddKitsModelsTable extends Migration {
*/
public function up()
{
//
Schema::create('kits_models', function ($table) {
$table->increments('id');
$table->integer('kit_id')->nullable()->default(NULL);
$table->integer('model_id')->nullable()->default(NULL);
$table->integer('quantity')->default(1);
$table->timestamps();
});
if (!Schema::hasTable('kits_models')) {
Schema::create('kits_models', function ($table) {
$table->increments('id');
$table->integer('kit_id')->nullable()->default(NULL);
$table->integer('model_id')->nullable()->default(NULL);
$table->integer('quantity')->default(1);
$table->timestamps();
});
}
}
/**
@ -29,8 +30,9 @@ class AddKitsModelsTable extends Migration {
*/
public function down()
{
//
Schema::drop('kits_models');
if (Schema::hasTable('kits_models')) {
Schema::drop('kits_models');
}
}
}

View file

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

View file

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