正在显示
1 个修改的文件
包含
6 行增加
和
6 行删除
| @@ -350,19 +350,19 @@ class UpdateRoute extends Command | @@ -350,19 +350,19 @@ class UpdateRoute extends Command | ||
| 350 | { | 350 | { |
| 351 | $sourceTable = 'gl_route_map'; | 351 | $sourceTable = 'gl_route_map'; |
| 352 | $destinationTable = 'gl_route_map_copy'; | 352 | $destinationTable = 'gl_route_map_copy'; |
| 353 | - if (!Schema::hasTable($sourceTable)) { | 353 | + if (!Schema::connection('custom_mysql')->hasTable($sourceTable)) { |
| 354 | $this->error("Source table {$sourceTable} does not exist."); | 354 | $this->error("Source table {$sourceTable} does not exist."); |
| 355 | return false; | 355 | return false; |
| 356 | } | 356 | } |
| 357 | - if (Schema::hasTable($destinationTable)) { | ||
| 358 | - Schema::dropIfExists($destinationTable); | 357 | + if (Schema::connection('custom_mysql')->hasTable($destinationTable)) { |
| 358 | + Schema::connection('custom_mysql')->dropIfExists($destinationTable); | ||
| 359 | } | 359 | } |
| 360 | - $columns = DB::select(DB::raw("SHOW COLUMNS FROM {$sourceTable}")); | 360 | + $columns = DB::connection('custom_mysql')->select(DB::raw("SHOW COLUMNS FROM {$sourceTable}")); |
| 361 | $columnsDefinition = collect($columns)->map(function($column) { | 361 | $columnsDefinition = collect($columns)->map(function($column) { |
| 362 | return $column->Field . ' ' . $column->Type . ($column->Null === 'NO' ? ' NOT NULL' : '') . ($column->Default !== null ? " DEFAULT '" . $column->Default . "'" : '') . ($column->Extra ? ' ' . $column->Extra : ''); | 362 | return $column->Field . ' ' . $column->Type . ($column->Null === 'NO' ? ' NOT NULL' : '') . ($column->Default !== null ? " DEFAULT '" . $column->Default . "'" : '') . ($column->Extra ? ' ' . $column->Extra : ''); |
| 363 | })->implode(', '); | 363 | })->implode(', '); |
| 364 | - DB::statement("CREATE TABLE {$destinationTable} ({$columnsDefinition})"); | ||
| 365 | - DB::statement("INSERT INTO {$destinationTable} SELECT * FROM {$sourceTable}"); | 364 | + DB::connection('custom_mysql')->statement("CREATE TABLE {$destinationTable} ({$columnsDefinition})"); |
| 365 | + DB::connection('custom_mysql')->statement("INSERT INTO {$destinationTable} SELECT * FROM {$sourceTable}"); | ||
| 366 | $this->info("Table {$sourceTable} has been copied to {$destinationTable} successfully."); | 366 | $this->info("Table {$sourceTable} has been copied to {$destinationTable} successfully."); |
| 367 | } | 367 | } |
| 368 | 368 |
-
请 注册 或 登录 后发表评论