正在显示
1 个修改的文件
包含
2 行增加
和
6 行删除
| @@ -229,12 +229,8 @@ class CopyProject extends Command | @@ -229,12 +229,8 @@ class CopyProject extends Command | ||
| 229 | $tables = Schema::connection('custom_tmp_mysql_copy')->getAllTables(); | 229 | $tables = Schema::connection('custom_tmp_mysql_copy')->getAllTables(); |
| 230 | $tables = array_column($tables, 'Tables_in_' . $database_name); | 230 | $tables = array_column($tables, 'Tables_in_' . $database_name); |
| 231 | foreach ($tables as $table) { | 231 | foreach ($tables as $table) { |
| 232 | - // 目标数据库是否存在该表 | ||
| 233 | - $has_table = Schema::connection('custom_mysql')->hasTable($table); | ||
| 234 | - if ($has_table) { | ||
| 235 | - // 1. 删除目标数据库中的表 | ||
| 236 | - DB::connection('custom_mysql')->statement("DROP TABLE IF EXISTS {$table}"); | ||
| 237 | - } | 232 | + // 1. 删除目标数据库中的表 |
| 233 | + DB::connection('custom_mysql')->statement("DROP TABLE IF EXISTS {$table}"); | ||
| 238 | // 2. 重新创建表 | 234 | // 2. 重新创建表 |
| 239 | $sql = DB::connection('custom_tmp_mysql_copy')->select("SHOW CREATE TABLE {$table}"); | 235 | $sql = DB::connection('custom_tmp_mysql_copy')->select("SHOW CREATE TABLE {$table}"); |
| 240 | DB::connection('custom_mysql')->statement(get_object_vars($sql[0])['Create Table']); | 236 | DB::connection('custom_mysql')->statement(get_object_vars($sql[0])['Create Table']); |
-
请 注册 或 登录 后发表评论