Skip to content

Commit

Permalink
Refactor DB table insertion to check if table exists before inserting.
Browse files Browse the repository at this point in the history
  • Loading branch information
herpaderpaldent committed Jan 5, 2025
1 parent 40351b0 commit 265c8c2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Services/MigrateDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ private function replicateTable(string $table): void
->map(fn (object $row) => (array) $row)
->map(fn (array $row) => array_filter($row, fn (string $key) => ! str_contains($key, 'name_normalized'), ARRAY_FILTER_USE_KEY));

DB::connection('pgsql')->table($table)->insert($table_data->toArray());
if (Schema::connection('pgsql')->hasTable($table)) {
DB::connection('pgsql')->table($table)->insert($table_data->toArray());
}
});
}

Expand Down

0 comments on commit 265c8c2

Please sign in to comment.