From e104bfbaf369b1c8fd8a6a5a12984e36951b47f2 Mon Sep 17 00:00:00 2001 From: Rory& Date: Thu, 11 Jun 2026 22:50:56 +0200 Subject: [PATCH] Fix recursive import in database --- assets/openapi.json | Bin 971939 -> 971939 bytes assets/schemas.json | Bin 439351 -> 439351 bytes src/database/Database.ts | 10 ++++------ 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/assets/openapi.json b/assets/openapi.json index 26c330a54ce5b06fb97b67dc18d2a3e42b6c4271..7d506babeddca247bc426ad7c143e6b1c6d038ff 100644 GIT binary patch delta 222 zcmZ3y(t7bq>xM0iKVEJB#m~YdINd>wk-h!@D@Gt@+W!9)Gavut3twZVCv-3>O*dG> zs5-qtn?-!`1AmUm4jl5+xwkPcoSu~h5t)AOJeveaYI=bul<^NHlAz88*0p(KlrQ5H zHsk3Hh0Jl2R)$Ys`-#PD@&_K>$rl7Uwx9jStSdPEzyd~|>3fw~c&3Z(XA+%Uz~TxM0iKVD6DP-A4Dp6Ltrl$%^2DA9ggkp+lZftU@5 b*@2h?h&h3n3y8Uam(wwCOxN*Z;h&bp{CE0= z(<~m-H*92NnS7wPe0qZ#v%qv4PZrL}8-g9De^|uGG5JDB#58UuuI(psm~Hr`_f23H pnttAok$w6yTPEk}AF5alrtkG*lxVl>Vg_OsAZFce*Twcz69A_SNHPEb delta 168 zcmdn~LTdX9sfI0#bC*qS=wNNP*vh!wVk?u-q3H)sF-lFJ;LRvI{oXPrz3KG^%pTMK zUSJiN-fzInIsJb%qr~*wKvw?g8}ykurpsQ0N$A%w>QCoc&Llor$>-~Ifh8=alN%O# zOb. */ -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;