From e104bfbaf369b1c8fd8a6a5a12984e36951b47f2 Mon Sep 17 00:00:00 2001 From: Rory& Date: Thu, 11 Jun 2026 22:50:56 +0200 Subject: Fix recursive import in database --- src/database/Database.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/database/Database.ts') diff --git a/src/database/Database.ts b/src/database/Database.ts index a1d394786..3fabc1795 100644 --- a/src/database/Database.ts +++ b/src/database/Database.ts @@ -16,13 +16,10 @@ along with this program. If not, see . */ -import { config } from "dotenv"; import path from "node:path"; +import fs from "node:fs"; import { green, red, yellow } from "picocolors"; import { DataSource } from "typeorm"; -// noinspection ES6PreferShortImport -import { ConfigEntity } from "@spacebar/database/entities/Config"; -import fs from "node:fs"; import { ProcessLifecycle } from "../util/util/ProcessLifecycle"; // UUID extension option is only supported with postgres @@ -34,7 +31,7 @@ let isHeadlessProcess = false; // For typeorm cli if (!process.env) { isHeadlessProcess = true; - config({ quiet: true }); + require("dotenv").config({ quiet: true }); } if (process.argv[1]?.endsWith("scripts/openapi.js")) isHeadlessProcess = true; @@ -100,7 +97,8 @@ export async function initDatabase(): Promise { // Crude way of detecting if the migrations table exists. const dbExists = async () => { try { - await ConfigEntity.count(); + // do not globally import to avoid circular references + await require("./entities/Config").ConfigEntity.count(); return true; } catch (e) { return false; -- cgit 1.5.1