1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-11 13:42:49 +01:00

Fix for foreign keys

This commit is contained in:
Hillel Coren 2016-09-05 08:19:03 +03:00
parent 0450803d57
commit 5b99f31805
3 changed files with 18 additions and 5 deletions

View File

@ -49,6 +49,9 @@ class EnterprisePlan extends Migration
Schema::table('accounts', function($table) Schema::table('accounts', function($table)
{ {
$table->unsignedInteger('company_id')->nullable(); $table->unsignedInteger('company_id')->nullable();
});
Schema::table('accounts', function($table)
{
$table->foreign('company_id')->references('id')->on('companies')->onDelete('cascade'); $table->foreign('company_id')->references('id')->on('companies')->onDelete('cascade');
}); });
} }

View File

@ -41,7 +41,10 @@ class AddPageSize extends Migration
Schema::table('expenses', function ($table) { Schema::table('expenses', function ($table) {
$table->unsignedInteger('expense_category_id')->nullable()->index(); $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');
}); });
} }

View File

@ -79,18 +79,22 @@ class PaymentsChanges extends Migration
{ {
$table->decimal('refunded', 13, 2); $table->decimal('refunded', 13, 2);
$table->unsignedInteger('payment_status_id')->default(PAYMENT_STATUS_COMPLETED); $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->unsignedInteger('routing_number')->nullable();
$table->smallInteger('last4')->unsigned()->nullable(); $table->smallInteger('last4')->unsigned()->nullable();
$table->date('expiration')->nullable(); $table->date('expiration')->nullable();
$table->text('gateway_error')->nullable(); $table->text('gateway_error')->nullable();
$table->string('email')->nullable(); $table->string('email')->nullable();
$table->unsignedInteger('payment_method_id')->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) Schema::table('invoices', function($table)
{ {
$table->boolean('client_enable_auto_bill')->default(false); $table->boolean('client_enable_auto_bill')->default(false);
@ -109,8 +113,11 @@ class PaymentsChanges extends Migration
Schema::table('account_gateway_tokens', function($table) Schema::table('account_gateway_tokens', function($table)
{ {
$table->unsignedInteger('default_payment_method_id')->nullable(); $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');
}); });
} }