mirror of
https://github.com/BetterCorp/BetterFrame.git
synced 2026-05-26 19:06:34 +00:00
fix(db): log failing PG migration index + SQL on error
Was crashing silently during migration. Now logs which migration index failed and the first 200 chars of the SQL before rethrowing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
664e6e1548
commit
5c367203c6
1 changed files with 7 additions and 1 deletions
|
|
@ -52,7 +52,13 @@ export async function initDb(
|
||||||
PRIMARY KEY (schema_name, version)
|
PRIMARY KEY (schema_name, version)
|
||||||
)`);
|
)`);
|
||||||
for (let i = currentVersion; i < TENANT_MIGRATIONS.length; i++) {
|
for (let i = currentVersion; i < TENANT_MIGRATIONS.length; i++) {
|
||||||
|
try {
|
||||||
await adapter.exec(TENANT_MIGRATIONS[i]!);
|
await adapter.exec(TENANT_MIGRATIONS[i]!);
|
||||||
|
} catch (err) {
|
||||||
|
log.warn(`PG migration ${i} failed: ${(err as Error).message}`);
|
||||||
|
log.warn(`SQL: ${TENANT_MIGRATIONS[i]!.slice(0, 200)}`);
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
await adapter.run(
|
await adapter.run(
|
||||||
`INSERT INTO schema_migrations (schema_name, version) VALUES ('public', ?)`,
|
`INSERT INTO schema_migrations (schema_name, version) VALUES ('public', ?)`,
|
||||||
[i + 1],
|
[i + 1],
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue