Skip to content

Commit

Permalink
WIP: change code for sql Server
Browse files Browse the repository at this point in the history
  • Loading branch information
WatheqAlshowaiter committed Aug 23, 2024
1 parent 612ebdf commit eea7673
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/BackupTablesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ protected function backupTablesForForMysql($newTableName, $table): array
// Step 3: Insert data into the new table, excluding generated columns
//DB::statement(/**@lang MySQL */ "INSERT INTO $newTableName ($columns) SELECT $columns FROM $table");

DB::statement(/**@lang PostgreSQL */ "CREATE TABLE $newTableName AS SELECT * FROM $table"); // todo for now
return $this->returnedBackupResponse($newTableName, $table);
}

Expand Down
15 changes: 15 additions & 0 deletions tests/BackupTablesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,27 @@ public function test_generate_2_single_table_backup_all_table_data()
$newFatherTable = $fatherTable . '_backup_' . $currentDateTime;
$newSonTable = $sonTable . '_backup_' . $currentDateTime;

// todo Debugging output to inspect the contents of the backup table
$backupData = DB::table($fatherTable)->get();
dump([
DB::getDriverName(),
$backupData
]);

$this->assertTrue(Schema::hasTable($newFatherTable));

$this->assertEquals(DB::table('fathers')->value('first_name'), DB::table($newFatherTable)->value('first_name'));
$this->assertEquals(DB::table('fathers')->value('email'), DB::table($newFatherTable)->value('email'));

BackupTables::generateBackup($sonTable);

// todo Debugging output to inspect the contents of the backup table
$backupData = DB::table($newSonTable)->get();
dump([
DB::getDriverName(),
$backupData
]);

$this->assertTrue(Schema::hasTable($newSonTable));
$this->assertEquals(DB::table('sons')->value('father_id'), DB::table($newSonTable)->value('father_id'));
}
Expand Down
5 changes: 4 additions & 1 deletion todos.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
- [x] fix duplicate console `Table 'fathers' completed backup successfully.` when use `test_generate_2_single_table_backup_all_table_data`
- [x] add database drop list (sqlite, mysql, sql server, mariadb, postgres) + version for each of them in the ISSUE_TEMPLATE, and make it required and even add it to the next
- [x] extract `mysql 8`, `mysql 5.7` and `mariadb` in separate GitHub actions if the still conflicts with each other and works fine alone.
- [ ] fix for foreign keys, and return foreign key father_id
- [x] fix for foreign keys, and return foreign key father_id
- [ ] fix for MySQL 5.7 with new implementation
- [ ] fix for SQL Server
- [ ] return back all tests
- [ ] check the console output when backup is correct and make in tests (prefer)
- [ ] return back pint formatting GitHub actions
- [ ] clean up the code, fix all todo in the code, and remove commented code

0 comments on commit eea7673

Please sign in to comment.