From aa5ee6053f3fa064596919ef12e82b4cd4660025 Mon Sep 17 00:00:00 2001 From: Watheq Alshowaiter Date: Tue, 20 Aug 2024 16:14:30 +0300 Subject: [PATCH] fix: disable foreign key constraint when backup --- src/BackupTablesService.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/BackupTablesService.php b/src/BackupTablesService.php index 346462e..3c19f87 100644 --- a/src/BackupTablesService.php +++ b/src/BackupTablesService.php @@ -67,6 +67,8 @@ protected function processBackup(array $tablesToBackup = []) $databaseDriver = DB::connection()->getDriverName(); + Schema::disableForeignKeyConstraints(); + switch ($databaseDriver) { case 'sqlite': $this->backupTablesForSqlite($newTableName, $table); @@ -83,7 +85,11 @@ protected function processBackup(array $tablesToBackup = []) break; default: throw Exception('NOT SUPPORTED DATABASE DRIVER'); + } + + Schema::enableForeignKeyConstraints(); + } return [