Fix schemas...

This commit is contained in:
Rory&
2025-12-27 13:08:44 +01:00
parent 0709744e1f
commit e784959bcc
4 changed files with 74 additions and 66 deletions
+42 -42
View File
@@ -50,50 +50,50 @@
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"NIXITCH_NIXPKGS_CONFIG": "/etc/nix/nixpkgs-config.nix",
"NIXITCH_NIX_CONF_DIR": "",
"NIXITCH_NIX_OTHER_STORES": "",
"NIXITCH_NIX_PATH": "/home/Rory/.nix-defexpr/channels:nixpkgs=/nix/store/wb6agba4kfsxpbnb5hzlq58vkjzvbsk6-source",
"NIXITCH_NIX_PROFILES": "/run/current-system/sw /nix/var/nix/profiles/default /etc/profiles/per-user/Rory /home/Rory/.local/state/nix/profile /nix/profile /home/Rory/.nix-profile",
"NIXITCH_NIX_REMOTE": "",
"NIXITCH_NIX_USER_PROFILE_DIR": "/nix/var/nix/profiles/per-user/Rory",
"Node.js.Server.ts.executor": "Debug",
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.git.unshallow": "true",
"git-widget-placeholder": "master",
"javascript.nodejs.core.library.configured.version": "24.11.1",
"javascript.nodejs.core.library.typings.version": "24.10.4",
"last_opened_file_path": "/home/Rory/git/spacebar/server-master/src/util/migration/postgres",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.standard": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.standard": "",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_interpreter_path": "node",
"nodejs_package_manager_path": "npm",
"npm.Start API.executor": "Run",
"npm.Start CDN.executor": "Run",
"npm.Start Gateway.executor": "Run",
"npm.build.executor": "Run",
"npm.build:src.executor": "Run",
"npm.start.executor": "Debug",
"prettierjs.PrettierConfiguration.Package": "/home/Rory/git/spacebar/server-master/node_modules/prettier",
"settings.editor.selected.configurable": "com.github.copilot.settings.customInstructions.CopilotInstructionsConfigurable",
"ts.external.directory.path": "/home/Rory/git/spacebar/server-master/node_modules/typescript/lib"
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;NIXITCH_NIXPKGS_CONFIG&quot;: &quot;/etc/nix/nixpkgs-config.nix&quot;,
&quot;NIXITCH_NIX_CONF_DIR&quot;: &quot;&quot;,
&quot;NIXITCH_NIX_OTHER_STORES&quot;: &quot;&quot;,
&quot;NIXITCH_NIX_PATH&quot;: &quot;/home/Rory/.nix-defexpr/channels:nixpkgs=/nix/store/wb6agba4kfsxpbnb5hzlq58vkjzvbsk6-source&quot;,
&quot;NIXITCH_NIX_PROFILES&quot;: &quot;/run/current-system/sw /nix/var/nix/profiles/default /etc/profiles/per-user/Rory /home/Rory/.local/state/nix/profile /nix/profile /home/Rory/.nix-profile&quot;,
&quot;NIXITCH_NIX_REMOTE&quot;: &quot;&quot;,
&quot;NIXITCH_NIX_USER_PROFILE_DIR&quot;: &quot;/nix/var/nix/profiles/per-user/Rory&quot;,
&quot;Node.js.Server.ts.executor&quot;: &quot;Debug&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;master&quot;,
&quot;javascript.nodejs.core.library.configured.version&quot;: &quot;24.11.1&quot;,
&quot;javascript.nodejs.core.library.typings.version&quot;: &quot;24.10.4&quot;,
&quot;last_opened_file_path&quot;: &quot;/home/Rory/git/spacebar/server-master/src/util/migration/postgres&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.standard&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.standard&quot;: &quot;&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_interpreter_path&quot;: &quot;node&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;npm.Start API.executor&quot;: &quot;Run&quot;,
&quot;npm.Start CDN.executor&quot;: &quot;Run&quot;,
&quot;npm.Start Gateway.executor&quot;: &quot;Run&quot;,
&quot;npm.build.executor&quot;: &quot;Run&quot;,
&quot;npm.build:src.executor&quot;: &quot;Run&quot;,
&quot;npm.start.executor&quot;: &quot;Debug&quot;,
&quot;prettierjs.PrettierConfiguration.Package&quot;: &quot;/home/Rory/git/spacebar/server-master/node_modules/prettier&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;com.github.copilot.settings.customInstructions.CopilotInstructionsConfigurable&quot;,
&quot;ts.external.directory.path&quot;: &quot;/home/Rory/git/spacebar/server-master/node_modules/typescript/lib&quot;
},
"keyToStringList": {
"DatabaseDriversLRU": [
"postgresql"
&quot;keyToStringList&quot;: {
&quot;DatabaseDriversLRU&quot;: [
&quot;postgresql&quot;
],
"GitStage.ChangesTree.GroupingKeys": [
"directory",
"module",
"repository"
&quot;GitStage.ChangesTree.GroupingKeys&quot;: [
&quot;directory&quot;,
&quot;module&quot;,
&quot;repository&quot;
]
}
}]]></component>
}</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/src/util/migration/postgres" />
@@ -125,8 +125,6 @@
<entry key="Start CDN" value="STOPPED" />
<entry key="Start Gateway" value="STOPPED" />
<entry key="Start bundle" value="STOPPED" />
<entry key="build" value="STOPPED" />
<entry key="build:src" value="STOPPED" />
</map>
</value>
</entry>
@@ -177,6 +175,8 @@
<workItem from="1765142585081" duration="16912000" />
<workItem from="1765849511651" duration="7921000" />
<workItem from="1765861713706" duration="18045000" />
<workItem from="1766715967914" duration="40995000" />
<workItem from="1766823293461" duration="11580000" />
</task>
<servers />
</component>
Binary file not shown.
Binary file not shown.
+32 -24
View File
@@ -29,43 +29,51 @@ import fs from "fs";
export let dbConnection: DataSource | undefined;
let isHeadlessProcess = false;
// For typeorm cli
if (!process.env) {
isHeadlessProcess = true;
config({ quiet: true });
}
if (process.argv[1]?.endsWith("scripts/openapi.js")) isHeadlessProcess = true;
const dbConnectionString = process.env.DATABASE || path.join(process.cwd(), "database.db");
export const DatabaseType = dbConnectionString.includes("://") ? dbConnectionString.split(":")[0]?.replace("+srv", "") : "sqlite";
const isSqlite = DatabaseType.includes("sqlite");
let hasWarnedSqlite = false;
if (isSqlite && !hasWarnedSqlite) {
hasWarnedSqlite = true;
console.log(`[Database] ${red(`You are running sqlite! Please keep in mind that we recommend setting up a dedicated database!`)}`);
try {
const _ = require("sqlite3");
} catch (e) {
console.log(`[Database] ${red(`Failed to load sqlite3 package. Please install it with 'npm install --no-save sqlite3', or switch to a real database like Postgres.`)}`);
process.exit(1);
// For openapi.js...
if (!isHeadlessProcess) {
let hasWarnedSqlite = false;
if (isSqlite && !hasWarnedSqlite) {
hasWarnedSqlite = true;
console.log(`[Database] ${red(`You are running sqlite! Please keep in mind that we recommend setting up a dedicated database!`)}`);
try {
const _ = require("sqlite3");
} catch (e) {
console.log(`[Database] ${red(`Failed to load sqlite3 package. Please install it with 'npm install --no-save sqlite3', or switch to a real database like Postgres.`)}`);
process.exit(1);
}
}
}
export const DataSourceOptions = new DataSource({
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore type 'string' is not 'sqlite' | 'postgres' | etc etc
type: DatabaseType,
charset: "utf8mb4",
url: isSqlite ? undefined : dbConnectionString,
database: isSqlite ? dbConnectionString : undefined,
entities: [path.join(__dirname, "..", "entities", "*.js")],
synchronize: !!process.env.DB_SYNC,
logging: !!process.env.DB_LOGGING,
bigNumberStrings: false,
supportBigNumbers: true,
name: "default",
migrations: [path.join(__dirname, "..", "migration", DatabaseType, "*.js")],
});
export const DataSourceOptions = isHeadlessProcess
? (undefined as unknown as DataSource)
: new DataSource({
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore type 'string' is not 'sqlite' | 'postgres' | etc etc
type: DatabaseType,
charset: "utf8mb4",
url: isSqlite ? undefined : dbConnectionString,
database: isSqlite ? dbConnectionString : undefined,
entities: [path.join(__dirname, "..", "entities", "*.js")],
synchronize: !!process.env.DB_SYNC,
logging: !!process.env.DB_LOGGING,
bigNumberStrings: false,
supportBigNumbers: true,
name: "default",
migrations: [path.join(__dirname, "..", "migration", DatabaseType, "*.js")],
});
// Gets the existing database connection
export function getDatabase(): DataSource | null {