@@ -115,8 +115,6 @@ protected function backupTablesForForMysql($newTableName, $table): array
115
115
116
116
// for MySQL 5.7
117
117
118
-
119
-
120
118
DB ::statement ("Create TABLE IF Not exists $ newTableName like $ table " );
121
119
122
120
$ columns = collect (DB ::select ("SHOW COLUMNS FROM $ table " ))
@@ -128,29 +126,6 @@ protected function backupTablesForForMysql($newTableName, $table): array
128
126
DB ::statement (/**@lang MySQL */ "INSERT INTO $ newTableName ( $ columns) SELECT $ columns FROM $ table " );
129
127
130
128
131
- // Step 1: Create the new table with the same structure, including generated columns
132
- //DB::statement(/**@lang MySQL */ "CREATE TABLE $newTableName LIKE $table");
133
-
134
- // Step 2: get the definition for generated columns `SHOW CREATE TABLE $table`
135
- // Step 3: extract the virtual columns definition to alter them later
136
- // Step 4: get all non-generated columns, then insert them to the new table
137
- // Step 5: Alter new table to add the generated tables definitions.
138
-
139
-
140
- //$generatedColumns = collect(DB::select(DB::raw('SHOW COLUMNS FROM $table')))
141
- //;
142
-
143
- // Step 2: Get the list of columns, excluding generated columns
144
- //$columns = collect(DB::select(DB::raw("SHOW COLUMNS FROM $table")))
145
- // ->reject(function ($column) {
146
- // return str_contains($column->Extra, 'VIRTUAL GENERATED') || str_contains($column->Extra, 'STORED GENERATED');
147
- // })->pluck('Field')
148
- // ->implode(', ');
149
-
150
- // Step 3: Insert data into the new table, excluding generated columns
151
- //DB::statement(/**@lang MySQL */ "INSERT INTO $newTableName ($columns) SELECT $columns FROM $table");
152
-
153
- //DB::statement(/**@lang PostgreSQL */ "CREATE TABLE $newTableName AS SELECT * FROM $table"); // todo for now
154
129
return $ this ->returnedBackupResponse ($ newTableName , $ table );
155
130
}
156
131
0 commit comments