diff options
author | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2023-01-05 17:04:15 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-05 17:04:15 +1100 |
commit | e42eaeee8d6310c81de2e90280afe99f8e8674aa (patch) | |
tree | db47e73433d38898b705e3d7e5fddc4e87a27f3d /src/util/util/Datasource.ts | |
parent | Merge pull request #922 from MaddyUnderStars/maddy/bodyParserPatch (diff) | |
download | server-e42eaeee8d6310c81de2e90280afe99f8e8674aa.tar.xz |
Add migrations (#923)
* Fix typeorm migration cli and server migrations. * Add `migrate-from-staging` script
Diffstat (limited to '')
-rw-r--r-- | src/util/util/Datasource.ts | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/src/util/util/Datasource.ts b/src/util/util/Datasource.ts deleted file mode 100644 index 1495faaa..00000000 --- a/src/util/util/Datasource.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { config } from "dotenv" -import path from "path"; -import { DataSource } from "typeorm"; -import { red } from "picocolors"; - -// For typeorm cli -if (!process.env) { - config(); -} - -let dbConnectionString = - process.env.DATABASE || path.join(process.cwd(), "database.db"); - -const type = dbConnectionString.includes("://") - ? dbConnectionString.split(":")[0]?.replace("+srv", "") - : "sqlite"; -const isSqlite = type.includes("sqlite"); - -if (isSqlite) { - console.log( - `[Database] ${red( - `You are running sqlite! Please keep in mind that we recommend setting up a dedicated database!`, - )}`, - ); -} - -const dataSource = new DataSource({ - //@ts-ignore type 'string' is not 'mysql' | 'sqlite' | 'mariadb' | etc etc - type, - charset: "utf8mb4", - url: isSqlite ? undefined : dbConnectionString, - database: isSqlite ? dbConnectionString : undefined, - entities: ["dist/util/entities/*.js"], - synchronize: false, - logging: false, - bigNumberStrings: false, - supportBigNumbers: true, - name: "default", - migrations: ["dist/util/migrations/*.js"], -}); - -export { dataSource as DataSourceOptions, type as DatabaseType }; \ No newline at end of file |