Merge pull request #62 from kilya11/master

Handle foreign keys
This commit is contained in:
James Cole 2015-02-11 14:29:19 +01:00
commit 7ed2e03654
2 changed files with 8 additions and 0 deletions

View File

@ -234,7 +234,9 @@ class ChangesForV321 extends Migration
{ {
Schema::table( Schema::table(
'limit_repetitions', function (Blueprint $table) { 'limit_repetitions', function (Blueprint $table) {
$table->dropForeign('limit_repetitions_budget_limit_id_foreign');
$table->renameColumn('budget_limit_id', 'limit_id'); $table->renameColumn('budget_limit_id', 'limit_id');
$table->foreign('limit_id')->references('id')->on('limits')->onDelete('cascade');
} }
); );
} }
@ -402,7 +404,9 @@ class ChangesForV321 extends Migration
{ {
Schema::table( Schema::table(
'limit_repetitions', function (Blueprint $table) { 'limit_repetitions', function (Blueprint $table) {
$table->dropForeign('limit_repetitions_limit_id_foreign');
$table->renameColumn('limit_id', 'budget_limit_id'); $table->renameColumn('limit_id', 'budget_limit_id');
$table->foreign('budget_limit_id')->references('id')->on('budget_limits')->onDelete('cascade');
} }
); );
} }

View File

@ -109,13 +109,17 @@ class ChangesForV322 extends Migration
// rename fields // rename fields
Schema::table( Schema::table(
'piggy_bank_events', function (Blueprint $table) { 'piggy_bank_events', function (Blueprint $table) {
$table->dropForeign('piggybank_events_piggybank_id_foreign');
$table->renameColumn('piggybank_id', 'piggy_bank_id'); $table->renameColumn('piggybank_id', 'piggy_bank_id');
$table->foreign('piggy_bank_id')->references('id')->on('piggy_banks')->onDelete('cascade');
} }
); );
Schema::table( Schema::table(
'piggy_bank_repetitions', function (Blueprint $table) { 'piggy_bank_repetitions', function (Blueprint $table) {
$table->dropForeign('piggybank_repetitions_piggybank_id_foreign');
$table->renameColumn('piggybank_id', 'piggy_bank_id'); $table->renameColumn('piggybank_id', 'piggy_bank_id');
$table->foreign('piggy_bank_id')->references('id')->on('piggy_banks')->onDelete('cascade');
} }
); );