Skip to content

Commit

Permalink
fix: disable foreign key constraint when backup
Browse files Browse the repository at this point in the history
  • Loading branch information
WatheqAlshowaiter committed Aug 20, 2024
1 parent 0c2dbea commit aa5ee60
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/BackupTablesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ protected function processBackup(array $tablesToBackup = [])

$databaseDriver = DB::connection()->getDriverName();

Schema::disableForeignKeyConstraints();

switch ($databaseDriver) {
case 'sqlite':
$this->backupTablesForSqlite($newTableName, $table);
Expand All @@ -83,7 +85,11 @@ protected function processBackup(array $tablesToBackup = [])
break;
default:
throw Exception('NOT SUPPORTED DATABASE DRIVER');

}

Schema::enableForeignKeyConstraints();

}

return [
Expand Down

0 comments on commit aa5ee60

Please sign in to comment.