From 548bb08b18ac9754bc6747ad8ef390c0a48a223e Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Mon, 5 Sep 2016 08:18:22 +0300 Subject: [PATCH] Fix for foreign keys --- .../2016_04_16_103943_enterprise_plan.php | 3 +++ .../2016_04_18_174135_add_page_size.php | 7 +++++-- .../2016_04_23_182223_payments_changes.php | 20 +++++++++++++------ 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/database/migrations/2016_04_16_103943_enterprise_plan.php b/database/migrations/2016_04_16_103943_enterprise_plan.php index fa86ef19a1..41ec9dfc4a 100644 --- a/database/migrations/2016_04_16_103943_enterprise_plan.php +++ b/database/migrations/2016_04_16_103943_enterprise_plan.php @@ -49,6 +49,9 @@ class EnterprisePlan extends Migration Schema::table('accounts', function($table) { $table->unsignedInteger('company_id')->nullable(); + }); + Schema::table('accounts', function($table) + { $table->foreign('company_id')->references('id')->on('companies')->onDelete('cascade'); }); } diff --git a/database/migrations/2016_04_18_174135_add_page_size.php b/database/migrations/2016_04_18_174135_add_page_size.php index 0b17124885..2eae676834 100644 --- a/database/migrations/2016_04_18_174135_add_page_size.php +++ b/database/migrations/2016_04_18_174135_add_page_size.php @@ -41,7 +41,10 @@ class AddPageSize extends Migration Schema::table('expenses', function ($table) { $table->unsignedInteger('expense_category_id')->nullable()->index(); - //$table->foreign('expense_category_id')->references('id')->on('expense_categories')->onDelete('cascade'); + }); + + Schema::table('expenses', function ($table) { + $table->foreign('expense_category_id')->references('id')->on('expense_categories')->onDelete('cascade'); }); } @@ -63,7 +66,7 @@ class AddPageSize extends Migration }); Schema::table('expenses', function ($table) { - //$table->dropForeign('expenses_expense_category_id_foreign'); + $table->dropForeign('expenses_expense_category_id_foreign'); $table->dropColumn('expense_category_id'); }); diff --git a/database/migrations/2016_04_23_182223_payments_changes.php b/database/migrations/2016_04_23_182223_payments_changes.php index 5f0994d62d..2b69336740 100644 --- a/database/migrations/2016_04_23_182223_payments_changes.php +++ b/database/migrations/2016_04_23_182223_payments_changes.php @@ -79,18 +79,22 @@ class PaymentsChanges extends Migration { $table->decimal('refunded', 13, 2); $table->unsignedInteger('payment_status_id')->default(PAYMENT_STATUS_COMPLETED); - $table->foreign('payment_status_id')->references('id')->on('payment_statuses'); $table->unsignedInteger('routing_number')->nullable(); $table->smallInteger('last4')->unsigned()->nullable(); $table->date('expiration')->nullable(); $table->text('gateway_error')->nullable(); $table->string('email')->nullable(); - $table->unsignedInteger('payment_method_id')->nullable(); - //$table->foreign('payment_method_id')->references('id')->on('payment_methods'); }); + Schema::table('payments', function($table) + { + $table->foreign('payment_status_id')->references('id')->on('payment_statuses'); + $table->foreign('payment_method_id')->references('id')->on('payment_methods'); + }); + + Schema::table('invoices', function($table) { $table->boolean('client_enable_auto_bill')->default(false); @@ -109,7 +113,11 @@ class PaymentsChanges extends Migration Schema::table('account_gateway_tokens', function($table) { $table->unsignedInteger('default_payment_method_id')->nullable(); - //$table->foreign('default_payment_method_id')->references('id')->on('payment_methods'); + }); + + Schema::table('account_gateway_tokens', function($table) + { + $table->foreign('default_payment_method_id')->references('id')->on('payment_methods'); }); } @@ -133,7 +141,7 @@ class PaymentsChanges extends Migration $table->dropColumn('gateway_error'); $table->dropColumn('email'); - //$table->dropForeign('payments_payment_method_id_foreign'); + $table->dropForeign('payments_payment_method_id_foreign'); $table->dropColumn('payment_method_id'); }); @@ -163,7 +171,7 @@ class PaymentsChanges extends Migration Schema::table('account_gateway_tokens', function($table) { - //$table->dropForeign('account_gateway_tokens_default_payment_method_id_foreign'); + $table->dropForeign('account_gateway_tokens_default_payment_method_id_foreign'); $table->dropColumn('default_payment_method_id'); });