Skip to content

Commit

Permalink
Fix error of foreign_key_constraint when rolling back migrations.
Browse files Browse the repository at this point in the history
  • Loading branch information
akoSalman committed Nov 23, 2017
1 parent ce471a4 commit 8083148
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ public function up()
*/
public function down()
{
// Don't check for foreign key constraints when executing below query in current session
DB::statement('set foreign_key_checks=0');

DB::statement("ALTER TABLE `" . $this->getTable() . "` CHANGE `id` `id` INT(10) UNSIGNED NOT NULL;");

// Ok! now DBMS can check for foregin key constraints
DB::statement('set foreign_key_checks=1');

}
}

0 comments on commit 8083148

Please sign in to comment.