From ba578c87019b0fd6abb154339b6f8ef401680dcc Mon Sep 17 00:00:00 2001 From: Namekuji Date: Fri, 2 Jun 2023 15:01:29 -0400 Subject: [PATCH] initialize native database on boot --- packages/backend/src/db/postgre.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/backend/src/db/postgre.ts b/packages/backend/src/db/postgre.ts index dd202b3def..9ffaf596c8 100644 --- a/packages/backend/src/db/postgre.ts +++ b/packages/backend/src/db/postgre.ts @@ -78,6 +78,7 @@ import { entities as charts } from "@/services/chart/entities.js"; import { envOption } from "../env.js"; import { dbLogger } from "./logger.js"; import { redisClient } from "./redis.js"; +import { nativeInitDatabase } from "native-utils/built/index.js"; const sqlLogger = dbLogger.createSubLogger("sql", "gray", false); @@ -220,6 +221,9 @@ export const db = new DataSource({ }); export async function initDb(force = false) { + await nativeInitDatabase( + `postgres://${config.db.user}:${config.db.pass}@${config.db.host}:${config.db.port}/${config.db.db}`, + ); if (force) { if (db.isInitialized) { await db.destroy();