From 5b99f3180565f9d5913bb783aae970e014469153 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Mon, 5 Sep 2016 08:19:03 +0300 Subject: [PATCH] Fix for foreign keys --- .../2016_04_16_103943_enterprise_plan.php | 3 +++ .../2016_04_18_174135_add_page_size.php | 5 ++++- .../2016_04_23_182223_payments_changes.php | 15 +++++++++++---- 3 files changed, 18 insertions(+), 5 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 7bd9c895a5..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'); }); } diff --git a/database/migrations/2016_04_23_182223_payments_changes.php b/database/migrations/2016_04_23_182223_payments_changes.php index 28fc2d58f1..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,8 +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'); }); }