Skip to content

Commit

Permalink
Fix #18 : Install using MySQL causes exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Bubka committed Dec 2, 2020
1 parent b80f7b6 commit 2f728a7
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ class AddGroupIdColumnToTwofaccountsTable extends Migration
*/
public function up()
{
Schema::enableForeignKeyConstraints();

Schema::table('twofaccounts', function (Blueprint $table) {
$table->foreignId('group_id')
$table->unsignedInteger('group_id')
->after('id')
->nullable()
->constrained()
->onDelete('set null');

$table->foreign('group_id')->references('id')->on('groups');
});
}

Expand All @@ -31,11 +31,16 @@ public function up()
*/
public function down()
{
Schema::disableForeignKeyConstraints();
Schema::table('twofaccounts', function (Blueprint $table) {
// cannot drop foreign keys in SQLite:
if ('sqlite' !== config('database.default')) {
$table->dropForeign(['group_id']);
}
}
);

Schema::table('twofaccounts', function (Blueprint $table) {
//$table->dropForeign('group_id');
$table->dropColumn('group_id');
});
}
}
}

0 comments on commit 2f728a7

Please sign in to comment.