From 5b59bb3213f4e1d248e74bf4390debdd0bf84d1c Mon Sep 17 00:00:00 2001 From: Watheq Alshowaiter Date: Sat, 24 Aug 2024 14:46:31 +0300 Subject: [PATCH] WIP: return test_generate_multiple_table_backup back --- src/BackupTablesService.php | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/src/BackupTablesService.php b/src/BackupTablesService.php index 5b2660a..4d4d411 100644 --- a/src/BackupTablesService.php +++ b/src/BackupTablesService.php @@ -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")) @@ -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); }