Fix for self host database migrations

This commit is contained in:
Hillel Coren 2016-11-29 21:04:08 +02:00
parent 0731165d8f
commit a08ebaeae9
6 changed files with 23 additions and 9 deletions

View File

@ -38,15 +38,14 @@ class AddDocuments extends Migration {
$t->unsignedInteger('size'); $t->unsignedInteger('size');
$t->unsignedInteger('width')->nullable(); $t->unsignedInteger('width')->nullable();
$t->unsignedInteger('height')->nullable(); $t->unsignedInteger('height')->nullable();
$t->timestamps(); $t->timestamps();
});
Schema::table('documents', function($t) {
$t->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade'); $t->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
$t->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); $t->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$t->foreign('invoice_id')->references('id')->on('invoices')->onDelete('cascade'); $t->foreign('invoice_id')->references('id')->on('invoices')->onDelete('cascade');
$t->foreign('expense_id')->references('id')->on('expenses')->onDelete('cascade'); $t->foreign('expense_id')->references('id')->on('expenses')->onDelete('cascade');
$t->unique( array('account_id','public_id') ); $t->unique( array('account_id','public_id') );
}); });
} }

View File

@ -32,7 +32,7 @@ class EnterprisePlan extends Migration
$table->date('plan_expires')->nullable(); $table->date('plan_expires')->nullable();
$table->unsignedInteger('payment_id')->nullable(); $table->unsignedInteger('payment_id')->nullable();
$table->foreign('payment_id')->references('id')->on('payments');
$table->date('trial_started')->nullable(); $table->date('trial_started')->nullable();
$table->enum('trial_plan', array('pro', 'enterprise'))->nullable(); $table->enum('trial_plan', array('pro', 'enterprise'))->nullable();
@ -43,6 +43,11 @@ class EnterprisePlan extends Migration
$table->timestamps(); $table->timestamps();
$table->softDeletes(); $table->softDeletes();
}); });
Schema::table('companies', function($table)
{
$table->foreign('payment_id')->references('id')->on('payments');
});
} }
if (!Schema::hasColumn('accounts', 'company_id')) { if (!Schema::hasColumn('accounts', 'company_id')) {

View File

@ -29,16 +29,17 @@ class AddPageSize extends Migration
$table->unsignedInteger('account_id')->index(); $table->unsignedInteger('account_id')->index();
$table->timestamps(); $table->timestamps();
$table->softDeletes(); $table->softDeletes();
$table->string('name')->nullable(); $table->string('name')->nullable();
$table->unsignedInteger('public_id')->index();
});
Schema::table('expense_categories', function ($table) {
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade'); $table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->unsignedInteger('public_id')->index();
$table->unique( array('account_id','public_id') ); $table->unique( array('account_id','public_id') );
}); });
Schema::table('expenses', function ($table) { Schema::table('expenses', function ($table) {
$table->unsignedInteger('expense_category_id')->nullable()->index(); $table->unsignedInteger('expense_category_id')->nullable()->index();
}); });

View File

@ -64,6 +64,11 @@ class PaymentsChanges extends Migration
$table->timestamps(); $table->timestamps();
$table->softDeletes(); $table->softDeletes();
$table->unsignedInteger('public_id')->index();
});
Schema::table('payment_methods', function($table)
{
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade'); $table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->foreign('contact_id')->references('id')->on('contacts')->onDelete('cascade'); $table->foreign('contact_id')->references('id')->on('contacts')->onDelete('cascade');
@ -71,7 +76,6 @@ class PaymentsChanges extends Migration
$table->foreign('payment_type_id')->references('id')->on('payment_types'); $table->foreign('payment_type_id')->references('id')->on('payment_types');
$table->foreign('currency_id')->references('id')->on('currencies'); $table->foreign('currency_id')->references('id')->on('currencies');
$table->unsignedInteger('public_id')->index();
$table->unique( array('account_id','public_id') ); $table->unique( array('account_id','public_id') );
}); });

View File

@ -22,7 +22,10 @@ class AddSupportForBots extends Migration
$table->string('code')->nullable(); $table->string('code')->nullable();
$table->string('bot_user_id')->unique(); $table->string('bot_user_id')->unique();
$table->timestamp('created_at')->useCurrent(); $table->timestamp('created_at')->useCurrent();
});
Schema::table('security_codes', function($table)
{
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->foreign('contact_id')->references('id')->on('contacts')->onDelete('cascade'); $table->foreign('contact_id')->references('id')->on('contacts')->onDelete('cascade');
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade'); $table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');

View File

@ -34,11 +34,13 @@ class CreateGatewayTypes extends Migration
$table->unsignedInteger('min_limit')->nullable(); $table->unsignedInteger('min_limit')->nullable();
$table->unsignedInteger('max_limit')->nullable(); $table->unsignedInteger('max_limit')->nullable();
});
Schema::table('account_gateway_settings', function($table)
{
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade'); $table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->foreign('gateway_type_id')->references('id')->on('gateway_types')->onDelete('cascade'); $table->foreign('gateway_type_id')->references('id')->on('gateway_types')->onDelete('cascade');
}); });
Schema::table('payment_types', function($table) Schema::table('payment_types', function($table)