feat: refactor migration handling to ensure server waits for database migrations before starting
This commit is contained in:
@@ -10,6 +10,7 @@ import fastifyStatic from "@fastify/static";
|
||||
import { resolve } from "path";
|
||||
import { existsSync, mkdirSync } from "fs";
|
||||
import { env } from "./plugins/env.js";
|
||||
import { migrationsReady } from "./db/client.js";
|
||||
import { healthRoutes } from "./routes/health.js";
|
||||
import { authRoutes } from "./routes/auth.js";
|
||||
import { medicationRoutes } from "./routes/medications.js";
|
||||
@@ -17,6 +18,10 @@ import { settingsRoutes } from "./routes/settings.js";
|
||||
import { plannerRoutes } from "./routes/planner.js";
|
||||
import { startReminderScheduler } from "./services/reminder-scheduler.js";
|
||||
|
||||
// Wait for database migrations before anything else
|
||||
await migrationsReady;
|
||||
console.log("[DB] Migrations complete, starting server...");
|
||||
|
||||
// Ensure images directory exists
|
||||
const imagesDir = resolve(process.cwd(), "data/images");
|
||||
if (!existsSync(imagesDir)) {
|
||||
|
||||
Reference in New Issue
Block a user