refactor: only set pragma on server start
Some checks failed
Release Workflow / determine-release-type (push) Has been cancelled
Release Workflow / checks (push) Has been cancelled
Release Workflow / e2e-tests (push) Has been cancelled
Release Workflow / build-images (push) Has been cancelled
Release Workflow / publish-release (push) Has been cancelled
Some checks failed
Release Workflow / determine-release-type (push) Has been cancelled
Release Workflow / checks (push) Has been cancelled
Release Workflow / e2e-tests (push) Has been cancelled
Release Workflow / build-images (push) Has been cancelled
Release Workflow / publish-release (push) Has been cancelled
This commit is contained in:
parent
bf82bbf48a
commit
6733151bca
2 changed files with 5 additions and 6 deletions
|
|
@ -3,9 +3,9 @@ import { shutdown } from "./server/modules/lifecycle/shutdown";
|
|||
import { runCLI } from "./server/cli";
|
||||
import { createStartHandler, defaultStreamHandler, defineHandlerCallback } from "@tanstack/react-start/server";
|
||||
import { createServerEntry } from "@tanstack/react-start/server-entry";
|
||||
import { runDbMigrations } from "./server/db/db";
|
||||
import { sqlite } from "./server/db/db";
|
||||
|
||||
await runDbMigrations();
|
||||
sqlite.run("PRAGMA foreign_keys = ON;");
|
||||
|
||||
const cliRun = await runCLI(Bun.argv);
|
||||
if (cliRun) {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ if (fs.existsSync(path.join(path.dirname(DATABASE_URL), "ironmount.db")) && !fs.
|
|||
fs.renameSync(path.join(path.dirname(DATABASE_URL), "ironmount.db"), DATABASE_URL);
|
||||
}
|
||||
|
||||
const sqlite = new Database(DATABASE_URL);
|
||||
export const sqlite = new Database(DATABASE_URL);
|
||||
export const db = drizzle({ client: sqlite, relations, schema });
|
||||
|
||||
let migrationsPromise: Promise<void> | undefined;
|
||||
|
|
@ -36,10 +36,9 @@ const runMigrations = async () => {
|
|||
};
|
||||
|
||||
export const runDbMigrations = () => {
|
||||
if (migrationsPromise) {
|
||||
return migrationsPromise;
|
||||
if (!migrationsPromise) {
|
||||
migrationsPromise = runMigrations();
|
||||
}
|
||||
|
||||
migrationsPromise = runMigrations();
|
||||
return migrationsPromise;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue