fix(api): survive existing-schema boots without DB shell
Nginx 502 Host-not-found meant the API never stayed listening. Stamp all migrations when tracking is empty but a late table exists, apply DDL statement-by-statement skipping already-exists, harden remaining CREATE TYPE/TABLE files, and never let seed crash the process. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -52,11 +52,18 @@ export async function prepareDatabase(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
const seeded = await runOnce(prisma, 'seed:initial', async () => {
|
||||
const { stdout } = await execFileAsync(process.execPath, [seedScript]);
|
||||
if (stdout.trim()) logger.log(stdout.trim());
|
||||
});
|
||||
if (seeded) logger.log('Seed data inserted');
|
||||
try {
|
||||
const seeded = await runOnce(prisma, 'seed:initial', async () => {
|
||||
const { stdout } = await execFileAsync(process.execPath, [seedScript]);
|
||||
if (stdout.trim()) logger.log(stdout.trim());
|
||||
});
|
||||
if (seeded) logger.log('Seed data inserted');
|
||||
} catch (err) {
|
||||
// Seed must never crash-loop the API (nginx Host not found / 502).
|
||||
logger.warn(
|
||||
`Seed skipped after error: ${err instanceof Error ? err.message : String(err)}`,
|
||||
);
|
||||
}
|
||||
} finally {
|
||||
await prisma.$disconnect();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user