Apply pending migrations during development reloads
This commit is contained in:
@@ -6,6 +6,13 @@ import { createApi } from "./api";
|
||||
import { readAuthConfig } from "./auth/config";
|
||||
import { readDiscordSharingConfig } from "./sharing/config";
|
||||
import index from "./index.html";
|
||||
import { migrate } from "drizzle-orm/bun-sqlite/migrator";
|
||||
|
||||
// Hot reloads skip the package script's migration step. Apply pending changes
|
||||
// before the reloaded development server accepts requests.
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
migrate(db, { migrationsFolder: "./drizzle" });
|
||||
}
|
||||
|
||||
const backups = process.env.NODE_ENV === "production" ? startBackups(sqlite, backupConfig(databasePath)) : undefined;
|
||||
if (import.meta.hot) import.meta.hot.dispose(() => backups?.stop());
|
||||
|
||||
Reference in New Issue
Block a user