Skip to content

Commit

Permalink
WIP: return test_generate_multiple_table_backup back
Browse files Browse the repository at this point in the history
  • Loading branch information
WatheqAlshowaiter committed Aug 24, 2024
1 parent a604f2f commit 5b59bb3
Showing 1 changed file with 0 additions and 25 deletions.
25 changes: 0 additions & 25 deletions src/BackupTablesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ protected function backupTablesForForMysql($newTableName, $table): array

// for MySQL 5.7



DB::statement("Create TABLE IF Not exists $newTableName like $table");

$columns = collect(DB::select("SHOW COLUMNS FROM $table"))
Expand All @@ -128,29 +126,6 @@ protected function backupTablesForForMysql($newTableName, $table): array
DB::statement(/**@lang MySQL */ "INSERT INTO $newTableName ($columns) SELECT $columns FROM $table");


// Step 1: Create the new table with the same structure, including generated columns
//DB::statement(/**@lang MySQL */ "CREATE TABLE $newTableName LIKE $table");

// Step 2: get the definition for generated columns `SHOW CREATE TABLE $table`
// Step 3: extract the virtual columns definition to alter them later
// Step 4: get all non-generated columns, then insert them to the new table
// Step 5: Alter new table to add the generated tables definitions.


//$generatedColumns = collect(DB::select(DB::raw('SHOW COLUMNS FROM $table')))
//;

// Step 2: Get the list of columns, excluding generated columns
//$columns = collect(DB::select(DB::raw("SHOW COLUMNS FROM $table")))
// ->reject(function ($column) {
// return str_contains($column->Extra, 'VIRTUAL GENERATED') || str_contains($column->Extra, 'STORED GENERATED');
// })->pluck('Field')
// ->implode(', ');

// 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

0 comments on commit 5b59bb3

Please sign in to comment.