fix migrate-data.ts postgres connection for unix socket

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-03 15:54:32 +01:00
parent 478ab57ef3
commit 08393cd7cd

View File

@@ -30,7 +30,15 @@ const maria = await mysql.createConnection({
timezone: "+00:00",
});
const pg = postgres(PG_URL);
const pgUrl = new URL(PG_URL);
const socketHost = pgUrl.searchParams.get("host");
const pg = postgres({
host: socketHost ?? pgUrl.hostname,
port: Number(pgUrl.port) || 5432,
database: pgUrl.pathname.slice(1),
username: pgUrl.username,
password: pgUrl.password,
});
// Order: rounds → round_users → movies → votes → round_history (FK constraint order)