diff --git a/.cspell.json b/.cspell.json index ecaabad6060..eba7db40f5c 100644 --- a/.cspell.json +++ b/.cspell.json @@ -393,7 +393,9 @@ "Desterrro", "Chetan", "chetan", - "Yostorono" + "Yostorono", + "sarif", + "SARIF" ], "useGitignore": true, "ignorePaths": [ diff --git a/.env.docker b/.env.docker index 12cb10ba211..6c4c7bce821 100644 --- a/.env.docker +++ b/.env.docker @@ -30,8 +30,8 @@ CLIENT_BASE_URL=http://localhost:4200 #set to Website Platform PLATFORM_WEBSITE_URL=https://gauzy.co -# DB_TYPE: sqlite | postgres -DB_TYPE=sqlite +# DB_TYPE: sqlite | postgres | better-sqlite3 +DB_TYPE=better-sqlite3 DB_SYNCHRONIZE=false # Below are PostgreSQL Connection Parameters diff --git a/.env.local b/.env.local index ec2482079a2..884af5c44f7 100644 --- a/.env.local +++ b/.env.local @@ -30,8 +30,8 @@ CLIENT_BASE_URL=http://localhost:4200 #set to Website Platform PLATFORM_WEBSITE_URL=https://gauzy.co -# DB_TYPE: sqlite | postgres -DB_TYPE=sqlite +# DB_TYPE: sqlite | postgres | better-sqlite3 +DB_TYPE=better-sqlite3 DB_SYNCHRONIZE=false # Below are PostgreSQL Connection Parameters diff --git a/.env.sample b/.env.sample index 449079d46f0..1f686561b6f 100644 --- a/.env.sample +++ b/.env.sample @@ -15,8 +15,8 @@ CLIENT_BASE_URL=http://localhost:4200 #set to Website Platform PLATFORM_WEBSITE_URL=https://gauzy.co -# DB_TYPE: sqlite | postgres -DB_TYPE=sqlite +# DB_TYPE: sqlite | postgres | better-sqlite3 +DB_TYPE=better-sqlite3 # PostgreSQL Connection Parameters # DB_HOST=localhost diff --git a/apps/api/src/plugin-config.ts b/apps/api/src/plugin-config.ts index d64b7f8cb35..e8e41d6c54b 100644 --- a/apps/api/src/plugin-config.ts +++ b/apps/api/src/plugin-config.ts @@ -129,5 +129,26 @@ function getDbConfig(): DataSourceOptions { logger: 'file', // Removes console logging, instead logs all queries in a file ormlogs.log synchronize: process.env.DB_SYNCHRONIZE === 'true' ? true : false, // We are using migrations, synchronize should be set to false. }; + case 'better-sqlite3': + const betterSqlitePath = + process.env.DB_PATH || + path.join( + path.resolve('.', ...['apps', 'api', 'data']), + 'gauzy.sqlite3' + ); + + return { + type: dbType, + database: betterSqlitePath, + logging: 'all', + logger: 'file', // Removes console logging, instead logs all queries in a file ormlogs.log + synchronize: process.env.DB_SYNCHRONIZE === 'true', // We are using migrations, synchronize should be set to false. + prepareDatabase: (db) => { + if (!process.env.IS_ELECTRON) { + // Enhance performance + db.pragma('journal_mode = WAL'); + } + } + }; } } diff --git a/apps/desktop-timer/src/index.ts b/apps/desktop-timer/src/index.ts index 531a200cb64..f8e20fffb69 100644 --- a/apps/desktop-timer/src/index.ts +++ b/apps/desktop-timer/src/index.ts @@ -392,7 +392,7 @@ app.on('ready', async () => { if (!settings) { launchAtStartup(true, false); } - if (provider.dialect === 'sqlite') { + if (['sqlite', 'better-sqlite'].includes(provider.dialect)) { try { const res = await knex.raw(`pragma journal_mode = WAL;`); console.log(res); @@ -600,46 +600,13 @@ ipcMain.on('restart_and_update', () => { ipcMain.on('check_database_connection', async (event, arg) => { try { - const provider = arg.db; - let databaseOptions; - if (provider === 'postgres' || provider === 'mysql') { - databaseOptions = { - client: provider === 'postgres' ? 'pg' : 'mysql', - connection: { - host: arg[provider].dbHost, - user: arg[provider].dbUsername, - password: arg[provider].dbPassword, - database: arg[provider].dbName, - port: arg[provider].dbPort, - }, - }; - } else { - databaseOptions = { - client: 'sqlite3', - connection: { - filename: sqlite3filename, - }, - }; - } - const dbConn = require('knex')(databaseOptions); - await dbConn.raw('select 1+1 as result'); + const driver = await provider.check(arg); event.sender.send('database_status', { status: true, - message: - provider === 'postgres' - ? TranslateService.instant( - 'TIMER_TRACKER.DIALOG.CONNECTION_DRIVER', - { driver: 'PostgresSQL' } - ) - : provider === 'mysql' - ? TranslateService.instant( - 'TIMER_TRACKER.DIALOG.CONNECTION_DRIVER', - { driver: 'MySQL' } - ) - : TranslateService.instant( - 'TIMER_TRACKER.DIALOG.CONNECTION_DRIVER', - { driver: 'SQLite' } - ), + message: TranslateService.instant( + 'TIMER_TRACKER.DIALOG.CONNECTION_DRIVER', + { driver } + ), }); } catch (error) { event.sender.send('database_status', { diff --git a/apps/desktop/src/index.ts b/apps/desktop/src/index.ts index 924616e924a..47161e5ebed 100644 --- a/apps/desktop/src/index.ts +++ b/apps/desktop/src/index.ts @@ -233,7 +233,10 @@ async function startServer(value, restart = false) { if (value.db === 'sqlite') { process.env.DB_PATH = sqlite3filename; process.env.DB_TYPE = 'sqlite'; - } else { + }else if(value.db === 'better-sqlite') { + process.env.DB_PATH = sqlite3filename; + process.env.DB_TYPE = 'better-sqlite3'; + }else { process.env.DB_TYPE = 'postgres'; process.env.DB_HOST = value['postgres']?.dbHost; process.env.DB_PORT = value['postgres']?.dbPort; @@ -462,7 +465,7 @@ app.on('ready', async () => { splashScreen = new SplashScreen(pathWindow.timeTrackerUi); await splashScreen.loadURL(); splashScreen.show(); - if (provider.dialect === 'sqlite') { + if (['sqlite', 'better-sqlite'].includes(provider.dialect)) { try { const res = await knex.raw(`pragma journal_mode = WAL;`) console.log(res); @@ -698,34 +701,12 @@ ipcMain.on('restart_and_update', () => { ipcMain.on('check_database_connection', async (event, arg) => { try { - const provider = arg.db; - let databaseOptions; - if (provider === 'postgres') { - databaseOptions = { - client: 'pg', - connection: { - host: arg[provider].dbHost, - user: arg[provider].dbUsername, - password: arg[provider].dbPassword, - database: arg[provider].dbName, - port: arg[provider].dbPort - } - }; - } else { - databaseOptions = { - client: 'sqlite', - connection: { - filename: sqlite3filename, - }, - }; - } - const dbConn = require('knex')(databaseOptions); - await dbConn.raw('select 1+1 as result'); + const driver = await provider.check(arg); event.sender.send('database_status', { status: true, message: TranslateService.instant( 'TIMER_TRACKER.DIALOG.CONNECTION_DRIVER', - { driver: provider === 'postgres' ? 'PostgresSQL' : 'SQLite' } + { driver } ) }); } catch (error) { diff --git a/apps/server/src/index.ts b/apps/server/src/index.ts index c71585de1d5..596e3b573d7 100644 --- a/apps/server/src/index.ts +++ b/apps/server/src/index.ts @@ -286,7 +286,8 @@ const getEnvApi = () => { const config = serverConfig.setting; serverConfig.update(); const addsConfig = LocalStore.getAdditionalConfig(); - const provider = config.db; + const provider = + config.db === 'better-sqlite' ? 'better-sqlite3' : config.db; return { IS_ELECTRON: 'true', DB_PATH: sqlite3filename, diff --git a/packages/config/src/database.ts b/packages/config/src/database.ts index fe70da8a208..0dfc86267df 100644 --- a/packages/config/src/database.ts +++ b/packages/config/src/database.ts @@ -81,6 +81,35 @@ switch (dbType) { connectionConfig = sqliteConfig; + break; + + case 'better-sqlite3': + const betterSqlitePath = + process.env.DB_PATH || + path.join( + process.cwd(), + ...['apps', 'api', 'data'], + 'gauzy.sqlite3' + ); + + console.log('Better Sqlite DB Path: ' + betterSqlitePath); + + const betterSqliteConfig: DataSourceOptions = { + type: dbType, + database: betterSqlitePath, + logging: 'all', + logger: 'file', // Removes console logging, instead logs all queries in a file ormlogs.log + synchronize: process.env.DB_SYNCHRONIZE === 'true', // We are using migrations, synchronize should be set to false. + prepareDatabase: (db) => { + if (!process.env.IS_ELECTRON) { + // Enhance performance + db.pragma('journal_mode = WAL'); + } + } + }; + + connectionConfig = betterSqliteConfig; + break; } diff --git a/packages/core/package.json b/packages/core/package.json index e9d8fd13b2f..7c0f1f3bc5a 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -46,10 +46,10 @@ "@gauzy/config": "^0.1.0", "@gauzy/contracts": "^0.1.0", "@gauzy/integration-ai": "^0.1.0", - "@gauzy/integration-hubstaff": "^0.1.0", - "@gauzy/integration-upwork": "^0.1.0", "@gauzy/integration-github": "^0.1.0", + "@gauzy/integration-hubstaff": "^0.1.0", "@gauzy/integration-jira": "^0.1.0", + "@gauzy/integration-upwork": "^0.1.0", "@gauzy/plugin": "^0.1.0", "@godaddy/terminus": "^4.5.0", "@grpc/grpc-js": "^1.6.7", @@ -86,6 +86,7 @@ "aws-sdk": "^2.1082.0", "axios": "^1.5.0", "bcrypt": "^5.1.0", + "better-sqlite3": "^8.7.0", "cache-manager": "^3.4.0", "camelcase": "^6.2.1", "chalk": "4.1.2", diff --git a/packages/core/src/availability-slots/commands/handlers/get-conflict-availability-slots.handler.ts b/packages/core/src/availability-slots/commands/handlers/get-conflict-availability-slots.handler.ts index cb1abbcec6b..8ba1f410282 100644 --- a/packages/core/src/availability-slots/commands/handlers/get-conflict-availability-slots.handler.ts +++ b/packages/core/src/availability-slots/commands/handlers/get-conflict-availability-slots.handler.ts @@ -21,7 +21,7 @@ export class GetConflictAvailabilitySlotsHandler public async execute( command: GetConflictAvailabilitySlotsCommand ): Promise { - + const { input } = command; const { startTime, endTime, employeeId, organizationId } = input; const tenantId = RequestContext.currentTenantId() || input.tenantId; @@ -38,7 +38,7 @@ export class GetConflictAvailabilitySlotsHandler }); query.andWhere( - this.configService.dbConnectionOptions.type === 'sqlite' + ['sqlite', 'better-sqlite3'].includes(this.configService.dbConnectionOptions.type) ? `'${startedAt}' >= "${query.alias}"."startTime" AND '${startedAt}' <= "${query.alias}"."endTime"` : `("${query.alias}"."startTime", "${query.alias}"."endTime") OVERLAPS (timestamptz '${startedAt}', timestamptz '${stoppedAt}')` ); @@ -52,7 +52,7 @@ export class GetConflictAvailabilitySlotsHandler if (input.type) { query.andWhere(`${query.alias}.type = :type`, { - type: input.type + type: input.type }); } diff --git a/packages/core/src/core/utils.ts b/packages/core/src/core/utils.ts index d6b61cf4482..64e110d8c81 100644 --- a/packages/core/src/core/utils.ts +++ b/packages/core/src/core/utils.ts @@ -78,7 +78,8 @@ export function unixTimestampToDate( export function convertToDatetime(datetime) { if (moment(new Date(datetime)).isValid()) { const dbType = getConfig().dbConnectionOptions.type || 'sqlite'; - if (dbType === 'sqlite') { + const allowedDbTypes = ['sqlite', 'better-sqlite3']; + if (allowedDbTypes.includes(dbType)) { return moment(new Date(datetime)).format('YYYY-MM-DD HH:mm:ss'); } else { return moment(new Date(datetime)).toDate(); @@ -132,7 +133,7 @@ export function getDateRange( } const dbType = getConfig().dbConnectionOptions.type || 'sqlite'; - if (dbType === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(dbType)) { start = start.format('YYYY-MM-DD HH:mm:ss'); end = end.format('YYYY-MM-DD HH:mm:ss'); } else { @@ -224,7 +225,8 @@ export function getDateRangeFormat( } const dbType = getConfig().dbConnectionOptions.type || 'sqlite'; - if (dbType === 'sqlite') { + const allowedDbTypes = ['sqlite', 'better-sqlite3']; + if (allowedDbTypes.includes(dbType)) { return { start: start.format('YYYY-MM-DD HH:mm:ss'), end: end.format('YYYY-MM-DD HH:mm:ss'), diff --git a/packages/core/src/database/migration-executor.ts b/packages/core/src/database/migration-executor.ts index 2912d1ab148..974eb17808d 100644 --- a/packages/core/src/database/migration-executor.ts +++ b/packages/core/src/database/migration-executor.ts @@ -275,7 +275,7 @@ export class ${camelCase(name, true)}${timestamp} implements MigrationInterface * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -288,7 +288,7 @@ export class ${camelCase(name, true)}${timestamp} implements MigrationInterface * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); @@ -318,23 +318,23 @@ export class ${camelCase(name, true)}${timestamp} implements MigrationInterface } /** - * SqliteDB Up Migration + * SqliteDB and BetterSQlite3DB Up Migration * * @param queryRunner */ public async sqliteUpQueryRunner(queryRunner: QueryRunner): Promise { - ${(connection.options.type === 'sqlite') ? upSqls.join(` + ${(['sqlite', 'better-sqlite3'].includes(connection.options.type)) ? upSqls.join(` `) : [].join(` `)} } /** - * SqliteDB Down Migration + * SqliteDB and BetterSQlite3DB Down Migration * * @param queryRunner */ public async sqliteDownQueryRunner(queryRunner: QueryRunner): Promise { - ${(connection.options.type === 'sqlite') ? downSqls.join(` + ${(['sqlite', 'better-sqlite3'].includes(connection.options.type)) ? downSqls.join(` `) : [].join(` `)} } diff --git a/packages/core/src/database/migrations/1638541848595-SwitchToMigration.ts b/packages/core/src/database/migrations/1638541848595-SwitchToMigration.ts index 1f7e5681f96..a4903e4cfa5 100644 --- a/packages/core/src/database/migrations/1638541848595-SwitchToMigration.ts +++ b/packages/core/src/database/migrations/1638541848595-SwitchToMigration.ts @@ -4,7 +4,7 @@ export class SwitchToMigration1638541848595 implements MigrationInterface { name = 'SwitchToMigration1638541848595' public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -12,7 +12,7 @@ export class SwitchToMigration1638541848595 implements MigrationInterface { } public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); @@ -21,8 +21,8 @@ export class SwitchToMigration1638541848595 implements MigrationInterface { /** * PostgresDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ private async postgresUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`CREATE EXTENSION IF NOT EXISTS "uuid-ossp"`); @@ -942,11 +942,11 @@ export class SwitchToMigration1638541848595 implements MigrationInterface { await queryRunner.query(`ALTER TABLE IF EXISTS "employee" DROP CONSTRAINT IF EXISTS "FK_1c0c1370ecd98040259625e17e2"`); await queryRunner.query(`ALTER TABLE "employee" ADD CONSTRAINT "FK_1c0c1370ecd98040259625e17e2" FOREIGN KEY ("contactId") REFERENCES "contact"("id") ON DELETE SET NULL ON UPDATE NO ACTION`); await queryRunner.query(`ALTER TABLE IF EXISTS "employee" DROP CONSTRAINT IF EXISTS "FK_5e719204dcafa8d6b2ecdeda130"`); - await queryRunner.query(`ALTER TABLE "employee" ADD CONSTRAINT "FK_5e719204dcafa8d6b2ecdeda130" FOREIGN KEY ("organizationPositionId") REFERENCES "organization_position"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "employee" ADD CONSTRAINT "FK_5e719204dcafa8d6b2ecdeda130" FOREIGN KEY ("organizationPositionId") REFERENCES "organization_position"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); await queryRunner.query(`ALTER TABLE IF EXISTS "equipment_sharing_policy" DROP CONSTRAINT IF EXISTS "FK_5443ca8ed830626656d8cfecef7"`); await queryRunner.query(`ALTER TABLE "equipment_sharing_policy" ADD CONSTRAINT "FK_5443ca8ed830626656d8cfecef7" FOREIGN KEY ("tenantId") REFERENCES "tenant"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); await queryRunner.query(`ALTER TABLE IF EXISTS "equipment_sharing_policy" DROP CONSTRAINT IF EXISTS "FK_5311a833ff255881454bd5b3b58"`); - await queryRunner.query(`ALTER TABLE "equipment_sharing_policy" ADD CONSTRAINT "FK_5311a833ff255881454bd5b3b58" FOREIGN KEY ("organizationId") REFERENCES "organization"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "equipment_sharing_policy" ADD CONSTRAINT "FK_5311a833ff255881454bd5b3b58" FOREIGN KEY ("organizationId") REFERENCES "organization"("id") ON DELETE CASCADE ON UPDATE CASCADE`); await queryRunner.query(`ALTER TABLE IF EXISTS "equipment_sharing" DROP CONSTRAINT IF EXISTS "FK_fa525e61fb3d8d9efec0f364a4b"`); await queryRunner.query(`ALTER TABLE "equipment_sharing" ADD CONSTRAINT "FK_fa525e61fb3d8d9efec0f364a4b" FOREIGN KEY ("tenantId") REFERENCES "tenant"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); await queryRunner.query(`ALTER TABLE IF EXISTS "equipment_sharing" DROP CONSTRAINT IF EXISTS "FK_ea9254be07ae4a8604f0aaab196"`); @@ -1482,7 +1482,7 @@ export class SwitchToMigration1638541848595 implements MigrationInterface { await queryRunner.query(`ALTER TABLE IF EXISTS "warehouse" DROP CONSTRAINT IF EXISTS "FK_f502dc6d9802306f9d1584932b8"`); await queryRunner.query(`ALTER TABLE IF EXISTS "warehouse" ADD CONSTRAINT "FK_f502dc6d9802306f9d1584932b8" FOREIGN KEY ("logoId") REFERENCES "image_asset"("id") ON DELETE SET NULL ON UPDATE NO ACTION`); await queryRunner.query(`ALTER TABLE IF EXISTS "warehouse" DROP CONSTRAINT IF EXISTS "FK_84594016a98da8b87e0f51cd931"`); - await queryRunner.query(`ALTER TABLE IF EXISTS "warehouse" ADD CONSTRAINT "FK_84594016a98da8b87e0f51cd931" FOREIGN KEY ("contactId") REFERENCES "contact"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE IF EXISTS "warehouse" ADD CONSTRAINT "FK_84594016a98da8b87e0f51cd931" FOREIGN KEY ("contactId") REFERENCES "contact"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); await queryRunner.query(`ALTER TABLE IF EXISTS "warehouse_product_variant" DROP CONSTRAINT IF EXISTS "FK_a1c4a97b928b547c3041d3ac1f6"`); await queryRunner.query(`ALTER TABLE IF EXISTS "warehouse_product_variant" ADD CONSTRAINT "FK_a1c4a97b928b547c3041d3ac1f6" FOREIGN KEY ("tenantId") REFERENCES "tenant"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); await queryRunner.query(`ALTER TABLE IF EXISTS "warehouse_product_variant" DROP CONSTRAINT IF EXISTS "FK_a2f863689d1316810c41c1ea38e"`); @@ -1705,8 +1705,8 @@ export class SwitchToMigration1638541848595 implements MigrationInterface { /** * PostgresDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ private async postgresDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "tag_warehouse" DROP CONSTRAINT "FK_3557d514afd3794d40128e05423"`); @@ -2905,8 +2905,8 @@ export class SwitchToMigration1638541848595 implements MigrationInterface { /** * SqliteDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ private async sqliteUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`CREATE TABLE IF NOT EXISTS "appointment_employee" ("id" varchar PRIMARY KEY NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "tenantId" varchar, "organizationId" varchar, "appointmentId" varchar NOT NULL, "employeeId" varchar NOT NULL, "employeeAppointmentId" varchar)`); @@ -5360,8 +5360,8 @@ export class SwitchToMigration1638541848595 implements MigrationInterface { /** * SqliteDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ private async sqliteDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_3557d514afd3794d40128e0542"`); diff --git a/packages/core/src/database/migrations/1638793919144-KnowledgeBasePlugin.ts b/packages/core/src/database/migrations/1638793919144-KnowledgeBasePlugin.ts index 462ca1f5c8b..832fd85fca5 100644 --- a/packages/core/src/database/migrations/1638793919144-KnowledgeBasePlugin.ts +++ b/packages/core/src/database/migrations/1638793919144-KnowledgeBasePlugin.ts @@ -1,10 +1,10 @@ import { MigrationInterface, QueryRunner } from "typeorm"; - + export class KnowledgeBasePlugin1638793919144 implements MigrationInterface { name = 'KnowledgeBasePlugin1638793919144'; public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -12,7 +12,7 @@ export class KnowledgeBasePlugin1638793919144 implements MigrationInterface { } public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); @@ -21,8 +21,8 @@ export class KnowledgeBasePlugin1638793919144 implements MigrationInterface { /** * PostgresDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`CREATE TABLE "knowledge_base" ("id" uuid NOT NULL DEFAULT gen_random_uuid(), "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), "tenantId" uuid, "organizationId" uuid, "name" character varying NOT NULL, "flag" character varying NOT NULL, "icon" character varying NOT NULL, "privacy" character varying NOT NULL, "language" character varying NOT NULL, "color" character varying NOT NULL, "description" character varying, "data" character varying, "index" integer, "parentId" uuid, CONSTRAINT "PK_19d3f52f6da1501b7e235f1da5c" PRIMARY KEY ("id"))`); @@ -51,11 +51,11 @@ export class KnowledgeBasePlugin1638793919144 implements MigrationInterface { await queryRunner.query(`ALTER TABLE "knowledge_base_author" ADD CONSTRAINT "FK_8eb7e413257d7a26104f4e326fd" FOREIGN KEY ("employeeId") REFERENCES "employee"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); await queryRunner.query(`ALTER TABLE "knowledge_base_author" ADD CONSTRAINT "FK_2d5ecab1f06b327bad545536143" FOREIGN KEY ("articleId") REFERENCES "knowledge_base_article"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); } - + /** * PostgresDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "knowledge_base_author" DROP CONSTRAINT "FK_2d5ecab1f06b327bad545536143"`); @@ -87,8 +87,8 @@ export class KnowledgeBasePlugin1638793919144 implements MigrationInterface { /** * SqliteDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`CREATE TABLE "knowledge_base" ("id" varchar PRIMARY KEY NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "tenantId" varchar, "organizationId" varchar, "name" varchar NOT NULL, "flag" varchar NOT NULL, "icon" varchar NOT NULL, "privacy" varchar NOT NULL, "language" varchar NOT NULL, "color" varchar NOT NULL, "description" varchar, "data" varchar, "index" integer, "parentId" varchar)`); @@ -145,11 +145,11 @@ export class KnowledgeBasePlugin1638793919144 implements MigrationInterface { await queryRunner.query(`CREATE INDEX "IDX_8eb7e413257d7a26104f4e326f" ON "knowledge_base_author" ("employeeId") `); await queryRunner.query(`CREATE INDEX "IDX_2d5ecab1f06b327bad54553614" ON "knowledge_base_author" ("articleId") `); } - + /** * SqliteDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_2d5ecab1f06b327bad54553614"`); @@ -206,4 +206,4 @@ export class KnowledgeBasePlugin1638793919144 implements MigrationInterface { await queryRunner.query(`DROP INDEX "IDX_bcb30c9893f4c8d0c4e556b4ed"`); await queryRunner.query(`DROP TABLE "knowledge_base"`); } -} \ No newline at end of file +} diff --git a/packages/core/src/database/migrations/1638797573521-ChangelogPlugin.ts b/packages/core/src/database/migrations/1638797573521-ChangelogPlugin.ts index 9260b3ccf32..c44ee25541a 100644 --- a/packages/core/src/database/migrations/1638797573521-ChangelogPlugin.ts +++ b/packages/core/src/database/migrations/1638797573521-ChangelogPlugin.ts @@ -1,11 +1,11 @@ import { MigrationInterface, QueryRunner } from "typeorm"; - + export class ChangelogPlugin1638797573521 implements MigrationInterface { name = 'ChangelogPlugin1638797573521'; public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -13,7 +13,7 @@ export class ChangelogPlugin1638797573521 implements MigrationInterface { } public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); @@ -22,8 +22,8 @@ export class ChangelogPlugin1638797573521 implements MigrationInterface { /** * PostgresDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`CREATE TABLE "changelog" ("id" uuid NOT NULL DEFAULT gen_random_uuid(), "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), "tenantId" uuid, "organizationId" uuid, "icon" character varying, "title" character varying, "date" TIMESTAMP NOT NULL, "content" character varying NOT NULL, "learnMoreUrl" character varying NOT NULL, CONSTRAINT "PK_9d12e70193212a9f6d2c542433d" PRIMARY KEY ("id"))`); @@ -37,8 +37,8 @@ export class ChangelogPlugin1638797573521 implements MigrationInterface { /** * PostgresDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "changelog" DROP CONSTRAINT "FK_c2037b621d2e8023898aee4ac74"`); @@ -52,8 +52,8 @@ export class ChangelogPlugin1638797573521 implements MigrationInterface { /** * SqliteDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`CREATE TABLE "changelog" ("id" varchar PRIMARY KEY NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "tenantId" varchar, "organizationId" varchar, "icon" varchar, "title" varchar, "date" datetime NOT NULL, "content" varchar NOT NULL, "learnMoreUrl" varchar NOT NULL)`); @@ -79,8 +79,8 @@ export class ChangelogPlugin1638797573521 implements MigrationInterface { /** * SqliteDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_c2037b621d2e8023898aee4ac7"`); @@ -103,4 +103,4 @@ export class ChangelogPlugin1638797573521 implements MigrationInterface { await queryRunner.query(`DROP INDEX "IDX_744268ee0ec6073883267bc3b6"`); await queryRunner.query(`DROP TABLE "changelog"`); } -} \ No newline at end of file +} diff --git a/packages/core/src/database/migrations/1639729354753-CreatePasswordResetTable.ts b/packages/core/src/database/migrations/1639729354753-CreatePasswordResetTable.ts index 0036602d5fb..9683c6ac19c 100644 --- a/packages/core/src/database/migrations/1639729354753-CreatePasswordResetTable.ts +++ b/packages/core/src/database/migrations/1639729354753-CreatePasswordResetTable.ts @@ -1,29 +1,29 @@ import { MigrationInterface, QueryRunner } from "typeorm"; - + export class CreatePasswordResetTable1639729354753 implements MigrationInterface { name = 'CreatePasswordResetTable1639729354753'; public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); } } - + public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); } } - + /** * PostgresDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`CREATE TABLE "password_reset" ("id" uuid NOT NULL DEFAULT gen_random_uuid(), "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), "email" character varying NOT NULL, "token" character varying NOT NULL, CONSTRAINT "PK_8515e60a2cc41584fa4784f52ce" PRIMARY KEY ("id"))`); @@ -32,11 +32,11 @@ import { MigrationInterface, QueryRunner } from "typeorm"; await queryRunner.query(`ALTER TABLE "contact" ALTER COLUMN "latitude" TYPE double precision`); await queryRunner.query(`ALTER TABLE "contact" ALTER COLUMN "longitude" TYPE double precision`); } - + /** * PostgresDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "contact" ALTER COLUMN "longitude" TYPE double precision`); @@ -48,8 +48,8 @@ import { MigrationInterface, QueryRunner } from "typeorm"; /** * SqliteDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`CREATE TABLE "password_reset" ("id" varchar PRIMARY KEY NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "email" varchar NOT NULL, "token" varchar NOT NULL)`); @@ -67,8 +67,8 @@ import { MigrationInterface, QueryRunner } from "typeorm"; /** * SqliteDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_60468af1ce34043a900809c84f"`); @@ -83,4 +83,4 @@ import { MigrationInterface, QueryRunner } from "typeorm"; await queryRunner.query(`DROP INDEX "IDX_1c88db6e50f0704688d1f1978c"`); await queryRunner.query(`DROP TABLE "password_reset"`); } - } \ No newline at end of file + } diff --git a/packages/core/src/database/migrations/1640784835692-AlterActivityTable.ts b/packages/core/src/database/migrations/1640784835692-AlterActivityTable.ts index 7e2da53d036..aeb88e62c40 100644 --- a/packages/core/src/database/migrations/1640784835692-AlterActivityTable.ts +++ b/packages/core/src/database/migrations/1640784835692-AlterActivityTable.ts @@ -1,11 +1,11 @@ import { MigrationInterface, QueryRunner } from "typeorm"; - + export class AlterActivityTable1640784835692 implements MigrationInterface { name = 'AlterActivityTable1640784835692'; public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -13,7 +13,7 @@ export class AlterActivityTable1640784835692 implements MigrationInterface { } public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); @@ -22,8 +22,8 @@ export class AlterActivityTable1640784835692 implements MigrationInterface { /** * PostgresDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "activity" ALTER COLUMN "title" DROP NOT NULL`); @@ -31,8 +31,8 @@ export class AlterActivityTable1640784835692 implements MigrationInterface { /** * PostgresDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "activity" ALTER COLUMN "title" SET NOT NULL`); @@ -40,8 +40,8 @@ export class AlterActivityTable1640784835692 implements MigrationInterface { /** * SqliteDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_2743f8990fde12f9586287eb09"`); @@ -96,8 +96,8 @@ export class AlterActivityTable1640784835692 implements MigrationInterface { /** * SqliteDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_f2401d8fdff5d8970dfe30d3ae"`); @@ -149,4 +149,4 @@ export class AlterActivityTable1640784835692 implements MigrationInterface { await queryRunner.query(`CREATE INDEX "IDX_4e382caaf07ab0923b2e06bf91" ON "activity" ("timeSlotId") `); await queryRunner.query(`CREATE INDEX "IDX_2743f8990fde12f9586287eb09" ON "activity" ("taskId") `); } -} \ No newline at end of file +} diff --git a/packages/core/src/database/migrations/1642411409517-AlterCandidateEmployeeTable.ts b/packages/core/src/database/migrations/1642411409517-AlterCandidateEmployeeTable.ts index 91c263ca0fa..d5568f2ccfe 100644 --- a/packages/core/src/database/migrations/1642411409517-AlterCandidateEmployeeTable.ts +++ b/packages/core/src/database/migrations/1642411409517-AlterCandidateEmployeeTable.ts @@ -1,11 +1,11 @@ import { MigrationInterface, QueryRunner } from "typeorm"; - + export class AlterCandidateEmployeeTable1642411409517 implements MigrationInterface { name = 'AlterCandidateEmployeeTable1642411409517'; public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -13,17 +13,17 @@ export class AlterCandidateEmployeeTable1642411409517 implements MigrationInterf } public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); } } - + /** * PostgresDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "candidate" ADD "employeeId" uuid`); @@ -33,11 +33,11 @@ export class AlterCandidateEmployeeTable1642411409517 implements MigrationInterf await queryRunner.query(`CREATE INDEX "IDX_8b900e8a39f76125e610ab30c0" ON "candidate" ("employeeId") `); await queryRunner.query(`ALTER TABLE "candidate" ADD CONSTRAINT "FK_8b900e8a39f76125e610ab30c0e" FOREIGN KEY ("employeeId") REFERENCES "employee"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); } - + /** * PostgresDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "candidate" DROP CONSTRAINT "FK_8b900e8a39f76125e610ab30c0e"`); @@ -50,8 +50,8 @@ export class AlterCandidateEmployeeTable1642411409517 implements MigrationInterf /** * SqliteDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_3930aa71e0fa24f09201811b1b"`); @@ -101,8 +101,8 @@ export class AlterCandidateEmployeeTable1642411409517 implements MigrationInterf /** * SqliteDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_8b900e8a39f76125e610ab30c0"`); @@ -149,4 +149,4 @@ export class AlterCandidateEmployeeTable1642411409517 implements MigrationInterf await queryRunner.query(`CREATE INDEX "IDX_4ea108fd8b089237964d5f98fb" ON "candidate" ("sourceId") `); await queryRunner.query(`CREATE INDEX "IDX_3930aa71e0fa24f09201811b1b" ON "candidate" ("userId") `); } -} \ No newline at end of file +} diff --git a/packages/core/src/database/migrations/1642770124831-AlterEmailHistoryTable.ts b/packages/core/src/database/migrations/1642770124831-AlterEmailHistoryTable.ts index 57dae735ddf..6a9d8f0848f 100644 --- a/packages/core/src/database/migrations/1642770124831-AlterEmailHistoryTable.ts +++ b/packages/core/src/database/migrations/1642770124831-AlterEmailHistoryTable.ts @@ -1,11 +1,11 @@ import { MigrationInterface, QueryRunner } from "typeorm"; - + export class AlterEmailHistoryTable1642770124831 implements MigrationInterface { name = 'AlterEmailHistoryTable1642770124831'; - + public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -13,7 +13,7 @@ export class AlterEmailHistoryTable1642770124831 implements MigrationInterface { } public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); @@ -22,8 +22,8 @@ export class AlterEmailHistoryTable1642770124831 implements MigrationInterface { /** * PostgresDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "email_sent" ALTER COLUMN "name" DROP NOT NULL`); @@ -33,8 +33,8 @@ export class AlterEmailHistoryTable1642770124831 implements MigrationInterface { /** * PostgresDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "public"."IDX_a954fda57cca81dc48446e73b8"`); @@ -44,8 +44,8 @@ export class AlterEmailHistoryTable1642770124831 implements MigrationInterface { /** * SqliteDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_5e719204dcafa8d6b2ecdeda13"`); @@ -105,8 +105,8 @@ export class AlterEmailHistoryTable1642770124831 implements MigrationInterface { /** * SqliteDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_a954fda57cca81dc48446e73b8"`); @@ -163,4 +163,4 @@ export class AlterEmailHistoryTable1642770124831 implements MigrationInterface { await queryRunner.query(`CREATE INDEX "IDX_1c0c1370ecd98040259625e17e" ON "employee" ("contactId") `); await queryRunner.query(`CREATE INDEX "IDX_5e719204dcafa8d6b2ecdeda13" ON "employee" ("organizationPositionId") `); } -} \ No newline at end of file +} diff --git a/packages/core/src/database/migrations/1643201180573-AlterTaskTable.ts b/packages/core/src/database/migrations/1643201180573-AlterTaskTable.ts index ca0a9c3bcd2..8219e8dc3be 100644 --- a/packages/core/src/database/migrations/1643201180573-AlterTaskTable.ts +++ b/packages/core/src/database/migrations/1643201180573-AlterTaskTable.ts @@ -1,11 +1,11 @@ import { MigrationInterface, QueryRunner } from "typeorm"; - + export class AlterTaskTable1643201180573 implements MigrationInterface { name = 'AlterTaskTable1643201180573'; public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -13,7 +13,7 @@ export class AlterTaskTable1643201180573 implements MigrationInterface { } public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); @@ -22,8 +22,8 @@ export class AlterTaskTable1643201180573 implements MigrationInterface { /** * PostgresDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "task" ALTER COLUMN "status" SET DEFAULT 'Todo'`); @@ -31,8 +31,8 @@ export class AlterTaskTable1643201180573 implements MigrationInterface { /** * PostgresDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "task" ALTER COLUMN "status" DROP DEFAULT`); @@ -40,8 +40,8 @@ export class AlterTaskTable1643201180573 implements MigrationInterface { /** * SqliteDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_1e1f64696aa3a26d3e12c840e5"`); @@ -62,8 +62,8 @@ export class AlterTaskTable1643201180573 implements MigrationInterface { /** * SqliteDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_e91cbff3d206f150ccc14d0c3a"`); @@ -81,4 +81,4 @@ export class AlterTaskTable1643201180573 implements MigrationInterface { await queryRunner.query(`CREATE INDEX "IDX_94fe6b3a5aec5f85427df4f8cd" ON "task" ("creatorId") `); await queryRunner.query(`CREATE INDEX "IDX_1e1f64696aa3a26d3e12c840e5" ON "task" ("organizationSprintId") `); } -} \ No newline at end of file +} diff --git a/packages/core/src/database/migrations/1643807301083-AlterRolePermissionTable.ts b/packages/core/src/database/migrations/1643807301083-AlterRolePermissionTable.ts index fd3ddf3f338..6df714fff5a 100644 --- a/packages/core/src/database/migrations/1643807301083-AlterRolePermissionTable.ts +++ b/packages/core/src/database/migrations/1643807301083-AlterRolePermissionTable.ts @@ -1,11 +1,11 @@ import { MigrationInterface, QueryRunner } from "typeorm"; - + export class AlterRolePermissionTable1643807301083 implements MigrationInterface { name = 'AlterRolePermissionTable1643807301083'; public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -13,7 +13,7 @@ export class AlterRolePermissionTable1643807301083 implements MigrationInterface } public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); @@ -22,8 +22,8 @@ export class AlterRolePermissionTable1643807301083 implements MigrationInterface /** * PostgresDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "role_permission" ADD "description" character varying`); @@ -31,8 +31,8 @@ export class AlterRolePermissionTable1643807301083 implements MigrationInterface /** * PostgresDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "role_permission" DROP COLUMN "description"`); @@ -40,8 +40,8 @@ export class AlterRolePermissionTable1643807301083 implements MigrationInterface /** * SqliteDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_e3130a39c1e4a740d044e68573"`); @@ -58,8 +58,8 @@ export class AlterRolePermissionTable1643807301083 implements MigrationInterface /** * SqliteDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_cbd053921056e77c0a8e03122a"`); @@ -73,4 +73,4 @@ export class AlterRolePermissionTable1643807301083 implements MigrationInterface await queryRunner.query(`CREATE INDEX "IDX_8307c5c44a4ad6210b767b17a9" ON "role_permission" ("permission") `); await queryRunner.query(`CREATE INDEX "IDX_e3130a39c1e4a740d044e68573" ON "role_permission" ("roleId") `); } -} \ No newline at end of file +} diff --git a/packages/core/src/database/migrations/1644491785525-AdjustTimeLogStopDate.ts b/packages/core/src/database/migrations/1644491785525-AdjustTimeLogStopDate.ts index 3d105ab39f5..3e84113ca8b 100644 --- a/packages/core/src/database/migrations/1644491785525-AdjustTimeLogStopDate.ts +++ b/packages/core/src/database/migrations/1644491785525-AdjustTimeLogStopDate.ts @@ -2,54 +2,72 @@ import { MigrationInterface, QueryRunner } from "typeorm"; import { chain } from 'underscore'; import * as moment from 'moment'; import { isEmpty, isNotEmpty } from "@gauzy/common"; - + export class AdjustTimeLogStopDate1644491785525 implements MigrationInterface { name = 'AdjustTimeLogStopDate1644491785525'; - + public async up(queryRunner: QueryRunner): Promise { - const timeSlots = await queryRunner.connection.manager.query(` - SELECT * FROM - "time_slot" - WHERE - "time_slot"."overall" < $1 OR + const isSqlite = ['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type); + const timeSlots = await queryRunner.connection.manager.query( + isSqlite + ? ` + SELECT * FROM + "time_slot" + WHERE + "time_slot"."overall" < ? OR + "time_slot"."keyboard" < ? OR + "time_slot"."mouse" < ? OR + "time_slot"."duration" > ?; + ` + : ` + SELECT * FROM + "time_slot" + WHERE + "time_slot"."overall" < $1 OR "time_slot"."keyboard" < $2 OR "time_slot"."mouse" < $3 OR - "time_slot"."duration" > $4 - `, [0, 0, 0, 600]); + "time_slot"."duration" > $4; + `, + [0, 0, 0, 600] + ); for await (const timeSlot of timeSlots) { const duration = (timeSlot.duration < 0) ? 0 : (timeSlot.duration > 600) ? 600 : timeSlot.duration; const overall = (timeSlot.overall < 0) ? 0 : (timeSlot.overall > 600) ? 600 : timeSlot.overall; const keyboard = (timeSlot.keyboard < 0) ? 0 : (timeSlot.keyboard > 600) ? 600 : timeSlot.keyboard; const mouse = (timeSlot.mouse < 0) ? 0 : (timeSlot.mouse > 600) ? 600 : timeSlot.mouse; - await queryRunner.connection.manager.query(` + await queryRunner.connection.manager.query( + isSqlite + ? ` + UPDATE "time_slot" SET + "duration" = ?, + "overall" = ?, + "keyboard" = ?, + "mouse" = ? + WHERE + "id" IN(?)` + : ` UPDATE "time_slot" SET "duration" = $1, "overall" = $2, "keyboard" = $3, "mouse" = $4 - WHERE + WHERE "id" IN($5)`, - [ - duration, - overall, - keyboard, - mouse, - timeSlot.id - ] - ); + [duration, overall, keyboard, mouse, timeSlot.id] + ); } const timelogs = await queryRunner.connection.manager.query(` - SELECT + SELECT "time_log"."id" AS "time_log_id", "time_slot"."id" AS "time_slot_id" FROM "time_log" - LEFT JOIN "time_slot_time_logs" - ON "time_slot_time_logs"."timeLogId" = "time_log"."id" + LEFT JOIN "time_slot_time_logs" + ON "time_slot_time_logs"."timeLogId" = "time_log"."id" LEFT JOIN "time_slot" ON "time_slot"."id" = "time_slot_time_logs"."timeSlotId" - WHERE + WHERE "time_log"."stoppedAt" IS NULL `); const timeLogs = chain(timelogs).groupBy((log: any) => log.time_log_id).value(); @@ -59,35 +77,39 @@ export class AdjustTimeLogStopDate1644491785525 implements MigrationInterface { (timeSlot: any) => timeSlot.time_slot_id ) .filter(Boolean); - const [timeLog] = await queryRunner.connection.manager.query(` - SELECT * FROM "time_log" WHERE "time_log"."id" = $1 LIMIT 1`, - [ - timeLogId - ] - ); + const [timeLog] = await queryRunner.connection.manager.query( + isSqlite + ? `SELECT * FROM "time_log" WHERE "time_log"."id" = ? LIMIT 1` + : `SELECT * FROM "time_log" WHERE "time_log"."id" = $1 LIMIT 1`, + [timeLogId] + ); const logDifference = moment().diff(moment.utc(timeLog.startedAt), 'minutes'); if ( isEmpty(timeSlotsIds) && logDifference > 10 ) { - await queryRunner.connection.manager.query(` - UPDATE "time_log" SET + await queryRunner.connection.manager.query( + isSqlite + ? ` + UPDATE "time_log" SET + "stoppedAt" = ? + WHERE + "id" IN(?)` + : ` + UPDATE "time_log" SET "stoppedAt" = $1 - WHERE - "id" IN($2)`, - [ - timeLog.startedAt, - timeLog.id - ] - ); + WHERE + "id" IN($2)`, + [timeLog.startedAt, timeLog.id] + ); } else if (isNotEmpty(timeSlotsIds)) { const timeSlots = await queryRunner.connection.manager.query(` - SELECT * FROM - "time_slot" - WHERE - "time_slot"."id" IN ('${timeSlotsIds.join("','")}') - ORDER BY + SELECT * FROM + "time_slot" + WHERE + "time_slot"."id" IN ('${timeSlotsIds.join("','")}') + ORDER BY "time_slot"."startedAt" DESC `); let stoppedAt: any; @@ -98,7 +120,7 @@ export class AdjustTimeLogStopDate1644491785525 implements MigrationInterface { /** * Adjust stopped date as per database selection */ - if (queryRunner.connection.options.type === 'sqlite') { + if (isSqlite) { stoppedAt = moment.utc(lastTimeSlot.startedAt) .add(duration, 'seconds') .format('YYYY-MM-DD HH:mm:ss.SSS'); @@ -110,20 +132,24 @@ export class AdjustTimeLogStopDate1644491785525 implements MigrationInterface { slotDifference = moment().diff(moment.utc(stoppedAt), 'minutes'); } if (slotDifference > 10) { - await queryRunner.connection.manager.query(` + await queryRunner.connection.manager.query( + isSqlite + ? ` + UPDATE "time_log" SET + "stoppedAt" = ? + WHERE + "id" IN(?)` + : ` UPDATE "time_log" SET "stoppedAt" = $1 - WHERE + WHERE "id" IN($2)`, - [ - stoppedAt, - timeLog.id - ] - ); + [stoppedAt, timeLog.id] + ); } } } } - + public async down(queryRunner: QueryRunner): Promise {} -} \ No newline at end of file +} diff --git a/packages/core/src/database/migrations/1644568289509-AlterTimeLogTable.ts b/packages/core/src/database/migrations/1644568289509-AlterTimeLogTable.ts index 2623d6f7f07..8cacf5fdb65 100644 --- a/packages/core/src/database/migrations/1644568289509-AlterTimeLogTable.ts +++ b/packages/core/src/database/migrations/1644568289509-AlterTimeLogTable.ts @@ -1,11 +1,11 @@ import { MigrationInterface, QueryRunner } from "typeorm"; - + export class AlterTimeLogTable1644568289509 implements MigrationInterface { name = 'AlterTimeLogTable1644568289509'; public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -13,7 +13,7 @@ export class AlterTimeLogTable1644568289509 implements MigrationInterface { } public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); @@ -22,8 +22,8 @@ export class AlterTimeLogTable1644568289509 implements MigrationInterface { /** * PostgresDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "time_log" ADD "isRunning" boolean`); @@ -31,8 +31,8 @@ export class AlterTimeLogTable1644568289509 implements MigrationInterface { /** * PostgresDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "time_log" DROP COLUMN "isRunning"`); @@ -40,8 +40,8 @@ export class AlterTimeLogTable1644568289509 implements MigrationInterface { /** * SqliteDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_d1e8f22c02c5e949453dde7f2d"`); @@ -66,8 +66,8 @@ export class AlterTimeLogTable1644568289509 implements MigrationInterface { /** * SqliteDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_fa9018cb248ea0f3b2b30ef143"`); @@ -89,4 +89,4 @@ export class AlterTimeLogTable1644568289509 implements MigrationInterface { await queryRunner.query(`CREATE INDEX "IDX_1ddf2da35e34378fd845d80a18" ON "time_log" ("taskId")`); await queryRunner.query(`CREATE INDEX "IDX_d1e8f22c02c5e949453dde7f2d" ON "time_log" ("organizationContactId")`); } -} \ No newline at end of file +} diff --git a/packages/core/src/database/migrations/1644915598578-AlterEmployeeTable.ts b/packages/core/src/database/migrations/1644915598578-AlterEmployeeTable.ts index df8dc32624e..6113dc48a10 100644 --- a/packages/core/src/database/migrations/1644915598578-AlterEmployeeTable.ts +++ b/packages/core/src/database/migrations/1644915598578-AlterEmployeeTable.ts @@ -1,11 +1,11 @@ import { MigrationInterface, QueryRunner } from "typeorm"; - + export class AlterEmployeeTable1644915598578 implements MigrationInterface { name = 'AlterEmployeeTable1644915598578'; public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -13,7 +13,7 @@ export class AlterEmployeeTable1644915598578 implements MigrationInterface { } public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); @@ -22,8 +22,8 @@ export class AlterEmployeeTable1644915598578 implements MigrationInterface { /** * PostgresDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "employee" ALTER COLUMN "totalWorkHours" DROP NOT NULL`); @@ -31,17 +31,17 @@ export class AlterEmployeeTable1644915598578 implements MigrationInterface { /** * PostgresDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "employee" ALTER COLUMN "totalWorkHours" SET NOT NULL`); } - + /** * SqliteDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_4b3303a6b7eb92d237a4379734"`); @@ -85,11 +85,11 @@ export class AlterEmployeeTable1644915598578 implements MigrationInterface { await queryRunner.query(`CREATE INDEX "IDX_1c0c1370ecd98040259625e17e" ON "employee" ("contactId") `); await queryRunner.query(`CREATE INDEX "IDX_5e719204dcafa8d6b2ecdeda13" ON "employee" ("organizationPositionId") `); } - + /** * SqliteDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_5e719204dcafa8d6b2ecdeda13"`); @@ -133,4 +133,4 @@ export class AlterEmployeeTable1644915598578 implements MigrationInterface { await queryRunner.query(`CREATE INDEX "IDX_c6a48286f3aa8ae903bee0d1e7" ON "employee" ("organizationId") `); await queryRunner.query(`CREATE INDEX "IDX_4b3303a6b7eb92d237a4379734" ON "employee" ("tenantId") `); } -} \ No newline at end of file +} diff --git a/packages/core/src/database/migrations/1645012749640-AlterPaymentTable.ts b/packages/core/src/database/migrations/1645012749640-AlterPaymentTable.ts index 80a9a03e204..a9601f61f11 100644 --- a/packages/core/src/database/migrations/1645012749640-AlterPaymentTable.ts +++ b/packages/core/src/database/migrations/1645012749640-AlterPaymentTable.ts @@ -1,11 +1,11 @@ import { MigrationInterface, QueryRunner } from "typeorm"; - + export class AlterPaymentTable1645012749640 implements MigrationInterface { name = 'AlterPaymentTable1645012749640'; public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -13,7 +13,7 @@ export class AlterPaymentTable1645012749640 implements MigrationInterface { } public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); @@ -22,8 +22,8 @@ export class AlterPaymentTable1645012749640 implements MigrationInterface { /** * PostgresDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "payment" DROP COLUMN "paymentMethod"`); @@ -33,8 +33,8 @@ export class AlterPaymentTable1645012749640 implements MigrationInterface { /** * PostgresDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "payment" DROP COLUMN "paymentMethod"`); @@ -44,15 +44,15 @@ export class AlterPaymentTable1645012749640 implements MigrationInterface { /** * SqliteDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteUpQueryRunner(queryRunner: QueryRunner): Promise {} /** * SqliteDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteDownQueryRunner(queryRunner: QueryRunner): Promise {} -} \ No newline at end of file +} diff --git a/packages/core/src/database/migrations/1645087150917-AlterEmailTable.ts b/packages/core/src/database/migrations/1645087150917-AlterEmailTable.ts index 4b2724d20bf..3fe921e3b16 100644 --- a/packages/core/src/database/migrations/1645087150917-AlterEmailTable.ts +++ b/packages/core/src/database/migrations/1645087150917-AlterEmailTable.ts @@ -1,11 +1,11 @@ import { MigrationInterface, QueryRunner } from "typeorm"; - + export class AlterEmailTable1645087150917 implements MigrationInterface { name = 'AlterEmailTable1645087150917'; public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -13,7 +13,7 @@ export class AlterEmailTable1645087150917 implements MigrationInterface { } public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); @@ -22,8 +22,8 @@ export class AlterEmailTable1645087150917 implements MigrationInterface { /** * PostgresDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "email_sent" ALTER COLUMN "isArchived" SET DEFAULT false`); @@ -35,8 +35,8 @@ export class AlterEmailTable1645087150917 implements MigrationInterface { /** * PostgresDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "email_sent" ALTER COLUMN "isArchived" DROP DEFAULT`); @@ -44,8 +44,8 @@ export class AlterEmailTable1645087150917 implements MigrationInterface { /** * SqliteDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_a954fda57cca81dc48446e73b8"`); @@ -65,13 +65,13 @@ export class AlterEmailTable1645087150917 implements MigrationInterface { /** * SET isArchived = 0, if database has already NULL rows */ - await queryRunner.query(`UPDATE "email_sent" SET "isArchived" = $1 WHERE "isArchived" IS NULL`, [0]); + await queryRunner.query(`UPDATE "email_sent" SET "isArchived" = ? WHERE "isArchived" IS NULL`, [0]); } /** * SqliteDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_1261c457b3035b77719556995b"`); @@ -89,4 +89,4 @@ export class AlterEmailTable1645087150917 implements MigrationInterface { await queryRunner.query(`CREATE INDEX "IDX_0af511c44de7a16beb45cc3785" ON "email_sent" ("tenantId") `); await queryRunner.query(`CREATE INDEX "IDX_a954fda57cca81dc48446e73b8" ON "email_sent" ("email") `); } -} \ No newline at end of file +} diff --git a/packages/core/src/database/migrations/1645179275947-AlterInvoiceTable.ts b/packages/core/src/database/migrations/1645179275947-AlterInvoiceTable.ts index 444abd07ea6..27f36f11422 100644 --- a/packages/core/src/database/migrations/1645179275947-AlterInvoiceTable.ts +++ b/packages/core/src/database/migrations/1645179275947-AlterInvoiceTable.ts @@ -1,11 +1,11 @@ import { MigrationInterface, QueryRunner } from "typeorm"; - + export class AlterInvoiceTable1645179275947 implements MigrationInterface { name = 'AlterInvoiceTable1645179275947'; public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -13,7 +13,7 @@ export class AlterInvoiceTable1645179275947 implements MigrationInterface { } public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); @@ -22,8 +22,8 @@ export class AlterInvoiceTable1645179275947 implements MigrationInterface { /** * PostgresDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "invoice" ALTER COLUMN "isArchived" SET DEFAULT false`); @@ -31,8 +31,8 @@ export class AlterInvoiceTable1645179275947 implements MigrationInterface { /** * PostgresDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "invoice" ALTER COLUMN "isArchived" DROP DEFAULT`); @@ -41,8 +41,8 @@ export class AlterInvoiceTable1645179275947 implements MigrationInterface { /** * SqliteDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_d9e965da0f63c94983d3a1006a"`); @@ -61,8 +61,8 @@ export class AlterInvoiceTable1645179275947 implements MigrationInterface { /** * SqliteDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_7fb52a5f267f53b7d93af3d8c3"`); @@ -78,4 +78,4 @@ export class AlterInvoiceTable1645179275947 implements MigrationInterface { await queryRunner.query(`CREATE INDEX "IDX_b5c33892e630b66c65d623baf8" ON "invoice" ("fromOrganizationId") `); await queryRunner.query(`CREATE INDEX "IDX_d9e965da0f63c94983d3a1006a" ON "invoice" ("toContactId") `); } -} \ No newline at end of file +} diff --git a/packages/core/src/database/migrations/1645441629137-AddTimeTrackingFeatureToEmployeeTable.ts b/packages/core/src/database/migrations/1645441629137-AddTimeTrackingFeatureToEmployeeTable.ts index 826c0d2b3ca..a46fe1af74f 100644 --- a/packages/core/src/database/migrations/1645441629137-AddTimeTrackingFeatureToEmployeeTable.ts +++ b/packages/core/src/database/migrations/1645441629137-AddTimeTrackingFeatureToEmployeeTable.ts @@ -1,11 +1,11 @@ import { MigrationInterface, QueryRunner } from "typeorm"; - + export class AddTimeTrackingFeatureToEmployeeTable1645441629137 implements MigrationInterface { name = 'AddTimeTrackingFeatureToEmployeeTable1645441629137'; public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -13,7 +13,7 @@ export class AddTimeTrackingFeatureToEmployeeTable1645441629137 implements Migra } public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); @@ -22,8 +22,8 @@ export class AddTimeTrackingFeatureToEmployeeTable1645441629137 implements Migra /** * PostgresDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "employee" ADD "isTrackingEnabled" boolean DEFAULT true`); @@ -31,8 +31,8 @@ export class AddTimeTrackingFeatureToEmployeeTable1645441629137 implements Migra /** * PostgresDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "employee" DROP COLUMN "isTrackingEnabled"`); @@ -41,8 +41,8 @@ export class AddTimeTrackingFeatureToEmployeeTable1645441629137 implements Migra /** * SqliteDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_5e719204dcafa8d6b2ecdeda13"`); @@ -65,8 +65,8 @@ export class AddTimeTrackingFeatureToEmployeeTable1645441629137 implements Migra /** * SqliteDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_4b3303a6b7eb92d237a4379734"`); @@ -86,4 +86,4 @@ export class AddTimeTrackingFeatureToEmployeeTable1645441629137 implements Migra await queryRunner.query(`CREATE INDEX "IDX_1c0c1370ecd98040259625e17e" ON "employee" ("contactId")`); await queryRunner.query(`CREATE INDEX "IDX_5e719204dcafa8d6b2ecdeda13" ON "employee" ("organizationPositionId")`); } -} \ No newline at end of file +} diff --git a/packages/core/src/database/migrations/1645726031706-AlterIntegrationTable.ts b/packages/core/src/database/migrations/1645726031706-AlterIntegrationTable.ts index 12a73fc49ed..b45e568ab29 100644 --- a/packages/core/src/database/migrations/1645726031706-AlterIntegrationTable.ts +++ b/packages/core/src/database/migrations/1645726031706-AlterIntegrationTable.ts @@ -1,11 +1,11 @@ import { MigrationInterface, QueryRunner } from "typeorm"; - + export class AlterIntegrationTable1645726031706 implements MigrationInterface { name = 'AlterIntegrationTable1645726031706'; - + public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -13,7 +13,7 @@ export class AlterIntegrationTable1645726031706 implements MigrationInterface { } public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); @@ -22,8 +22,8 @@ export class AlterIntegrationTable1645726031706 implements MigrationInterface { /** * PostgresDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "integration" ALTER COLUMN "freeTrialPeriod" DROP NOT NULL`); @@ -31,8 +31,8 @@ export class AlterIntegrationTable1645726031706 implements MigrationInterface { /** * PostgresDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "integration" ALTER COLUMN "freeTrialPeriod" SET NOT NULL`); @@ -41,8 +41,8 @@ export class AlterIntegrationTable1645726031706 implements MigrationInterface { /** * SqliteDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`CREATE TABLE "temporary_integration" ("id" varchar PRIMARY KEY NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "name" varchar NOT NULL, "imgSrc" varchar, "isComingSoon" boolean NOT NULL DEFAULT (0), "isPaid" boolean NOT NULL DEFAULT (0), "version" varchar, "docUrl" varchar, "isFreeTrial" boolean NOT NULL DEFAULT (0), "freeTrialPeriod" numeric NOT NULL DEFAULT (0), "order" integer)`); @@ -57,8 +57,8 @@ export class AlterIntegrationTable1645726031706 implements MigrationInterface { /** * SqliteDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "integration" RENAME TO "temporary_integration"`); @@ -70,4 +70,4 @@ export class AlterIntegrationTable1645726031706 implements MigrationInterface { await queryRunner.query(`INSERT INTO "integration"("id", "createdAt", "updatedAt", "name", "imgSrc", "isComingSoon", "isPaid", "version", "docUrl", "isFreeTrial", "freeTrialPeriod", "order") SELECT "id", "createdAt", "updatedAt", "name", "imgSrc", "isComingSoon", "isPaid", "version", "docUrl", "isFreeTrial", "freeTrialPeriod", "order" FROM "temporary_integration"`); await queryRunner.query(`DROP TABLE "temporary_integration"`); } -} \ No newline at end of file +} diff --git a/packages/core/src/database/migrations/1646056129050-AlterEmployeeRecurringExpenseTable.ts b/packages/core/src/database/migrations/1646056129050-AlterEmployeeRecurringExpenseTable.ts index 2a2f3adf612..9fe69a5956c 100644 --- a/packages/core/src/database/migrations/1646056129050-AlterEmployeeRecurringExpenseTable.ts +++ b/packages/core/src/database/migrations/1646056129050-AlterEmployeeRecurringExpenseTable.ts @@ -1,11 +1,11 @@ import { MigrationInterface, QueryRunner } from "typeorm"; - + export class AlterEmployeeRecurringExpenseTable1646056129050 implements MigrationInterface { name = 'AlterEmployeeRecurringExpenseTable1646056129050'; public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -13,7 +13,7 @@ export class AlterEmployeeRecurringExpenseTable1646056129050 implements Migratio } public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); @@ -22,8 +22,8 @@ export class AlterEmployeeRecurringExpenseTable1646056129050 implements Migratio /** * PostgresDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "employee_recurring_expense" DROP CONSTRAINT "FK_0ac8526c48a3daa267c86225fb5"`); @@ -33,8 +33,8 @@ export class AlterEmployeeRecurringExpenseTable1646056129050 implements Migratio /** * PostgresDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "employee_recurring_expense" DROP CONSTRAINT "FK_0ac8526c48a3daa267c86225fb5"`); @@ -45,8 +45,8 @@ export class AlterEmployeeRecurringExpenseTable1646056129050 implements Migratio /** * SqliteDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_0ac8526c48a3daa267c86225fb"`); @@ -117,8 +117,8 @@ export class AlterEmployeeRecurringExpenseTable1646056129050 implements Migratio /** * SqliteDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_5fde7be40b3c03bc0fdac0c2f6"`); @@ -186,4 +186,4 @@ export class AlterEmployeeRecurringExpenseTable1646056129050 implements Migratio await queryRunner.query(`CREATE INDEX "IDX_6e570174fda71e97616e9d2eea" ON "employee_recurring_expense" ("parentRecurringExpenseId") `); await queryRunner.query(`CREATE INDEX "IDX_0ac8526c48a3daa267c86225fb" ON "employee_recurring_expense" ("employeeId") `); } -} \ No newline at end of file +} diff --git a/packages/core/src/database/migrations/1646117679347-AlterScreenshotTable.ts b/packages/core/src/database/migrations/1646117679347-AlterScreenshotTable.ts index 4181f22de4d..8c8c96e4dc0 100644 --- a/packages/core/src/database/migrations/1646117679347-AlterScreenshotTable.ts +++ b/packages/core/src/database/migrations/1646117679347-AlterScreenshotTable.ts @@ -1,11 +1,11 @@ import { MigrationInterface, QueryRunner } from "typeorm"; - + export class AlterScreenshotTable1646117679347 implements MigrationInterface { name = 'AlterScreenshotTable1646117679347'; public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -13,7 +13,7 @@ export class AlterScreenshotTable1646117679347 implements MigrationInterface { } public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); @@ -22,8 +22,8 @@ export class AlterScreenshotTable1646117679347 implements MigrationInterface { /** * PostgresDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`CREATE TYPE "public"."screenshot_storageprovider_enum" AS ENUM('LOCAL', 'S3', 'WASABI')`); @@ -32,8 +32,8 @@ export class AlterScreenshotTable1646117679347 implements MigrationInterface { /** * PostgresDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "screenshot" DROP COLUMN "storageProvider"`); @@ -43,8 +43,8 @@ export class AlterScreenshotTable1646117679347 implements MigrationInterface { /** * SqliteDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_5b594d02d98d5defcde323abe5"`); @@ -61,8 +61,8 @@ export class AlterScreenshotTable1646117679347 implements MigrationInterface { /** * SqliteDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_235004f3dafac90692cd64d915"`); @@ -76,4 +76,4 @@ export class AlterScreenshotTable1646117679347 implements MigrationInterface { await queryRunner.query(`CREATE INDEX "IDX_0951aacffe3f8d0cff54cf2f34" ON "screenshot" ("organizationId") `); await queryRunner.query(`CREATE INDEX "IDX_5b594d02d98d5defcde323abe5" ON "screenshot" ("timeSlotId") `); } -} \ No newline at end of file +} diff --git a/packages/core/src/database/migrations/1646206946845-AlterExpenseTable.ts b/packages/core/src/database/migrations/1646206946845-AlterExpenseTable.ts index 01f4ac66e8d..1e41ae74ee7 100644 --- a/packages/core/src/database/migrations/1646206946845-AlterExpenseTable.ts +++ b/packages/core/src/database/migrations/1646206946845-AlterExpenseTable.ts @@ -1,11 +1,11 @@ import { MigrationInterface, QueryRunner } from "typeorm"; - + export class AlterExpenseTable1646206946845 implements MigrationInterface { name = 'AlterExpenseTable1646206946845'; public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -13,7 +13,7 @@ export class AlterExpenseTable1646206946845 implements MigrationInterface { } public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); @@ -22,8 +22,8 @@ export class AlterExpenseTable1646206946845 implements MigrationInterface { /** * PostgresDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "expense" DROP CONSTRAINT "FK_eacb116ab0521ad9b96f2bb53ba"`); @@ -34,8 +34,8 @@ export class AlterExpenseTable1646206946845 implements MigrationInterface { /** * PostgresDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "expense" DROP CONSTRAINT "FK_42eea5debc63f4d1bf89881c10a"`); @@ -47,8 +47,8 @@ export class AlterExpenseTable1646206946845 implements MigrationInterface { /** * SqliteDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_047b8b5c0782d5a6d4c8bfc1a4"`); @@ -163,8 +163,8 @@ export class AlterExpenseTable1646206946845 implements MigrationInterface { /** * SqliteDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_6d171c9d5f81095436b99da5e6"`); @@ -276,4 +276,4 @@ export class AlterExpenseTable1646206946845 implements MigrationInterface { await queryRunner.query(`CREATE INDEX "IDX_9971c4171ae051e74b833984a3" ON "expense" ("projectId") `); await queryRunner.query(`CREATE INDEX "IDX_047b8b5c0782d5a6d4c8bfc1a4" ON "expense" ("organizationContactId") `); } -} \ No newline at end of file +} diff --git a/packages/core/src/database/migrations/1647417832147-AlterActivityTable.ts b/packages/core/src/database/migrations/1647417832147-AlterActivityTable.ts index 13fcc05b0c4..e3d12eb5241 100644 --- a/packages/core/src/database/migrations/1647417832147-AlterActivityTable.ts +++ b/packages/core/src/database/migrations/1647417832147-AlterActivityTable.ts @@ -1,11 +1,11 @@ import { MigrationInterface, QueryRunner } from "typeorm"; - + export class AlterActivityTable1647417832147 implements MigrationInterface { name = 'AlterActivityTable1647417832147'; public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -13,7 +13,7 @@ export class AlterActivityTable1647417832147 implements MigrationInterface { } public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); @@ -22,8 +22,8 @@ export class AlterActivityTable1647417832147 implements MigrationInterface { /** * PostgresDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "activity" ADD "recordedAt" TIMESTAMP`); @@ -31,13 +31,13 @@ export class AlterActivityTable1647417832147 implements MigrationInterface { /** * PostgresDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "activity" DROP COLUMN "recordedAt"`); } - + public async sqliteUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_f2401d8fdff5d8970dfe30d3ae"`); await queryRunner.query(`DROP INDEX "IDX_fdb3f018c2bba4885bfa5757d1"`); @@ -56,7 +56,7 @@ export class AlterActivityTable1647417832147 implements MigrationInterface { await queryRunner.query(`CREATE INDEX "IDX_4e382caaf07ab0923b2e06bf91" ON "activity" ("timeSlotId") `); await queryRunner.query(`CREATE INDEX "IDX_2743f8990fde12f9586287eb09" ON "activity" ("taskId") `); } - + public async sqliteDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_2743f8990fde12f9586287eb09"`); await queryRunner.query(`DROP INDEX "IDX_4e382caaf07ab0923b2e06bf91"`); @@ -75,4 +75,4 @@ export class AlterActivityTable1647417832147 implements MigrationInterface { await queryRunner.query(`CREATE INDEX "IDX_fdb3f018c2bba4885bfa5757d1" ON "activity" ("organizationId") `); await queryRunner.query(`CREATE INDEX "IDX_f2401d8fdff5d8970dfe30d3ae" ON "activity" ("tenantId") `); } -} \ No newline at end of file +} diff --git a/packages/core/src/database/migrations/1648899149818-AlterTenantTable.ts b/packages/core/src/database/migrations/1648899149818-AlterTenantTable.ts index 38eaabb3722..e4888a25f51 100644 --- a/packages/core/src/database/migrations/1648899149818-AlterTenantTable.ts +++ b/packages/core/src/database/migrations/1648899149818-AlterTenantTable.ts @@ -1,11 +1,11 @@ import { MigrationInterface, QueryRunner } from "typeorm"; - + export class AlterTenantTable1648899149818 implements MigrationInterface { name = 'AlterTenantTable1648899149818'; public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -13,7 +13,7 @@ export class AlterTenantTable1648899149818 implements MigrationInterface { } public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); @@ -22,8 +22,8 @@ export class AlterTenantTable1648899149818 implements MigrationInterface { /** * PostgresDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "tenant" ADD "logo" character varying`); @@ -31,17 +31,17 @@ export class AlterTenantTable1648899149818 implements MigrationInterface { /** * PostgresDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "tenant" DROP COLUMN "logo"`); } - + /** * SqliteDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_56211336b5ff35fd944f225917"`); @@ -52,11 +52,11 @@ export class AlterTenantTable1648899149818 implements MigrationInterface { await queryRunner.query(`CREATE INDEX "IDX_56211336b5ff35fd944f225917" ON "tenant" ("name") `); await queryRunner.query(`CREATE INDEX "IDX_3062637d94040b8a277c5e6367" ON "tenant" ("logo") `); } - + /** * SqliteDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_3062637d94040b8a277c5e6367"`); @@ -67,4 +67,4 @@ export class AlterTenantTable1648899149818 implements MigrationInterface { await queryRunner.query(`DROP TABLE "temporary_tenant"`); await queryRunner.query(`CREATE INDEX "IDX_56211336b5ff35fd944f225917" ON "tenant" ("name") `); } -} \ No newline at end of file +} diff --git a/packages/core/src/database/migrations/1650532321598-AlterOrganizationProject.ts b/packages/core/src/database/migrations/1650532321598-AlterOrganizationProject.ts index aaedb92e65d..61de3104c42 100644 --- a/packages/core/src/database/migrations/1650532321598-AlterOrganizationProject.ts +++ b/packages/core/src/database/migrations/1650532321598-AlterOrganizationProject.ts @@ -6,7 +6,7 @@ export class AlterOrganizationProject1650532321598 implements MigrationInterface name = 'AlterOrganizationProject1650532321598'; public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -16,7 +16,7 @@ export class AlterOrganizationProject1650532321598 implements MigrationInterface } public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1650704972412-AlterChangelogTable.ts b/packages/core/src/database/migrations/1650704972412-AlterChangelogTable.ts index 6283ac5577c..b4086f932b8 100644 --- a/packages/core/src/database/migrations/1650704972412-AlterChangelogTable.ts +++ b/packages/core/src/database/migrations/1650704972412-AlterChangelogTable.ts @@ -5,7 +5,7 @@ export class AlterChangelogTable1650704972412 implements MigrationInterface { name = 'AlterChangelogTable1650704972412'; public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -13,7 +13,7 @@ export class AlterChangelogTable1650704972412 implements MigrationInterface { } public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); @@ -22,8 +22,8 @@ export class AlterChangelogTable1650704972412 implements MigrationInterface { /** * PostgresDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "changelog" ADD "isFeature" boolean`); @@ -33,19 +33,19 @@ export class AlterChangelogTable1650704972412 implements MigrationInterface { /** * PostgresDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "changelog" ALTER COLUMN "learnMoreUrl" SET NOT NULL`); await queryRunner.query(`ALTER TABLE "changelog" DROP COLUMN "imageUrl"`); await queryRunner.query(`ALTER TABLE "changelog" DROP COLUMN "isFeature"`); } - + /** * SqliteDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_c2037b621d2e8023898aee4ac7"`); @@ -65,11 +65,11 @@ export class AlterChangelogTable1650704972412 implements MigrationInterface { await queryRunner.query(`CREATE INDEX "IDX_c2037b621d2e8023898aee4ac7" ON "changelog" ("organizationId") `); await queryRunner.query(`CREATE INDEX "IDX_744268ee0ec6073883267bc3b6" ON "changelog" ("tenantId") `); } - + /** * SqliteDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_744268ee0ec6073883267bc3b6"`); @@ -89,4 +89,4 @@ export class AlterChangelogTable1650704972412 implements MigrationInterface { await queryRunner.query(`CREATE INDEX "IDX_744268ee0ec6073883267bc3b6" ON "changelog" ("tenantId") `); await queryRunner.query(`CREATE INDEX "IDX_c2037b621d2e8023898aee4ac7" ON "changelog" ("organizationId") `); } -} \ No newline at end of file +} diff --git a/packages/core/src/database/migrations/1652270907163-AlterTimeOffRequestTable.ts b/packages/core/src/database/migrations/1652270907163-AlterTimeOffRequestTable.ts index 58a8b9c98d7..3343d0a2889 100644 --- a/packages/core/src/database/migrations/1652270907163-AlterTimeOffRequestTable.ts +++ b/packages/core/src/database/migrations/1652270907163-AlterTimeOffRequestTable.ts @@ -1,10 +1,10 @@ import { MigrationInterface, QueryRunner } from "typeorm"; - + export class AlterTimeOffRequestTable1652270907163 implements MigrationInterface { name = 'AlterTimeOffRequestTable1652270907163'; public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -12,7 +12,7 @@ export class AlterTimeOffRequestTable1652270907163 implements MigrationInterface } public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); @@ -21,19 +21,19 @@ export class AlterTimeOffRequestTable1652270907163 implements MigrationInterface /** * PostgresDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "time_off_request" ALTER COLUMN "isHoliday" DROP NOT NULL`); await queryRunner.query(`ALTER TABLE "time_off_request" ALTER COLUMN "isHoliday" SET DEFAULT false`); await queryRunner.query(`ALTER TABLE "time_off_request" ALTER COLUMN "isArchived" SET DEFAULT false`); } - + /** * PostgresDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "time_off_request" ALTER COLUMN "isArchived" DROP DEFAULT`); @@ -43,8 +43,8 @@ export class AlterTimeOffRequestTable1652270907163 implements MigrationInterface /** * SqliteDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_c1f8ae47dc2f1882afc5045c73"`); @@ -71,8 +71,8 @@ export class AlterTimeOffRequestTable1652270907163 implements MigrationInterface /** * SqliteDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_4989834dd1c9c8ea3576ed99ce"`); @@ -96,4 +96,4 @@ export class AlterTimeOffRequestTable1652270907163 implements MigrationInterface await queryRunner.query(`CREATE INDEX "IDX_981333982a6df8b815957dcbf2" ON "time_off_request" ("organizationId") `); await queryRunner.query(`CREATE INDEX "IDX_c1f8ae47dc2f1882afc5045c73" ON "time_off_request" ("policyId") `); } -} \ No newline at end of file +} diff --git a/packages/core/src/database/migrations/1652703299052-AlterTaskTableColumns.ts b/packages/core/src/database/migrations/1652703299052-AlterTaskTableColumns.ts index 6823c5d36da..0aee8568ca1 100644 --- a/packages/core/src/database/migrations/1652703299052-AlterTaskTableColumns.ts +++ b/packages/core/src/database/migrations/1652703299052-AlterTaskTableColumns.ts @@ -5,7 +5,7 @@ export class AlterTaskTableColumns1652703299052 implements MigrationInterface { name = 'AlterTaskTableColumns1652703299052'; public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -13,7 +13,7 @@ export class AlterTaskTableColumns1652703299052 implements MigrationInterface { } public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); @@ -22,8 +22,8 @@ export class AlterTaskTableColumns1652703299052 implements MigrationInterface { /** * PostgresDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "task" ADD "number" integer`); @@ -33,8 +33,8 @@ export class AlterTaskTableColumns1652703299052 implements MigrationInterface { /** * PostgresDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "public"."taskNumber"`); @@ -44,8 +44,8 @@ export class AlterTaskTableColumns1652703299052 implements MigrationInterface { /** * SqliteDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_e91cbff3d206f150ccc14d0c3a"`); @@ -67,8 +67,8 @@ export class AlterTaskTableColumns1652703299052 implements MigrationInterface { /** * SqliteDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "taskNumber"`); @@ -87,4 +87,4 @@ export class AlterTaskTableColumns1652703299052 implements MigrationInterface { await queryRunner.query(`CREATE INDEX "IDX_5b0272d923a31c972bed1a1ac4" ON "task" ("organizationId") `); await queryRunner.query(`CREATE INDEX "IDX_e91cbff3d206f150ccc14d0c3a" ON "task" ("tenantId") `); } -} \ No newline at end of file +} diff --git a/packages/core/src/database/migrations/1652936174625-ReportTableIconSeed.ts b/packages/core/src/database/migrations/1652936174625-ReportTableIconSeed.ts index c5645c58f8a..0b4b1240f48 100644 --- a/packages/core/src/database/migrations/1652936174625-ReportTableIconSeed.ts +++ b/packages/core/src/database/migrations/1652936174625-ReportTableIconSeed.ts @@ -5,30 +5,60 @@ export class ReportTableIconSeed1652936174625 implements MigrationInterface { name = 'ReportTableIconSeed1652936174625'; public async up(queryRunner: QueryRunner): Promise { - await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['far fa-clock', 'time-activity']); - await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['fas fa-calendar-alt', 'weekly']); - await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['far fa-window-maximize', 'apps-urls']); - await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['far fa-window-maximize', 'manual-time-edits']); - await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['far fa-credit-card', 'expense']); - await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['far fa-credit-card', 'amounts-owed']); - await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['far fa-credit-card', 'payments']); - await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['far fa-clock', 'weekly-limits']); - await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['far fa-clock', 'daily-limits']); - await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['far fa-credit-card', 'project-budgets']); - await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['far fa-credit-card', 'client-budgets']); + const isSqlite = ['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type); + if (isSqlite) { + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = ? WHERE "slug" = ?`, ['far fa-clock', 'time-activity']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = ? WHERE "slug" = ?`, ['fas fa-calendar-alt', 'weekly']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = ? WHERE "slug" = ?`, ['far fa-window-maximize', 'apps-urls']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = ? WHERE "slug" = ?`, ['far fa-window-maximize', 'manual-time-edits']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = ? WHERE "slug" = ?`, ['far fa-credit-card', 'expense']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = ? WHERE "slug" = ?`, ['far fa-credit-card', 'amounts-owed']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = ? WHERE "slug" = ?`, ['far fa-credit-card', 'payments']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = ? WHERE "slug" = ?`, ['far fa-clock', 'weekly-limits']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = ? WHERE "slug" = ?`, ['far fa-clock', 'daily-limits']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = ? WHERE "slug" = ?`, ['far fa-credit-card', 'project-budgets']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = ? WHERE "slug" = ?`, ['far fa-credit-card', 'client-budgets']); + } else { + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['far fa-clock', 'time-activity']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['fas fa-calendar-alt', 'weekly']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['far fa-window-maximize', 'apps-urls']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['far fa-window-maximize', 'manual-time-edits']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['far fa-credit-card', 'expense']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['far fa-credit-card', 'amounts-owed']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['far fa-credit-card', 'payments']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['far fa-clock', 'weekly-limits']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['far fa-clock', 'daily-limits']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['far fa-credit-card', 'project-budgets']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['far fa-credit-card', 'client-budgets']); + } } public async down(queryRunner: QueryRunner): Promise { - await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['clock-outline', 'time-activity']); - await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['calendar-outline', 'weekly']); - await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['browser-outline', 'apps-urls']); - await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['browser-outline', 'manual-time-edits']); - await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['credit-card-outline', 'expense']); - await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['credit-card-outline', 'amounts-owed']); - await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['credit-card-outline', 'payments']); - await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['clock-outline', 'weekly-limits']); - await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['clock-outline', 'daily-limits']); - await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['credit-card-outline', 'project-budgets']); - await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['credit-card-outline', 'client-budgets']); + const isSqlite = ['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type); + if (isSqlite) { + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = ? WHERE "slug" = ?`, ['clock-outline', 'time-activity']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = ? WHERE "slug" = ?`, ['calendar-outline', 'weekly']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = ? WHERE "slug" = ?`, ['browser-outline', 'apps-urls']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = ? WHERE "slug" = ?`, ['browser-outline', 'manual-time-edits']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = ? WHERE "slug" = ?`, ['credit-card-outline', 'expense']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = ? WHERE "slug" = ?`, ['credit-card-outline', 'amounts-owed']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = ? WHERE "slug" = ?`, ['credit-card-outline', 'payments']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = ? WHERE "slug" = ?`, ['clock-outline', 'weekly-limits']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = ? WHERE "slug" = ?`, ['clock-outline', 'daily-limits']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = ? WHERE "slug" = ?`, ['credit-card-outline', 'project-budgets']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = ? WHERE "slug" = ?`, ['credit-card-outline', 'client-budgets']); + } else { + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['clock-outline', 'time-activity']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['calendar-outline', 'weekly']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['browser-outline', 'apps-urls']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['browser-outline', 'manual-time-edits']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['credit-card-outline', 'expense']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['credit-card-outline', 'amounts-owed']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['credit-card-outline', 'payments']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['clock-outline', 'weekly-limits']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['clock-outline', 'daily-limits']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['credit-card-outline', 'project-budgets']); + await queryRunner.connection.query(`UPDATE "report" SET "iconClass" = $1 WHERE "slug" = $2`, ['credit-card-outline', 'client-budgets']); + } } -} \ No newline at end of file +} diff --git a/packages/core/src/database/migrations/1653482244724-AlterExpenseTable.ts b/packages/core/src/database/migrations/1653482244724-AlterExpenseTable.ts index 4052186f60f..8b5c7977373 100644 --- a/packages/core/src/database/migrations/1653482244724-AlterExpenseTable.ts +++ b/packages/core/src/database/migrations/1653482244724-AlterExpenseTable.ts @@ -5,7 +5,7 @@ export class AlterExpenseTable1653482244724 implements MigrationInterface { name = 'AlterExpenseTable1653482244724'; public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -13,7 +13,7 @@ export class AlterExpenseTable1653482244724 implements MigrationInterface { } public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); @@ -22,8 +22,8 @@ export class AlterExpenseTable1653482244724 implements MigrationInterface { /** * PostgresDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "expense" DROP CONSTRAINT "FK_eacb116ab0521ad9b96f2bb53ba"`); @@ -40,8 +40,8 @@ export class AlterExpenseTable1653482244724 implements MigrationInterface { /** * PostgresDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "expense" DROP CONSTRAINT "FK_42eea5debc63f4d1bf89881c10a"`); @@ -58,15 +58,15 @@ export class AlterExpenseTable1653482244724 implements MigrationInterface { /** * SqliteDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteUpQueryRunner(queryRunner: QueryRunner): Promise {} /** * SqliteDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteDownQueryRunner(queryRunner: QueryRunner): Promise {} -} \ No newline at end of file +} diff --git a/packages/core/src/database/migrations/1653742570167-AlterOrganizationContactTable.ts b/packages/core/src/database/migrations/1653742570167-AlterOrganizationContactTable.ts index 4a8ae6d3e3a..ed69fd2e046 100644 --- a/packages/core/src/database/migrations/1653742570167-AlterOrganizationContactTable.ts +++ b/packages/core/src/database/migrations/1653742570167-AlterOrganizationContactTable.ts @@ -5,7 +5,7 @@ export class AlterOrganizationContactTable1653742570167 implements MigrationInte name = 'AlterOrganizationContactTable1653742570167'; public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -13,7 +13,7 @@ export class AlterOrganizationContactTable1653742570167 implements MigrationInte } public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); @@ -22,8 +22,8 @@ export class AlterOrganizationContactTable1653742570167 implements MigrationInte /** * PostgresDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "organization_contact" DROP COLUMN "inviteStatus"`); @@ -39,8 +39,8 @@ export class AlterOrganizationContactTable1653742570167 implements MigrationInte /** * PostgresDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "organization_contact" DROP COLUMN "budgetType"`); @@ -56,8 +56,8 @@ export class AlterOrganizationContactTable1653742570167 implements MigrationInte /** * SqliteDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_a86d2e378b953cb39261f457d2"`); @@ -88,8 +88,8 @@ export class AlterOrganizationContactTable1653742570167 implements MigrationInte /** * SqliteDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_e68c43e315ad3aaea4e99cf461"`); @@ -103,7 +103,7 @@ export class AlterOrganizationContactTable1653742570167 implements MigrationInte await queryRunner.query(`CREATE INDEX "IDX_e68c43e315ad3aaea4e99cf461" ON "organization_contact" ("tenantId") `); await queryRunner.query(`CREATE INDEX "IDX_6200736cb4d3617b004e5b647f" ON "organization_contact" ("organizationId") `); await queryRunner.query(`CREATE INDEX "IDX_de33f92e042365d196d959e774" ON "organization_contact" ("name") `); - await queryRunner.query(`CREATE INDEX "IDX_a86d2e378b953cb39261f457d2" ON "organization_contact" ("contactId") `); + await queryRunner.query(`CREATE INDEX "IDX_a86d2e378b953cb39261f457d2" ON "organization_contact" ("contactId") `); await queryRunner.query(`DROP INDEX "IDX_e68c43e315ad3aaea4e99cf461"`); await queryRunner.query(`DROP INDEX "IDX_6200736cb4d3617b004e5b647f"`); await queryRunner.query(`DROP INDEX "IDX_de33f92e042365d196d959e774"`); @@ -117,4 +117,4 @@ export class AlterOrganizationContactTable1653742570167 implements MigrationInte await queryRunner.query(`CREATE INDEX "IDX_de33f92e042365d196d959e774" ON "organization_contact" ("name") `); await queryRunner.query(`CREATE INDEX "IDX_a86d2e378b953cb39261f457d2" ON "organization_contact" ("contactId") `); } -} \ No newline at end of file +} diff --git a/packages/core/src/database/migrations/1654675304373-SeedChangeLogFeature.ts b/packages/core/src/database/migrations/1654675304373-SeedChangeLogFeature.ts index 7e5a06be341..2d1818b1e73 100644 --- a/packages/core/src/database/migrations/1654675304373-SeedChangeLogFeature.ts +++ b/packages/core/src/database/migrations/1654675304373-SeedChangeLogFeature.ts @@ -6,11 +6,12 @@ export class SeedChangeLogFeature1654675304373 implements MigrationInterface { name = 'SeedChangeLogFeature1654675304373'; public async up(queryRunner: QueryRunner): Promise { + const date = ['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type) ? Date.now() : new Date(); const features = [ { icon: 'cube-outline', title: 'New CRM', - date: new Date(), + date, isFeature: true, content: 'Now you can read latest features changelog directly in Gauzy', learnMoreUrl: '', @@ -19,7 +20,7 @@ export class SeedChangeLogFeature1654675304373 implements MigrationInterface { { icon: 'globe-outline', title: 'Most popular in 20 countries', - date: new Date(), + date, isFeature: true, content: 'Europe, Americas and Asia get choise', learnMoreUrl: '', @@ -28,7 +29,7 @@ export class SeedChangeLogFeature1654675304373 implements MigrationInterface { { icon: 'flash-outline', title: 'Visit our website', - date: new Date(), + date, isFeature: true, content: 'You are welcome to check more information about the platform at our official website.', learnMoreUrl: '', @@ -38,10 +39,10 @@ export class SeedChangeLogFeature1654675304373 implements MigrationInterface { try { for await (const feature of features) { const payload = Object.values(feature); - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { payload.push(uuidV4()); await queryRunner.connection.manager.query(` - INSERT INTO "changelog" ("icon", "title", "date", "isFeature", "content", "learnMoreUrl", "imageUrl", "id") VALUES($1, $2, $3, $4, $5, $6, $7, $8)`, + INSERT INTO "changelog" ("icon", "title", "date", "isFeature", "content", "learnMoreUrl", "imageUrl", "id") VALUES(?, ?, ?, ?, ?, ?, ?, ?)`, payload ); } else { @@ -58,6 +59,6 @@ export class SeedChangeLogFeature1654675304373 implements MigrationInterface { } public async down(queryRunner: QueryRunner): Promise { - + } -} \ No newline at end of file +} diff --git a/packages/core/src/database/migrations/1655885355508-OrganizationProjectAlterTable.ts b/packages/core/src/database/migrations/1655885355508-OrganizationProjectAlterTable.ts index 6f33d93334c..f4ebc0e0206 100644 --- a/packages/core/src/database/migrations/1655885355508-OrganizationProjectAlterTable.ts +++ b/packages/core/src/database/migrations/1655885355508-OrganizationProjectAlterTable.ts @@ -5,7 +5,7 @@ export class OrganizationProjectAlterTable1655885355508 implements MigrationInte name = 'OrganizationProjectAlterTable1655885355508'; public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -13,7 +13,7 @@ export class OrganizationProjectAlterTable1655885355508 implements MigrationInte } public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); @@ -22,8 +22,8 @@ export class OrganizationProjectAlterTable1655885355508 implements MigrationInte /** * PostgresDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "organization_project" ADD "imageUrl" character varying(500)`); @@ -31,8 +31,8 @@ export class OrganizationProjectAlterTable1655885355508 implements MigrationInte /** * PostgresDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async postgresDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "organization_project" DROP COLUMN "imageUrl"`); @@ -40,8 +40,8 @@ export class OrganizationProjectAlterTable1655885355508 implements MigrationInte /** * SqliteDB Up Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteUpQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_7cf84e8b5775f349f81a1f3cc4"`); @@ -62,8 +62,8 @@ export class OrganizationProjectAlterTable1655885355508 implements MigrationInte /** * SqliteDB Down Migration - * - * @param queryRunner + * + * @param queryRunner */ public async sqliteDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX "IDX_bc1e32c13683dbb16ada1c6da1"`); @@ -81,4 +81,4 @@ export class OrganizationProjectAlterTable1655885355508 implements MigrationInte await queryRunner.query(`CREATE INDEX "IDX_9d8afc1e1e64d4b7d48dd2229d" ON "organization_project" ("organizationId") `); await queryRunner.query(`CREATE INDEX "IDX_7cf84e8b5775f349f81a1f3cc4" ON "organization_project" ("tenantId") `); } -} \ No newline at end of file +} diff --git a/packages/core/src/database/migrations/1656833636109-AlterUserTable.ts b/packages/core/src/database/migrations/1656833636109-AlterUserTable.ts index 70417d814ce..78a81817570 100644 --- a/packages/core/src/database/migrations/1656833636109-AlterUserTable.ts +++ b/packages/core/src/database/migrations/1656833636109-AlterUserTable.ts @@ -5,7 +5,7 @@ export class AlterUserTable1656833636109 implements MigrationInterface { name = 'AlterUserTable1656833636109'; public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -13,7 +13,7 @@ export class AlterUserTable1656833636109 implements MigrationInterface { } public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); @@ -135,4 +135,4 @@ export class AlterUserTable1656833636109 implements MigrationInterface { await queryRunner.query(`CREATE INDEX "IDX_78a916df40e02a9deb1c4b75ed" ON "user" ("username") `); await queryRunner.query(`CREATE INDEX "IDX_c28e52f758e7bbc53828db9219" ON "user" ("roleId") `); } -} \ No newline at end of file +} diff --git a/packages/core/src/database/migrations/1659618978087-AlterInvoiceEstimateHistory.ts b/packages/core/src/database/migrations/1659618978087-AlterInvoiceEstimateHistory.ts index e4be2d2d4f0..cfb0698d4a0 100644 --- a/packages/core/src/database/migrations/1659618978087-AlterInvoiceEstimateHistory.ts +++ b/packages/core/src/database/migrations/1659618978087-AlterInvoiceEstimateHistory.ts @@ -5,7 +5,7 @@ export class AlterInvoiceEstimateHistory1659618978087 implements MigrationInterf name = 'AlterInvoiceEstimateHistory1659618978087'; public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -13,7 +13,7 @@ export class AlterInvoiceEstimateHistory1659618978087 implements MigrationInterf } public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); @@ -154,4 +154,4 @@ export class AlterInvoiceEstimateHistory1659618978087 implements MigrationInterf await queryRunner.query(`CREATE INDEX "IDX_da2893697d57368470952a76f6" ON "invoice_estimate_history" ("userId") `); await queryRunner.query(`CREATE INDEX "IDX_31ec3d5a6b0985cec544c64217" ON "invoice_estimate_history" ("invoiceId") `); } -} \ No newline at end of file +} diff --git a/packages/core/src/database/migrations/1659684413063-AlterContactTable.ts b/packages/core/src/database/migrations/1659684413063-AlterContactTable.ts index a7f4c2d97d9..42743a85f01 100644 --- a/packages/core/src/database/migrations/1659684413063-AlterContactTable.ts +++ b/packages/core/src/database/migrations/1659684413063-AlterContactTable.ts @@ -5,7 +5,7 @@ export class AlterContactTable1659684413063 implements MigrationInterface { name = 'AlterContactTable1659684413063'; public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -13,7 +13,7 @@ export class AlterContactTable1659684413063 implements MigrationInterface { } public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); @@ -75,4 +75,4 @@ export class AlterContactTable1659684413063 implements MigrationInterface { await queryRunner.query(`CREATE INDEX "IDX_60468af1ce34043a900809c84f" ON "contact" ("tenantId") `); await queryRunner.query(`CREATE INDEX "IDX_7719d73cd16a9f57ecc6ac24b3" ON "contact" ("organizationId") `); } -} \ No newline at end of file +} diff --git a/packages/core/src/database/migrations/1659696180759-AlterTenantTable.ts b/packages/core/src/database/migrations/1659696180759-AlterTenantTable.ts index 72d37c17f58..b9ba7321ae0 100644 --- a/packages/core/src/database/migrations/1659696180759-AlterTenantTable.ts +++ b/packages/core/src/database/migrations/1659696180759-AlterTenantTable.ts @@ -5,7 +5,7 @@ export class AlterTenantTable1659696180759 implements MigrationInterface { name = 'AlterTenantTable1659696180759'; public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -13,7 +13,7 @@ export class AlterTenantTable1659696180759 implements MigrationInterface { } public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); @@ -51,4 +51,4 @@ export class AlterTenantTable1659696180759 implements MigrationInterface { public async sqliteDownQueryRunner(queryRunner: QueryRunner): Promise { await queryRunner.query(`CREATE INDEX "IDX_3062637d94040b8a277c5e6367" ON "tenant" ("logo") `); } -} \ No newline at end of file +} diff --git a/packages/core/src/database/migrations/1660988196279-AlterWarehouseProductTable.ts b/packages/core/src/database/migrations/1660988196279-AlterWarehouseProductTable.ts index 3122fdc71a6..79c69965364 100644 --- a/packages/core/src/database/migrations/1660988196279-AlterWarehouseProductTable.ts +++ b/packages/core/src/database/migrations/1660988196279-AlterWarehouseProductTable.ts @@ -11,7 +11,7 @@ export class AlterWarehouseProductTable1660988196279 implements MigrationInterfa * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterWarehouseProductTable1660988196279 implements MigrationInterfa * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1661599336316-AlterWarehouseMerchant.ts b/packages/core/src/database/migrations/1661599336316-AlterWarehouseMerchant.ts index 86c9f25e3f8..06355e75439 100644 --- a/packages/core/src/database/migrations/1661599336316-AlterWarehouseMerchant.ts +++ b/packages/core/src/database/migrations/1661599336316-AlterWarehouseMerchant.ts @@ -11,7 +11,7 @@ export class AlterWarehouseMerchant1661599336316 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterWarehouseMerchant1661599336316 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1661853087396-AlterTimesheetTable.ts b/packages/core/src/database/migrations/1661853087396-AlterTimesheetTable.ts index ea2f3101912..9fc858979dd 100644 --- a/packages/core/src/database/migrations/1661853087396-AlterTimesheetTable.ts +++ b/packages/core/src/database/migrations/1661853087396-AlterTimesheetTable.ts @@ -11,7 +11,7 @@ export class AlterTimesheetTable1661853087396 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterTimesheetTable1661853087396 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1662994539197-AlterInvoiceTable.ts b/packages/core/src/database/migrations/1662994539197-AlterInvoiceTable.ts index 96b9b7da87b..79f96fc3f7b 100644 --- a/packages/core/src/database/migrations/1662994539197-AlterInvoiceTable.ts +++ b/packages/core/src/database/migrations/1662994539197-AlterInvoiceTable.ts @@ -11,7 +11,7 @@ export class AlterInvoiceTable1662994539197 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterInvoiceTable1662994539197 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1664869127437-AlterCandidateFeedbackTable.ts b/packages/core/src/database/migrations/1664869127437-AlterCandidateFeedbackTable.ts index dd2d616b275..8d89b6ad28d 100644 --- a/packages/core/src/database/migrations/1664869127437-AlterCandidateFeedbackTable.ts +++ b/packages/core/src/database/migrations/1664869127437-AlterCandidateFeedbackTable.ts @@ -11,7 +11,7 @@ export class AlterCandidateFeedbackTable1664869127437 implements MigrationInterf * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterCandidateFeedbackTable1664869127437 implements MigrationInterf * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1665044607000-AlterCandidateInterviewTable.ts b/packages/core/src/database/migrations/1665044607000-AlterCandidateInterviewTable.ts index f5e25e4586e..9b30f411ec7 100644 --- a/packages/core/src/database/migrations/1665044607000-AlterCandidateInterviewTable.ts +++ b/packages/core/src/database/migrations/1665044607000-AlterCandidateInterviewTable.ts @@ -11,7 +11,7 @@ export class AlterCandidateInterviewTable1665044607000 implements MigrationInter * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterCandidateInterviewTable1665044607000 implements MigrationInter * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1665388204010-AlterWarehouseTable.ts b/packages/core/src/database/migrations/1665388204010-AlterWarehouseTable.ts index dae2c3a8006..458d1c7e1e0 100644 --- a/packages/core/src/database/migrations/1665388204010-AlterWarehouseTable.ts +++ b/packages/core/src/database/migrations/1665388204010-AlterWarehouseTable.ts @@ -11,7 +11,7 @@ export class AlterWarehouseTable1665388204010 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterWarehouseTable1665388204010 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1665399395983-AlterOrganizationTable.ts b/packages/core/src/database/migrations/1665399395983-AlterOrganizationTable.ts index e6682b681bf..1596755ae7d 100644 --- a/packages/core/src/database/migrations/1665399395983-AlterOrganizationTable.ts +++ b/packages/core/src/database/migrations/1665399395983-AlterOrganizationTable.ts @@ -11,7 +11,7 @@ export class AlterOrganizationTable1665399395983 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterOrganizationTable1665399395983 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1665767813286-AltereInviteTable.ts b/packages/core/src/database/migrations/1665767813286-AltereInviteTable.ts index 1cbb484c0d4..5d973123799 100644 --- a/packages/core/src/database/migrations/1665767813286-AltereInviteTable.ts +++ b/packages/core/src/database/migrations/1665767813286-AltereInviteTable.ts @@ -11,7 +11,7 @@ export class AltereInviteTable1665767813286 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AltereInviteTable1665767813286 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1666007548644-AlterEmployeeTable.ts b/packages/core/src/database/migrations/1666007548644-AlterEmployeeTable.ts index 21c4e1e0411..a5f46134a96 100644 --- a/packages/core/src/database/migrations/1666007548644-AlterEmployeeTable.ts +++ b/packages/core/src/database/migrations/1666007548644-AlterEmployeeTable.ts @@ -11,7 +11,7 @@ export class AlterEmployeeTable1666007548644 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterEmployeeTable1666007548644 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); @@ -98,4 +98,4 @@ export class AlterEmployeeTable1666007548644 implements MigrationInterface { await queryRunner.query(`CREATE INDEX "IDX_c34e79a3aa682bbd3f0e8cf4c4" ON "organization_department_employee" ("organizationDepartmentId") `); await queryRunner.query(`CREATE INDEX "IDX_0d4f83695591ae3c98a0544ac8" ON "organization_department_employee" ("employeeId") `); } -} \ No newline at end of file +} diff --git a/packages/core/src/database/migrations/1666181221327-AlterOrganizationTable.ts b/packages/core/src/database/migrations/1666181221327-AlterOrganizationTable.ts index ed7888d3ca0..161df4c1e72 100644 --- a/packages/core/src/database/migrations/1666181221327-AlterOrganizationTable.ts +++ b/packages/core/src/database/migrations/1666181221327-AlterOrganizationTable.ts @@ -11,7 +11,7 @@ export class AlterOrganizationTable1666181221327 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterOrganizationTable1666181221327 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1666780716428-AlterEmployeeTable.ts b/packages/core/src/database/migrations/1666780716428-AlterEmployeeTable.ts index a9b6109cff2..45a6e55c0ca 100644 --- a/packages/core/src/database/migrations/1666780716428-AlterEmployeeTable.ts +++ b/packages/core/src/database/migrations/1666780716428-AlterEmployeeTable.ts @@ -11,7 +11,7 @@ export class AlterEmployeeTable1666780716428 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterEmployeeTable1666780716428 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); @@ -94,6 +94,6 @@ export class AlterEmployeeTable1666780716428 implements MigrationInterface { await queryRunner.query(`CREATE INDEX "IDX_f4b0d329c4a3cf79ffe9d56504" ON "employee" ("userId") `); await queryRunner.query(`CREATE INDEX "IDX_96dfbcaa2990df01fe5bb39ccc" ON "employee" ("profile_link") `); await queryRunner.query(`CREATE INDEX "IDX_c6a48286f3aa8ae903bee0d1e7" ON "employee" ("organizationId") `); - await queryRunner.query(`CREATE INDEX "IDX_4b3303a6b7eb92d237a4379734" ON "employee" ("tenantId") `); + await queryRunner.query(`CREATE INDEX "IDX_4b3303a6b7eb92d237a4379734" ON "employee" ("tenantId") `); } } diff --git a/packages/core/src/database/migrations/1668064327561-AlterOrganizationTable.ts b/packages/core/src/database/migrations/1668064327561-AlterOrganizationTable.ts index 9d5c4d5c6e7..cc641c39406 100644 --- a/packages/core/src/database/migrations/1668064327561-AlterOrganizationTable.ts +++ b/packages/core/src/database/migrations/1668064327561-AlterOrganizationTable.ts @@ -11,7 +11,7 @@ export class AlterOrganizationTable1668064327561 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterOrganizationTable1668064327561 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1668084518509-AlterEmployeeTableColumns.ts b/packages/core/src/database/migrations/1668084518509-AlterEmployeeTableColumns.ts index 8f817b7ff7b..20cb17ab3f6 100644 --- a/packages/core/src/database/migrations/1668084518509-AlterEmployeeTableColumns.ts +++ b/packages/core/src/database/migrations/1668084518509-AlterEmployeeTableColumns.ts @@ -11,7 +11,7 @@ export class AlterEmployeeTableColumns1668084518509 implements MigrationInterfac * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterEmployeeTableColumns1668084518509 implements MigrationInterfac * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1668256889786-AlterCustomSmtpTable.ts b/packages/core/src/database/migrations/1668256889786-AlterCustomSmtpTable.ts index 4aa5e61a9bd..d46d0cb7fc5 100644 --- a/packages/core/src/database/migrations/1668256889786-AlterCustomSmtpTable.ts +++ b/packages/core/src/database/migrations/1668256889786-AlterCustomSmtpTable.ts @@ -11,7 +11,7 @@ export class AlterCustomSmtpTable1668256889786 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterCustomSmtpTable1668256889786 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1668446646237-AlterTableRelationCascading.ts b/packages/core/src/database/migrations/1668446646237-AlterTableRelationCascading.ts index 3bd02ce872b..81dee5ec6ab 100644 --- a/packages/core/src/database/migrations/1668446646237-AlterTableRelationCascading.ts +++ b/packages/core/src/database/migrations/1668446646237-AlterTableRelationCascading.ts @@ -11,7 +11,7 @@ export class AlterTableRelationCascading1668446646237 implements MigrationInterf * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterTableRelationCascading1668446646237 implements MigrationInterf * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1668502997873-AlterUserTable.ts b/packages/core/src/database/migrations/1668502997873-AlterUserTable.ts index cf5a471a4ad..6a8c2f8e75d 100644 --- a/packages/core/src/database/migrations/1668502997873-AlterUserTable.ts +++ b/packages/core/src/database/migrations/1668502997873-AlterUserTable.ts @@ -11,7 +11,7 @@ export class AlterUserTable1668502997873 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterUserTable1668502997873 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1668504932478-AlterTableRelationCascading.ts b/packages/core/src/database/migrations/1668504932478-AlterTableRelationCascading.ts index 16402e35be2..fe8ae9de9f9 100644 --- a/packages/core/src/database/migrations/1668504932478-AlterTableRelationCascading.ts +++ b/packages/core/src/database/migrations/1668504932478-AlterTableRelationCascading.ts @@ -11,7 +11,7 @@ export class AlterTableRelationCascading1668504932478 implements MigrationInterf * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterTableRelationCascading1668504932478 implements MigrationInterf * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1669033406667-AlterUserTableEmailVerificationColumns.ts b/packages/core/src/database/migrations/1669033406667-AlterUserTableEmailVerificationColumns.ts index 4b0beb5ec0d..1885755bee0 100644 --- a/packages/core/src/database/migrations/1669033406667-AlterUserTableEmailVerificationColumns.ts +++ b/packages/core/src/database/migrations/1669033406667-AlterUserTableEmailVerificationColumns.ts @@ -11,7 +11,7 @@ export class AlterUserTableEmailVerificationColumns1669033406667 implements Migr * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterUserTableEmailVerificationColumns1669033406667 implements Migr * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1669280426592-AlterInviteTable.ts b/packages/core/src/database/migrations/1669280426592-AlterInviteTable.ts index 12a5dc396fc..a33b70906c7 100644 --- a/packages/core/src/database/migrations/1669280426592-AlterInviteTable.ts +++ b/packages/core/src/database/migrations/1669280426592-AlterInviteTable.ts @@ -11,7 +11,7 @@ export class AlterInviteTable1669280426592 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterInviteTable1669280426592 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1669453028914-AlterUserInviteTable.ts b/packages/core/src/database/migrations/1669453028914-AlterUserInviteTable.ts index 8efd59212e0..3747f255539 100644 --- a/packages/core/src/database/migrations/1669453028914-AlterUserInviteTable.ts +++ b/packages/core/src/database/migrations/1669453028914-AlterUserInviteTable.ts @@ -11,7 +11,7 @@ export class AlterUserInviteTable1669453028914 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterUserInviteTable1669453028914 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1670313962263-AlterOrganizationTeamTable.ts b/packages/core/src/database/migrations/1670313962263-AlterOrganizationTeamTable.ts index a49cd9bbbe3..a0a2a66f0c2 100644 --- a/packages/core/src/database/migrations/1670313962263-AlterOrganizationTeamTable.ts +++ b/packages/core/src/database/migrations/1670313962263-AlterOrganizationTeamTable.ts @@ -11,7 +11,7 @@ export class AlterOrganizationTeamTable1670313962263 implements MigrationInterfa * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterOrganizationTeamTable1670313962263 implements MigrationInterfa * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1671107860058-AlterInviteAllowedOrganizationTable.ts b/packages/core/src/database/migrations/1671107860058-AlterInviteAllowedOrganizationTable.ts index 497bb0ca11e..c2a75400495 100644 --- a/packages/core/src/database/migrations/1671107860058-AlterInviteAllowedOrganizationTable.ts +++ b/packages/core/src/database/migrations/1671107860058-AlterInviteAllowedOrganizationTable.ts @@ -11,7 +11,7 @@ export class AlterInviteAllowedOrganizationTable1671107860058 implements Migrati * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterInviteAllowedOrganizationTable1671107860058 implements Migrati * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1671706727549-AlterOrganizationTeamTable.ts b/packages/core/src/database/migrations/1671706727549-AlterOrganizationTeamTable.ts index 93a90c4626c..6b6d051c36e 100644 --- a/packages/core/src/database/migrations/1671706727549-AlterOrganizationTeamTable.ts +++ b/packages/core/src/database/migrations/1671706727549-AlterOrganizationTeamTable.ts @@ -11,7 +11,7 @@ export class AlterOrganizationTeamTable1671706727549 implements MigrationInterfa * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterOrganizationTeamTable1671706727549 implements MigrationInterfa * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1672211594766-AlterCandidateTable.ts b/packages/core/src/database/migrations/1672211594766-AlterCandidateTable.ts index 0ecd8fbb33f..67ce8269da8 100644 --- a/packages/core/src/database/migrations/1672211594766-AlterCandidateTable.ts +++ b/packages/core/src/database/migrations/1672211594766-AlterCandidateTable.ts @@ -11,7 +11,7 @@ export class AlterCandidateTable1672211594766 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterCandidateTable1672211594766 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1673005639130-AlterTimeLogTable.ts b/packages/core/src/database/migrations/1673005639130-AlterTimeLogTable.ts index b187fc3ee74..43bbcf8741f 100644 --- a/packages/core/src/database/migrations/1673005639130-AlterTimeLogTable.ts +++ b/packages/core/src/database/migrations/1673005639130-AlterTimeLogTable.ts @@ -11,7 +11,7 @@ export class AlterTimeLogTable1673005639130 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterTimeLogTable1673005639130 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1673423542165-AlterTaskTable.ts b/packages/core/src/database/migrations/1673423542165-AlterTaskTable.ts index a5e3ae4473c..9f04d53f641 100644 --- a/packages/core/src/database/migrations/1673423542165-AlterTaskTable.ts +++ b/packages/core/src/database/migrations/1673423542165-AlterTaskTable.ts @@ -11,7 +11,7 @@ export class AlterTaskTable1673423542165 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterTaskTable1673423542165 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1673589923548-CreateStatusTable.ts b/packages/core/src/database/migrations/1673589923548-CreateStatusTable.ts index 922796db43c..67b58301692 100644 --- a/packages/core/src/database/migrations/1673589923548-CreateStatusTable.ts +++ b/packages/core/src/database/migrations/1673589923548-CreateStatusTable.ts @@ -9,7 +9,7 @@ export class CreateStatusTable1673589923548 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -22,7 +22,7 @@ export class CreateStatusTable1673589923548 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1673946248066-AlterTaskTable.ts b/packages/core/src/database/migrations/1673946248066-AlterTaskTable.ts index 8acfbf8df63..f29d2c84a60 100644 --- a/packages/core/src/database/migrations/1673946248066-AlterTaskTable.ts +++ b/packages/core/src/database/migrations/1673946248066-AlterTaskTable.ts @@ -11,7 +11,7 @@ export class AlterTaskTable1673946248066 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterTaskTable1673946248066 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1674044473393-SeedDefaultGlobalTaskStatus.ts b/packages/core/src/database/migrations/1674044473393-SeedDefaultGlobalTaskStatus.ts index adcf2e34940..8e901d0d3e3 100644 --- a/packages/core/src/database/migrations/1674044473393-SeedDefaultGlobalTaskStatus.ts +++ b/packages/core/src/database/migrations/1674044473393-SeedDefaultGlobalTaskStatus.ts @@ -16,9 +16,9 @@ export class SeedDefaultGlobalTaskStatus1674044473393 implements MigrationInterf try { for await (const status of DEFAULT_GLOBAL_STATUSES) { const payload = Object.values(status); - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { payload.push(uuidV4()); - const query = `INSERT INTO "status" ("name", "value", "description", "icon", "color", "isSystem", "id") VALUES($1, $2, $3, $4, $5, $6, $7)`; + const query = `INSERT INTO "status" ("name", "value", "description", "icon", "color", "isSystem", "id") VALUES(?, ?, ?, ?, ?, ?, ?)`; await queryRunner.connection.manager.query(query, payload); } else { const query = `INSERT INTO "status" ("name", "value", "description", "icon", "color", "isSystem") VALUES($1, $2, $3, $4, $5, $6)`; diff --git a/packages/core/src/database/migrations/1674109138954-AlterEmailSentTable.ts b/packages/core/src/database/migrations/1674109138954-AlterEmailSentTable.ts index 6178cd820e0..1cd078988be 100644 --- a/packages/core/src/database/migrations/1674109138954-AlterEmailSentTable.ts +++ b/packages/core/src/database/migrations/1674109138954-AlterEmailSentTable.ts @@ -11,7 +11,7 @@ export class AlterEmailSentTable1674109138954 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterEmailSentTable1674109138954 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1674535367176-CreateTaskPriorityTable.ts b/packages/core/src/database/migrations/1674535367176-CreateTaskPriorityTable.ts index 9517f63625a..7f459e0664c 100644 --- a/packages/core/src/database/migrations/1674535367176-CreateTaskPriorityTable.ts +++ b/packages/core/src/database/migrations/1674535367176-CreateTaskPriorityTable.ts @@ -11,7 +11,7 @@ export class CreateTaskPriorityTable1674535367176 implements MigrationInterface * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class CreateTaskPriorityTable1674535367176 implements MigrationInterface * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1674538040466-CreateTaskSizeTable.ts b/packages/core/src/database/migrations/1674538040466-CreateTaskSizeTable.ts index 0f5c2eab970..44842f206c4 100644 --- a/packages/core/src/database/migrations/1674538040466-CreateTaskSizeTable.ts +++ b/packages/core/src/database/migrations/1674538040466-CreateTaskSizeTable.ts @@ -11,7 +11,7 @@ export class CreateTaskSizeTable1674538040466 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class CreateTaskSizeTable1674538040466 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1674638501088-SeedDefaultGlobalTaskPriorityAndSize.ts b/packages/core/src/database/migrations/1674638501088-SeedDefaultGlobalTaskPriorityAndSize.ts index 702a73889a3..1cfb0475e90 100644 --- a/packages/core/src/database/migrations/1674638501088-SeedDefaultGlobalTaskPriorityAndSize.ts +++ b/packages/core/src/database/migrations/1674638501088-SeedDefaultGlobalTaskPriorityAndSize.ts @@ -34,9 +34,9 @@ export class SeedDefaultGlobalTaskPriorityAndSize1674638501088 implements Migrat try { for await (const priority of DEFAULT_GLOBAL_PRIORITIES) { const payload = Object.values(priority); - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { payload.push(uuidV4()); - const query = `INSERT INTO "task_priority" ("name", "value", "description", "icon", "color", "isSystem", "id") VALUES($1, $2, $3, $4, $5, $6, $7)`; + const query = `INSERT INTO "task_priority" ("name", "value", "description", "icon", "color", "isSystem", "id") VALUES(?, ?, ?, ?, ?, ?, ?)`; await queryRunner.connection.manager.query(query, payload); } else { const query = `INSERT INTO "task_priority" ("name", "value", "description", "icon", "color", "isSystem") VALUES($1, $2, $3, $4, $5, $6)`; @@ -58,9 +58,9 @@ export class SeedDefaultGlobalTaskPriorityAndSize1674638501088 implements Migrat try { for await (const size of DEFAULT_GLOBAL_SIZES) { const payload = Object.values(size); - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { payload.push(uuidV4()); - const query = `INSERT INTO "task_size" ("name", "value", "description", "icon", "color", "isSystem", "id") VALUES($1, $2, $3, $4, $5, $6, $7)`; + const query = `INSERT INTO "task_size" ("name", "value", "description", "icon", "color", "isSystem", "id") VALUES(?, ?, ?, ?, ?, ?, ?)`; await queryRunner.connection.manager.query(query, payload); } else { const query = `INSERT INTO "task_size" ("name", "value", "description", "icon", "color", "isSystem") VALUES($1, $2, $3, $4, $5, $6)`; diff --git a/packages/core/src/database/migrations/1675186090641-AlterTaskStatusTable.ts b/packages/core/src/database/migrations/1675186090641-AlterTaskStatusTable.ts index 1d9c8f6ab43..03b5fe29254 100644 --- a/packages/core/src/database/migrations/1675186090641-AlterTaskStatusTable.ts +++ b/packages/core/src/database/migrations/1675186090641-AlterTaskStatusTable.ts @@ -11,7 +11,7 @@ export class AlterTaskStatusTable1675186090641 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterTaskStatusTable1675186090641 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1675240711524-CreateEmployeePhoneTable.ts b/packages/core/src/database/migrations/1675240711524-CreateEmployeePhoneTable.ts index 3307ee651cc..da29021d053 100644 --- a/packages/core/src/database/migrations/1675240711524-CreateEmployeePhoneTable.ts +++ b/packages/core/src/database/migrations/1675240711524-CreateEmployeePhoneTable.ts @@ -9,7 +9,7 @@ export class CreateEmployeePhoneTable1675240711524 implements MigrationInterface * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -22,7 +22,7 @@ export class CreateEmployeePhoneTable1675240711524 implements MigrationInterface * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1675241589518-AlterUserTable.ts b/packages/core/src/database/migrations/1675241589518-AlterUserTable.ts index 08b5a038ece..ab701043850 100644 --- a/packages/core/src/database/migrations/1675241589518-AlterUserTable.ts +++ b/packages/core/src/database/migrations/1675241589518-AlterUserTable.ts @@ -9,7 +9,7 @@ export class AlterUserTable1675241589518 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -22,7 +22,7 @@ export class AlterUserTable1675241589518 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1675410785835-AlterTaskTable.ts b/packages/core/src/database/migrations/1675410785835-AlterTaskTable.ts index 9bc741248d1..684217e8cc8 100644 --- a/packages/core/src/database/migrations/1675410785835-AlterTaskTable.ts +++ b/packages/core/src/database/migrations/1675410785835-AlterTaskTable.ts @@ -11,7 +11,7 @@ export class AlterTaskTable1675410785835 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterTaskTable1675410785835 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1675687502784-AddTimeZoneColumnToUserTable.ts b/packages/core/src/database/migrations/1675687502784-AddTimeZoneColumnToUserTable.ts index 6c1266b4783..a47d9a50f4f 100644 --- a/packages/core/src/database/migrations/1675687502784-AddTimeZoneColumnToUserTable.ts +++ b/packages/core/src/database/migrations/1675687502784-AddTimeZoneColumnToUserTable.ts @@ -11,7 +11,7 @@ export class AddTimeZoneColumnToUserTable1675687502784 implements MigrationInter * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AddTimeZoneColumnToUserTable1675687502784 implements MigrationInter * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1676351186923-AlterOrganizationTeamTable.ts b/packages/core/src/database/migrations/1676351186923-AlterOrganizationTeamTable.ts index 1907978d3eb..65e9f518e0f 100644 --- a/packages/core/src/database/migrations/1676351186923-AlterOrganizationTeamTable.ts +++ b/packages/core/src/database/migrations/1676351186923-AlterOrganizationTeamTable.ts @@ -11,7 +11,7 @@ export class AlterOrganizationTeamTable1676351186923 implements MigrationInterfa * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterOrganizationTeamTable1676351186923 implements MigrationInterfa * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1676477607906-AddTimeTrackingColumnToOrganizationTeamEmployeeTable.ts b/packages/core/src/database/migrations/1676477607906-AddTimeTrackingColumnToOrganizationTeamEmployeeTable.ts index d35f3764a46..90ccca59881 100644 --- a/packages/core/src/database/migrations/1676477607906-AddTimeTrackingColumnToOrganizationTeamEmployeeTable.ts +++ b/packages/core/src/database/migrations/1676477607906-AddTimeTrackingColumnToOrganizationTeamEmployeeTable.ts @@ -11,7 +11,7 @@ export class AddTimeTrackingColumnToOrganizationTeamEmployeeTable1676477607906 i * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AddTimeTrackingColumnToOrganizationTeamEmployeeTable1676477607906 i * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1676630369336-AddLogoToOrganizationTeamTable.ts b/packages/core/src/database/migrations/1676630369336-AddLogoToOrganizationTeamTable.ts index 362a8bd2fa9..ccb6c80db2f 100644 --- a/packages/core/src/database/migrations/1676630369336-AddLogoToOrganizationTeamTable.ts +++ b/packages/core/src/database/migrations/1676630369336-AddLogoToOrganizationTeamTable.ts @@ -11,7 +11,7 @@ export class AddLogoToOrganizationTeamTable1676630369336 implements MigrationInt * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AddLogoToOrganizationTeamTable1676630369336 implements MigrationInt * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1676827319035-AlterEmployeeTable.ts b/packages/core/src/database/migrations/1676827319035-AlterEmployeeTable.ts index 277c9e5d683..1e0df6cbd52 100644 --- a/packages/core/src/database/migrations/1676827319035-AlterEmployeeTable.ts +++ b/packages/core/src/database/migrations/1676827319035-AlterEmployeeTable.ts @@ -11,7 +11,7 @@ export class AlterEmployeeTable1676827319035 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterEmployeeTable1676827319035 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1676870424741-SeedTaskPriorityAndSizeAndStatusIcon.ts b/packages/core/src/database/migrations/1676870424741-SeedTaskPriorityAndSizeAndStatusIcon.ts index 29c3fd36745..34883581ceb 100644 --- a/packages/core/src/database/migrations/1676870424741-SeedTaskPriorityAndSizeAndStatusIcon.ts +++ b/packages/core/src/database/migrations/1676870424741-SeedTaskPriorityAndSizeAndStatusIcon.ts @@ -38,8 +38,10 @@ export class SeedTaskPriorityAndSizeAndStatusIcon1676870424741 implements Migrat for await (const status of DEFAULT_GLOBAL_STATUSES) { const { name, value, icon, color } = status; const filepath = `ever-icons/${icon}`; - - const query = `UPDATE "task_status" SET "icon" = '${filepath}', "color" = '${color}' WHERE ("name" = $1 AND "value" = $2) AND ("tenantId" IS NULL AND "organizationId" IS NULL)`; + let query = `UPDATE "task_status" SET "icon" = '${filepath}', "color" = '${color}' WHERE ("name" = $1 AND "value" = $2) AND ("tenantId" IS NULL AND "organizationId" IS NULL)`; + if(['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { + query = `UPDATE "task_status" SET "icon" = '${filepath}', "color" = '${color}' WHERE ("name" = ? AND "value" = ?) AND ("tenantId" IS NULL AND "organizationId" IS NULL)`; + } await queryRunner.connection.manager.query(query, [name, value]); copyAssets(status.icon, this.config); } @@ -58,8 +60,10 @@ export class SeedTaskPriorityAndSizeAndStatusIcon1676870424741 implements Migrat for await (const priority of DEFAULT_GLOBAL_PRIORITIES) { const { name, value, icon, color } = priority; const filepath = `ever-icons/${icon}`; - - const query = `UPDATE "task_priority" SET "icon" = '${filepath}', "color" = '${color}' WHERE ("name" = $1 AND "value" = $2) AND ("tenantId" IS NULL AND "organizationId" IS NULL)`; + let query = `UPDATE "task_priority" SET "icon" = '${filepath}', "color" = '${color}' WHERE ("name" = $1 AND "value" = $2) AND ("tenantId" IS NULL AND "organizationId" IS NULL)`; + if(['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { + query = `UPDATE "task_priority" SET "icon" = '${filepath}', "color" = '${color}' WHERE ("name" = ? AND "value" = ?) AND ("tenantId" IS NULL AND "organizationId" IS NULL)`; + } await queryRunner.connection.manager.query(query, [name, value]); copyAssets(priority.icon, this.config); } @@ -78,8 +82,10 @@ export class SeedTaskPriorityAndSizeAndStatusIcon1676870424741 implements Migrat for await (const size of DEFAULT_GLOBAL_SIZES) { const { name, value, icon, color } = size; const filepath = `ever-icons/${icon}`; - - const query = `UPDATE "task_size" SET "icon" = '${filepath}', "color" = '${color}' WHERE ("name" = $1 AND "value" = $2) AND ("tenantId" IS NULL AND "organizationId" IS NULL)`; + let query = `UPDATE "task_size" SET "icon" = '${filepath}', "color" = '${color}' WHERE ("name" = $1 AND "value" = $2) AND ("tenantId" IS NULL AND "organizationId" IS NULL)`; + if(['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { + query = `UPDATE "task_size" SET "icon" = '${filepath}', "color" = '${color}' WHERE ("name" = ? AND "value" = ?) AND ("tenantId" IS NULL AND "organizationId" IS NULL)`; + } await queryRunner.connection.manager.query(query, [name, value]); copyAssets(size.icon, this.config); } diff --git a/packages/core/src/database/migrations/1676978573552-AlterOrganizationTable.ts b/packages/core/src/database/migrations/1676978573552-AlterOrganizationTable.ts index 1d6c9a102da..3924b61f0d3 100644 --- a/packages/core/src/database/migrations/1676978573552-AlterOrganizationTable.ts +++ b/packages/core/src/database/migrations/1676978573552-AlterOrganizationTable.ts @@ -11,7 +11,7 @@ export class AlterOrganizationTable1676828580883 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterOrganizationTable1676828580883 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1677063195155-AlterOrganizationTeamTable.ts b/packages/core/src/database/migrations/1677063195155-AlterOrganizationTeamTable.ts index f0f50958b14..23e78aca41a 100644 --- a/packages/core/src/database/migrations/1677063195155-AlterOrganizationTeamTable.ts +++ b/packages/core/src/database/migrations/1677063195155-AlterOrganizationTeamTable.ts @@ -11,7 +11,7 @@ export class AlterOrganizationTeamTable1677063195155 implements MigrationInterfa * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterOrganizationTeamTable1677063195155 implements MigrationInterfa * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1677142065591-AlterTagTable.ts b/packages/core/src/database/migrations/1677142065591-AlterTagTable.ts index 96b9bb6833c..1f385dd25f3 100644 --- a/packages/core/src/database/migrations/1677142065591-AlterTagTable.ts +++ b/packages/core/src/database/migrations/1677142065591-AlterTagTable.ts @@ -11,7 +11,7 @@ export class AlterTagTable1677142065591 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterTagTable1677142065591 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1677156446733-AlterTaskTable.ts b/packages/core/src/database/migrations/1677156446733-AlterTaskTable.ts index f6bf75c500a..4e276a35a81 100644 --- a/packages/core/src/database/migrations/1677156446733-AlterTaskTable.ts +++ b/packages/core/src/database/migrations/1677156446733-AlterTaskTable.ts @@ -11,7 +11,7 @@ export class AlterTaskTable1677156446733 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterTaskTable1677156446733 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1677313663312-AlterEmployeeTable.ts b/packages/core/src/database/migrations/1677313663312-AlterEmployeeTable.ts index f63db7e9b49..1efa8e45eb9 100644 --- a/packages/core/src/database/migrations/1677313663312-AlterEmployeeTable.ts +++ b/packages/core/src/database/migrations/1677313663312-AlterEmployeeTable.ts @@ -11,7 +11,7 @@ export class AlterEmployeeTable1677313663312 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterEmployeeTable1677313663312 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1677508195152-AlterScreenshotTable.ts b/packages/core/src/database/migrations/1677508195152-AlterScreenshotTable.ts index 4cc3ecaadbb..87784ff768f 100644 --- a/packages/core/src/database/migrations/1677508195152-AlterScreenshotTable.ts +++ b/packages/core/src/database/migrations/1677508195152-AlterScreenshotTable.ts @@ -11,7 +11,7 @@ export class AlterScreenshotTable1677508195152 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterScreenshotTable1677508195152 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1678187685289-CreateOrganizationTeamJoinRequestTable.ts b/packages/core/src/database/migrations/1678187685289-CreateOrganizationTeamJoinRequestTable.ts index 2b116a2ed59..6b3a99dfcc2 100644 --- a/packages/core/src/database/migrations/1678187685289-CreateOrganizationTeamJoinRequestTable.ts +++ b/packages/core/src/database/migrations/1678187685289-CreateOrganizationTeamJoinRequestTable.ts @@ -9,7 +9,7 @@ export class CreateOrganizationTeamJoinRequestTable1678187685289 implements Migr * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -22,7 +22,7 @@ export class CreateOrganizationTeamJoinRequestTable1678187685289 implements Migr * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1678190791247-CreateEmailResetTable.ts b/packages/core/src/database/migrations/1678190791247-CreateEmailResetTable.ts index df7097ff5ca..cb536e26438 100644 --- a/packages/core/src/database/migrations/1678190791247-CreateEmailResetTable.ts +++ b/packages/core/src/database/migrations/1678190791247-CreateEmailResetTable.ts @@ -11,7 +11,7 @@ export class CreateEmailResetTable1678190791247 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class CreateEmailResetTable1678190791247 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1678436030249-AlterOrganizationTeamTable.ts b/packages/core/src/database/migrations/1678436030249-AlterOrganizationTeamTable.ts index e8df876f478..cfba65adc22 100644 --- a/packages/core/src/database/migrations/1678436030249-AlterOrganizationTeamTable.ts +++ b/packages/core/src/database/migrations/1678436030249-AlterOrganizationTeamTable.ts @@ -11,7 +11,7 @@ export class AlterOrganizationTeamTable1678436030249 implements MigrationInterfa * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterOrganizationTeamTable1678436030249 implements MigrationInterfa * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1678461100447-AlterEmailResetTable.ts b/packages/core/src/database/migrations/1678461100447-AlterEmailResetTable.ts index 1b37c9de3ae..19b0238aa18 100644 --- a/packages/core/src/database/migrations/1678461100447-AlterEmailResetTable.ts +++ b/packages/core/src/database/migrations/1678461100447-AlterEmailResetTable.ts @@ -11,7 +11,7 @@ export class AlterEmailResetTable1678461100447 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterEmailResetTable1678461100447 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1679055440296-AlterTaskStatusTableTaskSizeTableTaskPriorityTable.ts b/packages/core/src/database/migrations/1679055440296-AlterTaskStatusTableTaskSizeTableTaskPriorityTable.ts index f6d62617af1..9e113c4bae1 100644 --- a/packages/core/src/database/migrations/1679055440296-AlterTaskStatusTableTaskSizeTableTaskPriorityTable.ts +++ b/packages/core/src/database/migrations/1679055440296-AlterTaskStatusTableTaskSizeTableTaskPriorityTable.ts @@ -11,7 +11,7 @@ export class AlterTaskStatusTableTaskSizeTableTaskPriorityTable1679055440296 imp * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterTaskStatusTableTaskSizeTableTaskPriorityTable1679055440296 imp * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1679119603264-AlterOrganizationTeamJoinRequestTable.ts b/packages/core/src/database/migrations/1679119603264-AlterOrganizationTeamJoinRequestTable.ts index 007e2bfcc10..0d129fba1f0 100644 --- a/packages/core/src/database/migrations/1679119603264-AlterOrganizationTeamJoinRequestTable.ts +++ b/packages/core/src/database/migrations/1679119603264-AlterOrganizationTeamJoinRequestTable.ts @@ -11,7 +11,7 @@ export class AlterOrganizationTeamJoinRequestTable1679119603264 implements Migra * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterOrganizationTeamJoinRequestTable1679119603264 implements Migra * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1679308324164-AlterImageAssetTable.ts b/packages/core/src/database/migrations/1679308324164-AlterImageAssetTable.ts index 7aa48a61afb..316c4c6070c 100644 --- a/packages/core/src/database/migrations/1679308324164-AlterImageAssetTable.ts +++ b/packages/core/src/database/migrations/1679308324164-AlterImageAssetTable.ts @@ -11,7 +11,7 @@ export class AlterImageAssetTable1679308324164 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterImageAssetTable1679308324164 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1679406665415-AddImageAssetColumnToTables.ts b/packages/core/src/database/migrations/1679406665415-AddImageAssetColumnToTables.ts index 46398ee6b45..fe53b2e80b8 100644 --- a/packages/core/src/database/migrations/1679406665415-AddImageAssetColumnToTables.ts +++ b/packages/core/src/database/migrations/1679406665415-AddImageAssetColumnToTables.ts @@ -11,7 +11,7 @@ export class AddImageAssetColumnToTables1679406665415 implements MigrationInterf * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AddImageAssetColumnToTables1679406665415 implements MigrationInterf * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1679676292810-AddImageAssetColumnToTheOrganizationTable.ts b/packages/core/src/database/migrations/1679676292810-AddImageAssetColumnToTheOrganizationTable.ts index 12765f15f34..5de65ba3377 100644 --- a/packages/core/src/database/migrations/1679676292810-AddImageAssetColumnToTheOrganizationTable.ts +++ b/packages/core/src/database/migrations/1679676292810-AddImageAssetColumnToTheOrganizationTable.ts @@ -11,7 +11,7 @@ export class AddImageAssetColumnToTheOrganizationTable1679676292810 implements M * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AddImageAssetColumnToTheOrganizationTable1679676292810 implements M * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1679724221071-AddImageAssetColumnToTheProductCategoryTable.ts b/packages/core/src/database/migrations/1679724221071-AddImageAssetColumnToTheProductCategoryTable.ts index 3102aae466a..a081d93539a 100644 --- a/packages/core/src/database/migrations/1679724221071-AddImageAssetColumnToTheProductCategoryTable.ts +++ b/packages/core/src/database/migrations/1679724221071-AddImageAssetColumnToTheProductCategoryTable.ts @@ -11,7 +11,7 @@ export class AddImageAssetColumnToTheProductCategoryTable1679724221071 implement * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AddImageAssetColumnToTheProductCategoryTable1679724221071 implement * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1680071714132-CreateIssueTypeTable.ts b/packages/core/src/database/migrations/1680071714132-CreateIssueTypeTable.ts index c66844fc288..eac3e717d95 100644 --- a/packages/core/src/database/migrations/1680071714132-CreateIssueTypeTable.ts +++ b/packages/core/src/database/migrations/1680071714132-CreateIssueTypeTable.ts @@ -11,7 +11,7 @@ export class CreateIssueTypeTable1680071714132 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class CreateIssueTypeTable1680071714132 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1680082411434-AddIssueTypeColumnToTheTaskTable.ts b/packages/core/src/database/migrations/1680082411434-AddIssueTypeColumnToTheTaskTable.ts index 548859d0df0..23ed7ac16fa 100644 --- a/packages/core/src/database/migrations/1680082411434-AddIssueTypeColumnToTheTaskTable.ts +++ b/packages/core/src/database/migrations/1680082411434-AddIssueTypeColumnToTheTaskTable.ts @@ -11,7 +11,7 @@ export class AddIssueTypeColumnToTheTaskTable1680082411434 implements MigrationI * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AddIssueTypeColumnToTheTaskTable1680082411434 implements MigrationI * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1680108987586-AddIndexesColumnsToTheTimeSlotTable.ts b/packages/core/src/database/migrations/1680108987586-AddIndexesColumnsToTheTimeSlotTable.ts index 58c04bc3b56..21e0e3073ba 100644 --- a/packages/core/src/database/migrations/1680108987586-AddIndexesColumnsToTheTimeSlotTable.ts +++ b/packages/core/src/database/migrations/1680108987586-AddIndexesColumnsToTheTimeSlotTable.ts @@ -11,7 +11,7 @@ export class AddIndexesColumnsToTheTimeSlotTable1680108987586 implements Migrati * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AddIndexesColumnsToTheTimeSlotTable1680108987586 implements Migrati * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1680110810109-AddIndexesColumnsToTheScreenshotTable.ts b/packages/core/src/database/migrations/1680110810109-AddIndexesColumnsToTheScreenshotTable.ts index e65c1ebe9e5..42b1978824f 100644 --- a/packages/core/src/database/migrations/1680110810109-AddIndexesColumnsToTheScreenshotTable.ts +++ b/packages/core/src/database/migrations/1680110810109-AddIndexesColumnsToTheScreenshotTable.ts @@ -11,7 +11,7 @@ export class AddIndexesColumnsToTheScreenshotTable1680110810109 implements Migra * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AddIndexesColumnsToTheScreenshotTable1680110810109 implements Migra * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1680154573492-AddIndexesColumnsToTheActivityTable.ts b/packages/core/src/database/migrations/1680154573492-AddIndexesColumnsToTheActivityTable.ts index 08c560737f0..234fe73a2fc 100644 --- a/packages/core/src/database/migrations/1680154573492-AddIndexesColumnsToTheActivityTable.ts +++ b/packages/core/src/database/migrations/1680154573492-AddIndexesColumnsToTheActivityTable.ts @@ -11,7 +11,7 @@ export class AddIndexesColumnsToTheActivityTable1680154573492 implements Migrati * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AddIndexesColumnsToTheActivityTable1680154573492 implements Migrati * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1680164421193-AddIndexesColumnsToTheTimesheetTable.ts b/packages/core/src/database/migrations/1680164421193-AddIndexesColumnsToTheTimesheetTable.ts index a447752fa19..49f58e5300d 100644 --- a/packages/core/src/database/migrations/1680164421193-AddIndexesColumnsToTheTimesheetTable.ts +++ b/packages/core/src/database/migrations/1680164421193-AddIndexesColumnsToTheTimesheetTable.ts @@ -11,7 +11,7 @@ export class AddIndexesColumnsToTheTimesheetTable1680164421193 implements Migrat * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AddIndexesColumnsToTheTimesheetTable1680164421193 implements Migrat * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1680172332764-AddIndexesColumnsToTheTimeLogTable.ts b/packages/core/src/database/migrations/1680172332764-AddIndexesColumnsToTheTimeLogTable.ts index 2fd8b4adf8c..2ecb630367c 100644 --- a/packages/core/src/database/migrations/1680172332764-AddIndexesColumnsToTheTimeLogTable.ts +++ b/packages/core/src/database/migrations/1680172332764-AddIndexesColumnsToTheTimeLogTable.ts @@ -9,7 +9,7 @@ export class AddIndexesColumnsToTheTimeLogTable1680172332764 implements Migratio * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -22,7 +22,7 @@ export class AddIndexesColumnsToTheTimeLogTable1680172332764 implements Migratio * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1680530165590-AlterJobSearchRelationalTables.ts b/packages/core/src/database/migrations/1680530165590-AlterJobSearchRelationalTables.ts index 2be5332f602..26f8c1ec58d 100644 --- a/packages/core/src/database/migrations/1680530165590-AlterJobSearchRelationalTables.ts +++ b/packages/core/src/database/migrations/1680530165590-AlterJobSearchRelationalTables.ts @@ -11,7 +11,7 @@ export class AlterJobSearchRelationalTables1680530165590 implements MigrationInt * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterJobSearchRelationalTables1680530165590 implements MigrationInt * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1680622389221-SeedDafaultGlobalIssueType.ts b/packages/core/src/database/migrations/1680622389221-SeedDafaultGlobalIssueType.ts index 667fab17d0f..74f82019ad7 100644 --- a/packages/core/src/database/migrations/1680622389221-SeedDafaultGlobalIssueType.ts +++ b/packages/core/src/database/migrations/1680622389221-SeedDafaultGlobalIssueType.ts @@ -65,7 +65,7 @@ export class SeedDafaultGlobalIssueType1680622389221 implements MigrationInterfa isSystem ]; - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { const imageAssetId = uuidv4(); imageAsset.push(imageAssetId); @@ -74,7 +74,7 @@ export class SeedDafaultGlobalIssueType1680622389221 implements MigrationInterfa "name", "url", "storageProvider", "height", "width", "size", "id" ) VALUES ( - $1, $2, $3, $4, $5, $6, $7 + ?, ?, ?, ?, ?, ?, ? ); `; await queryRunner.connection.manager.query(insertQuery, imageAsset); @@ -84,7 +84,7 @@ export class SeedDafaultGlobalIssueType1680622389221 implements MigrationInterfa INSERT INTO "issue_type" ( "name", "value", "description", "icon", "color", "isSystem", "id", "imageId" ) VALUES ( - $1, $2, $3, $4, $5, $6, $7, $8); + ?, ?, ?, ?, ?, ?, ?, ?); `, payload); } else { const insertQuery = ` diff --git a/packages/core/src/database/migrations/1680688280325-AddUpworkOrganizationIdToTheOrganizationTable.ts b/packages/core/src/database/migrations/1680688280325-AddUpworkOrganizationIdToTheOrganizationTable.ts index 91dd404d8e3..15644143c3a 100644 --- a/packages/core/src/database/migrations/1680688280325-AddUpworkOrganizationIdToTheOrganizationTable.ts +++ b/packages/core/src/database/migrations/1680688280325-AddUpworkOrganizationIdToTheOrganizationTable.ts @@ -11,7 +11,7 @@ export class AddUpworkOrganizationIdToTheOrganizationTable1680688280325 implemen * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AddUpworkOrganizationIdToTheOrganizationTable1680688280325 implemen * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1680692867660-AlterEmployeeTable.ts b/packages/core/src/database/migrations/1680692867660-AlterEmployeeTable.ts index ee5c2c9abe2..ab374b9d996 100644 --- a/packages/core/src/database/migrations/1680692867660-AlterEmployeeTable.ts +++ b/packages/core/src/database/migrations/1680692867660-AlterEmployeeTable.ts @@ -11,7 +11,7 @@ export class AlterEmployeeTable1680692867660 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterEmployeeTable1680692867660 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1680866279166-AddDocumentAssetColumnToTheOrganizationDocumentTable.ts b/packages/core/src/database/migrations/1680866279166-AddDocumentAssetColumnToTheOrganizationDocumentTable.ts index 20308a9c419..46764826600 100644 --- a/packages/core/src/database/migrations/1680866279166-AddDocumentAssetColumnToTheOrganizationDocumentTable.ts +++ b/packages/core/src/database/migrations/1680866279166-AddDocumentAssetColumnToTheOrganizationDocumentTable.ts @@ -11,7 +11,7 @@ export class AddDocumentAssetColumnToTheOrganizationDocumentTable1680866279166 i * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AddDocumentAssetColumnToTheOrganizationDocumentTable1680866279166 i * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1680871419966-AddDocumentAssetColumnToTheTimeOffRequestTable.ts b/packages/core/src/database/migrations/1680871419966-AddDocumentAssetColumnToTheTimeOffRequestTable.ts index 1625d7194b0..ed6ea27b611 100644 --- a/packages/core/src/database/migrations/1680871419966-AddDocumentAssetColumnToTheTimeOffRequestTable.ts +++ b/packages/core/src/database/migrations/1680871419966-AddDocumentAssetColumnToTheTimeOffRequestTable.ts @@ -11,7 +11,7 @@ export class AddDocumentAssetColumnToTheTimeOffRequestTable1680871419966 impleme * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AddDocumentAssetColumnToTheTimeOffRequestTable1680871419966 impleme * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1681132031905-AddEmployeeStatusColumnsToTheEmployeeTable.ts b/packages/core/src/database/migrations/1681132031905-AddEmployeeStatusColumnsToTheEmployeeTable.ts index 46109877cd6..36f50d3ff46 100644 --- a/packages/core/src/database/migrations/1681132031905-AddEmployeeStatusColumnsToTheEmployeeTable.ts +++ b/packages/core/src/database/migrations/1681132031905-AddEmployeeStatusColumnsToTheEmployeeTable.ts @@ -10,7 +10,7 @@ export class AddEmployeeStatusColumnsToTheEmployeeTable1681132031905 implements * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -23,7 +23,7 @@ export class AddEmployeeStatusColumnsToTheEmployeeTable1681132031905 implements * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1681455351186-AddOrganizationTeamIdColumnToTheTimeLogTable.ts b/packages/core/src/database/migrations/1681455351186-AddOrganizationTeamIdColumnToTheTimeLogTable.ts index a4da56ed0aa..552cff5af94 100644 --- a/packages/core/src/database/migrations/1681455351186-AddOrganizationTeamIdColumnToTheTimeLogTable.ts +++ b/packages/core/src/database/migrations/1681455351186-AddOrganizationTeamIdColumnToTheTimeLogTable.ts @@ -11,7 +11,7 @@ export class AddOrganizationTeamIdColumnToTheTimeLogTable1681455351186 implement * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AddOrganizationTeamIdColumnToTheTimeLogTable1681455351186 implement * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1686195290990-AlterOrganizationTeamTable.ts b/packages/core/src/database/migrations/1686195290990-AlterOrganizationTeamTable.ts index 8fc66b73f91..00024302f2b 100644 --- a/packages/core/src/database/migrations/1686195290990-AlterOrganizationTeamTable.ts +++ b/packages/core/src/database/migrations/1686195290990-AlterOrganizationTeamTable.ts @@ -9,7 +9,7 @@ export class AlterOrganizationTeamTable1686195290990 implements MigrationInterfa * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -22,7 +22,7 @@ export class AlterOrganizationTeamTable1686195290990 implements MigrationInterfa * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1687967010243-AddMinimumBillingRateColumnToEmployeeTable.ts b/packages/core/src/database/migrations/1687967010243-AddMinimumBillingRateColumnToEmployeeTable.ts index 6c6eccdc06a..8bbcd1eb663 100644 --- a/packages/core/src/database/migrations/1687967010243-AddMinimumBillingRateColumnToEmployeeTable.ts +++ b/packages/core/src/database/migrations/1687967010243-AddMinimumBillingRateColumnToEmployeeTable.ts @@ -9,7 +9,7 @@ export class AddMinimumBillingRateColumnToEmployeeTable1687967010243 implements * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -22,7 +22,7 @@ export class AddMinimumBillingRateColumnToEmployeeTable1687967010243 implements * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1687967919076-AddMinimumBillingRateColumnToCandidateTable.ts b/packages/core/src/database/migrations/1687967919076-AddMinimumBillingRateColumnToCandidateTable.ts index 87be7d863ed..401b71d46f6 100644 --- a/packages/core/src/database/migrations/1687967919076-AddMinimumBillingRateColumnToCandidateTable.ts +++ b/packages/core/src/database/migrations/1687967919076-AddMinimumBillingRateColumnToCandidateTable.ts @@ -11,7 +11,7 @@ export class AddMinimumBillingRateColumnToCandidateTable1687967919076 implements * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AddMinimumBillingRateColumnToCandidateTable1687967919076 implements * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1687974863736-CreateTaskVersionTable.ts b/packages/core/src/database/migrations/1687974863736-CreateTaskVersionTable.ts index c773fb41ead..3b40219b27a 100644 --- a/packages/core/src/database/migrations/1687974863736-CreateTaskVersionTable.ts +++ b/packages/core/src/database/migrations/1687974863736-CreateTaskVersionTable.ts @@ -9,7 +9,7 @@ export class CreateTaskVersionTable1687974863736 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -22,7 +22,7 @@ export class CreateTaskVersionTable1687974863736 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1688122296981-AlterTableEmployee.ts b/packages/core/src/database/migrations/1688122296981-AlterTableEmployee.ts index 44a42df30bf..7111d4f8205 100644 --- a/packages/core/src/database/migrations/1688122296981-AlterTableEmployee.ts +++ b/packages/core/src/database/migrations/1688122296981-AlterTableEmployee.ts @@ -11,7 +11,7 @@ export class AlterTableEmployee1688122296981 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterTableEmployee1688122296981 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1688168798377-CreateRelatedIssueTypeTable.ts b/packages/core/src/database/migrations/1688168798377-CreateRelatedIssueTypeTable.ts index 029e2febd9f..3f2fba0efa6 100644 --- a/packages/core/src/database/migrations/1688168798377-CreateRelatedIssueTypeTable.ts +++ b/packages/core/src/database/migrations/1688168798377-CreateRelatedIssueTypeTable.ts @@ -11,7 +11,7 @@ export class CreateRelatedIssueTypeTable1688168798377 * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class CreateRelatedIssueTypeTable1688168798377 * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1688886388219-AddParentIdColumnToTaskTable.ts b/packages/core/src/database/migrations/1688886388219-AddParentIdColumnToTaskTable.ts index 56612ca47cc..bd3da2a89c4 100644 --- a/packages/core/src/database/migrations/1688886388219-AddParentIdColumnToTaskTable.ts +++ b/packages/core/src/database/migrations/1688886388219-AddParentIdColumnToTaskTable.ts @@ -11,7 +11,7 @@ export class AddParentIdColumnToTaskTable1688886388219 implements MigrationInter * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AddParentIdColumnToTaskTable1688886388219 implements MigrationInter * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1688966032457-AddRelatedIssueRelationToTaskTable.ts b/packages/core/src/database/migrations/1688966032457-AddRelatedIssueRelationToTaskTable.ts index 67b723a1ceb..1c9c4ff1372 100644 --- a/packages/core/src/database/migrations/1688966032457-AddRelatedIssueRelationToTaskTable.ts +++ b/packages/core/src/database/migrations/1688966032457-AddRelatedIssueRelationToTaskTable.ts @@ -9,7 +9,7 @@ export class AddRelatedIssueRelationToTaskTable1688966032457 implements Migratio * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -22,7 +22,7 @@ export class AddRelatedIssueRelationToTaskTable1688966032457 implements Migratio * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1689150247379-CreateTaskLinkedIssueTable.ts b/packages/core/src/database/migrations/1689150247379-CreateTaskLinkedIssueTable.ts index d6bb87d13bf..b39e0150e92 100644 --- a/packages/core/src/database/migrations/1689150247379-CreateTaskLinkedIssueTable.ts +++ b/packages/core/src/database/migrations/1689150247379-CreateTaskLinkedIssueTable.ts @@ -11,7 +11,7 @@ export class CreateTaskLinkedIssueTable1689150247379 implements MigrationInterfa * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class CreateTaskLinkedIssueTable1689150247379 implements MigrationInterfa * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1689181881441-CreateOrganizationTaskSettingTable.ts b/packages/core/src/database/migrations/1689181881441-CreateOrganizationTaskSettingTable.ts index 4c0f836acac..b600e5e81f3 100644 --- a/packages/core/src/database/migrations/1689181881441-CreateOrganizationTaskSettingTable.ts +++ b/packages/core/src/database/migrations/1689181881441-CreateOrganizationTaskSettingTable.ts @@ -11,7 +11,7 @@ export class CreateOrganizationTaskSettingTable1689181881441 implements Migratio * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class CreateOrganizationTaskSettingTable1689181881441 implements Migratio * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1689611487195-DropTaskRelatedIssuesTable.ts b/packages/core/src/database/migrations/1689611487195-DropTaskRelatedIssuesTable.ts index 536270b9220..d616a34c67d 100644 --- a/packages/core/src/database/migrations/1689611487195-DropTaskRelatedIssuesTable.ts +++ b/packages/core/src/database/migrations/1689611487195-DropTaskRelatedIssuesTable.ts @@ -11,7 +11,7 @@ export class DropTaskRelatedIssuesTable1689611487195 implements MigrationInterfa * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class DropTaskRelatedIssuesTable1689611487195 implements MigrationInterfa * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1689670799675-CreateTaskEstimationTable.ts b/packages/core/src/database/migrations/1689670799675-CreateTaskEstimationTable.ts index 5197fa86655..8becb60f917 100644 --- a/packages/core/src/database/migrations/1689670799675-CreateTaskEstimationTable.ts +++ b/packages/core/src/database/migrations/1689670799675-CreateTaskEstimationTable.ts @@ -11,7 +11,7 @@ export class CreateTaskEstimationTable1689670799675 * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class CreateTaskEstimationTable1689670799675 * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1690040638765-AlterReportTable.ts b/packages/core/src/database/migrations/1690040638765-AlterReportTable.ts index a8ee24bf289..84ec429ba70 100644 --- a/packages/core/src/database/migrations/1690040638765-AlterReportTable.ts +++ b/packages/core/src/database/migrations/1690040638765-AlterReportTable.ts @@ -11,7 +11,7 @@ export class AlterReportTable1690040638765 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterReportTable1690040638765 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1690167501143-AddActiveTaskColumnToOrganizationTeamEmployee.ts b/packages/core/src/database/migrations/1690167501143-AddActiveTaskColumnToOrganizationTeamEmployee.ts index 1ee2f106ab3..f704f302695 100644 --- a/packages/core/src/database/migrations/1690167501143-AddActiveTaskColumnToOrganizationTeamEmployee.ts +++ b/packages/core/src/database/migrations/1690167501143-AddActiveTaskColumnToOrganizationTeamEmployee.ts @@ -11,7 +11,7 @@ export class AddActiveTaskColumnToOrganizationTeamEmployee1690167501143 * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AddActiveTaskColumnToOrganizationTeamEmployee1690167501143 * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1690527506095-AddUpworkOrganizationNameToTheOrganizationTable.ts b/packages/core/src/database/migrations/1690527506095-AddUpworkOrganizationNameToTheOrganizationTable.ts index 11a07ba16a6..5776077e30a 100644 --- a/packages/core/src/database/migrations/1690527506095-AddUpworkOrganizationNameToTheOrganizationTable.ts +++ b/packages/core/src/database/migrations/1690527506095-AddUpworkOrganizationNameToTheOrganizationTable.ts @@ -11,7 +11,7 @@ export class AddUpworkOrganizationNameToTheOrganizationTable1690527506095 implem * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AddUpworkOrganizationNameToTheOrganizationTable1690527506095 implem * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1691493358068-AlterIntegrationTable.ts b/packages/core/src/database/migrations/1691493358068-AlterIntegrationTable.ts index b0e188f17b6..45760e5913b 100644 --- a/packages/core/src/database/migrations/1691493358068-AlterIntegrationTable.ts +++ b/packages/core/src/database/migrations/1691493358068-AlterIntegrationTable.ts @@ -14,7 +14,7 @@ export class AlterIntegrationTable1691493358068 implements MigrationInterface { public async up(queryRunner: QueryRunner): Promise { console.log(chalk.yellow(`AlterIntegrationTable1691493358068 start running!`)); - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -27,7 +27,7 @@ export class AlterIntegrationTable1691493358068 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1691494801748-SeedIntegrationTable.ts b/packages/core/src/database/migrations/1691494801748-SeedIntegrationTable.ts index 1d26c6f6a60..e50600d9718 100644 --- a/packages/core/src/database/migrations/1691494801748-SeedIntegrationTable.ts +++ b/packages/core/src/database/migrations/1691494801748-SeedIntegrationTable.ts @@ -43,23 +43,18 @@ export class SeedIntegrationTable1691494801748 implements MigrationInterface { let upsertQuery = ``; const payload = [name, filepath, isComingSoon, order]; - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { // For SQLite, manually generate a UUID using uuidv4() const generatedId = uuidv4(); payload.push(generatedId); upsertQuery = ` - INSERT INTO integration ( - "name", "imgSrc", "isComingSoon", "order", "id" - ) - VALUES ( - $1, $2, $3, $4, $5 - ) - ON CONFLICT(name) DO UPDATE - SET - "imgSrc" = $2, - "isComingSoon" = $3, - "order" = $4 - RETURNING id; + INSERT INTO "integration" ("name", "imgSrc", "isComingSoon", "order", "id") + VALUES (?, ?, ?, ?, ?) + ON CONFLICT ("name") + DO UPDATE SET "imgSrc" = EXCLUDED."imgSrc", + "isComingSoon" = EXCLUDED."isComingSoon", + "order" = EXCLUDED."order" + RETURNING "id"; `; } else { upsertQuery = ` diff --git a/packages/core/src/database/migrations/1691756595248-AddUserIdColumnToUserTable.ts b/packages/core/src/database/migrations/1691756595248-AddUserIdColumnToUserTable.ts index caa0aaab553..1c76ea6abaf 100644 --- a/packages/core/src/database/migrations/1691756595248-AddUserIdColumnToUserTable.ts +++ b/packages/core/src/database/migrations/1691756595248-AddUserIdColumnToUserTable.ts @@ -14,7 +14,7 @@ export class AddUserIdColumnToUserTable1691756595248 implements MigrationInterfa public async up(queryRunner: QueryRunner): Promise { console.log(chalk.yellow(`AddUserIdColumnToUserTable1691756595248 start running!`)); - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -27,7 +27,7 @@ export class AddUserIdColumnToUserTable1691756595248 implements MigrationInterfa * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1692171665427-SeedIntegrationTable.ts b/packages/core/src/database/migrations/1692171665427-SeedIntegrationTable.ts index 9a478d06311..65b5db6c5f9 100644 --- a/packages/core/src/database/migrations/1692171665427-SeedIntegrationTable.ts +++ b/packages/core/src/database/migrations/1692171665427-SeedIntegrationTable.ts @@ -43,23 +43,18 @@ export class SeedIntegrationTable1692171665427 implements MigrationInterface { let upsertQuery = ``; const payload = [name, filepath, isComingSoon, order]; - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { // For SQLite, manually generate a UUID using uuidv4() const generatedId = uuidv4(); payload.push(generatedId); upsertQuery = ` - INSERT INTO integration ( - "name", "imgSrc", "isComingSoon", "order", "id" - ) - VALUES ( - $1, $2, $3, $4, $5 - ) - ON CONFLICT(name) DO UPDATE - SET - "imgSrc" = $2, - "isComingSoon" = $3, - "order" = $4 - RETURNING id; + INSERT INTO "integration" ("name", "imgSrc", "isComingSoon", "order", "id") + VALUES (?, ?, ?, ?, ?) + ON CONFLICT ("name") + DO UPDATE SET "imgSrc" = EXCLUDED."imgSrc", + "isComingSoon" = EXCLUDED."isComingSoon", + "order" = EXCLUDED."order" + RETURNING "id"; `; } else { upsertQuery = ` diff --git a/packages/core/src/database/migrations/1692256031607-AddOrganizationProjectTeamRelation.ts b/packages/core/src/database/migrations/1692256031607-AddOrganizationProjectTeamRelation.ts index 6903b918085..60bf2ac038a 100644 --- a/packages/core/src/database/migrations/1692256031607-AddOrganizationProjectTeamRelation.ts +++ b/packages/core/src/database/migrations/1692256031607-AddOrganizationProjectTeamRelation.ts @@ -14,7 +14,7 @@ export class AddOrganizationProjectTeamRelation1692256031607 implements Migratio public async up(queryRunner: QueryRunner): Promise { console.log(chalk.yellow(`AddOrganizationProjectTeamRelation1692256031607 start running!`)); - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -27,7 +27,7 @@ export class AddOrganizationProjectTeamRelation1692256031607 implements Migratio * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1692275997367-AlterIntegrationTableRelationCascading.ts b/packages/core/src/database/migrations/1692275997367-AlterIntegrationTableRelationCascading.ts index 8f02670dd62..ca042bea7cd 100644 --- a/packages/core/src/database/migrations/1692275997367-AlterIntegrationTableRelationCascading.ts +++ b/packages/core/src/database/migrations/1692275997367-AlterIntegrationTableRelationCascading.ts @@ -14,7 +14,7 @@ export class AlterIntegrationTableRelationCascading1692275997367 implements Migr public async up(queryRunner: QueryRunner): Promise { console.log(chalk.yellow(`AlterIntegrationTableRelationCascading1692275997367 start running!`)); - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -27,7 +27,7 @@ export class AlterIntegrationTableRelationCascading1692275997367 implements Migr * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1692433732267-AlterIntegrationTenantTable.ts b/packages/core/src/database/migrations/1692433732267-AlterIntegrationTenantTable.ts index af8f9a3c835..342b7f7e8a9 100644 --- a/packages/core/src/database/migrations/1692433732267-AlterIntegrationTenantTable.ts +++ b/packages/core/src/database/migrations/1692433732267-AlterIntegrationTenantTable.ts @@ -14,7 +14,7 @@ export class AlterIntegrationTenantTable1692433732267 implements MigrationInterf public async up(queryRunner: QueryRunner): Promise { console.log(chalk.yellow(`AlterIntegrationTenantTable1692433732267 start running!`)); - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -27,7 +27,7 @@ export class AlterIntegrationTenantTable1692433732267 implements MigrationInterf * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1693547294428-AlterCodeToAlphaNumericFormat.ts b/packages/core/src/database/migrations/1693547294428-AlterCodeToAlphaNumericFormat.ts index 1aecad79d3a..af3feaa67c4 100644 --- a/packages/core/src/database/migrations/1693547294428-AlterCodeToAlphaNumericFormat.ts +++ b/packages/core/src/database/migrations/1693547294428-AlterCodeToAlphaNumericFormat.ts @@ -14,7 +14,7 @@ export class AlterCodeToAlphaNumericFormat1693547294428 implements MigrationInte public async up(queryRunner: QueryRunner): Promise { console.log(chalk.yellow(`AlterCodeToAlphaNumericFormat1693547294428 start running!`)); - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -27,7 +27,7 @@ export class AlterCodeToAlphaNumericFormat1693547294428 implements MigrationInte * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1694427247661-AlterOrganizationTeamJoinRequestTable.ts b/packages/core/src/database/migrations/1694427247661-AlterOrganizationTeamJoinRequestTable.ts index fe157b3de49..4fa010dfc27 100644 --- a/packages/core/src/database/migrations/1694427247661-AlterOrganizationTeamJoinRequestTable.ts +++ b/packages/core/src/database/migrations/1694427247661-AlterOrganizationTeamJoinRequestTable.ts @@ -11,7 +11,7 @@ export class AlterOrganizationTeamJoinRequestTable1694427247661 implements Migra * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AlterOrganizationTeamJoinRequestTable1694427247661 implements Migra * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1695023907817-AddColumnsToTheIntegrationTable.ts b/packages/core/src/database/migrations/1695023907817-AddColumnsToTheIntegrationTable.ts index d59fcfa7969..de7e00a133a 100644 --- a/packages/core/src/database/migrations/1695023907817-AddColumnsToTheIntegrationTable.ts +++ b/packages/core/src/database/migrations/1695023907817-AddColumnsToTheIntegrationTable.ts @@ -13,7 +13,7 @@ export class AddColumnsToTheIntegrationTable1695023907817 implements MigrationIn public async up(queryRunner: QueryRunner): Promise { console.log(chalk.yellow(`AddColumnsToTheIntegrationTable1695023907817 start running!`)); - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -26,7 +26,7 @@ export class AddColumnsToTheIntegrationTable1695023907817 implements MigrationIn * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1695111838783-AddColumnsToTheIntegrationTypeTable.ts b/packages/core/src/database/migrations/1695111838783-AddColumnsToTheIntegrationTypeTable.ts index 2b4613ba97e..6bfacf945f8 100644 --- a/packages/core/src/database/migrations/1695111838783-AddColumnsToTheIntegrationTypeTable.ts +++ b/packages/core/src/database/migrations/1695111838783-AddColumnsToTheIntegrationTypeTable.ts @@ -14,7 +14,7 @@ export class AddColumnsToTheIntegrationTypeTable1695111838783 implements Migrati public async up(queryRunner: QueryRunner): Promise { console.log(chalk.yellow(`AddColumnsToTheIntegrationTypeTable1695111838783 start running!`)); - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -27,7 +27,7 @@ export class AddColumnsToTheIntegrationTypeTable1695111838783 implements Migrati * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1695570009125-AlterTableTask.ts b/packages/core/src/database/migrations/1695570009125-AlterTableTask.ts index 64d176c8948..bfcdfcd09ec 100644 --- a/packages/core/src/database/migrations/1695570009125-AlterTableTask.ts +++ b/packages/core/src/database/migrations/1695570009125-AlterTableTask.ts @@ -9,7 +9,7 @@ export class AlterTableTask1695570009125 implements MigrationInterface { * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -22,7 +22,7 @@ export class AlterTableTask1695570009125 implements MigrationInterface { * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1695958130201-AddedArchivedColumnToUser.ts b/packages/core/src/database/migrations/1695958130201-AddedArchivedColumnToUser.ts index a620f0e9323..d0fe4155b9b 100644 --- a/packages/core/src/database/migrations/1695958130201-AddedArchivedColumnToUser.ts +++ b/packages/core/src/database/migrations/1695958130201-AddedArchivedColumnToUser.ts @@ -11,7 +11,7 @@ export class AddedArchivedColumnToUser1695958130201 implements MigrationInterfac * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AddedArchivedColumnToUser1695958130201 implements MigrationInterfac * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/database/migrations/1696413384868-AddedActiveArchivedColumnsToBaseEntity.ts b/packages/core/src/database/migrations/1696413384868-AddedActiveArchivedColumnsToBaseEntity.ts index 57e32453d3f..3b17efa43f5 100644 --- a/packages/core/src/database/migrations/1696413384868-AddedActiveArchivedColumnsToBaseEntity.ts +++ b/packages/core/src/database/migrations/1696413384868-AddedActiveArchivedColumnsToBaseEntity.ts @@ -11,7 +11,7 @@ export class AddedActiveArchivedColumnsToBaseEntity1696413384868 implements Migr * @param queryRunner */ public async up(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteUpQueryRunner(queryRunner); } else { await this.postgresUpQueryRunner(queryRunner); @@ -24,7 +24,7 @@ export class AddedActiveArchivedColumnsToBaseEntity1696413384868 implements Migr * @param queryRunner */ public async down(queryRunner: QueryRunner): Promise { - if (queryRunner.connection.options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type)) { await this.sqliteDownQueryRunner(queryRunner); } else { await this.postgresDownQueryRunner(queryRunner); diff --git a/packages/core/src/email-template/utils.ts b/packages/core/src/email-template/utils.ts index 49c878a18b5..a635588f31f 100644 --- a/packages/core/src/email-template/utils.ts +++ b/packages/core/src/email-template/utils.ts @@ -161,16 +161,23 @@ export class EmailTemplateUtils { hbs, mjml ]; - const query = `SELECT COUNT(*) FROM "email_template" WHERE ("name" = $1 AND "languageCode" = $2) AND ("tenantId" IS NULL AND "organizationId" IS NULL)`; - const [template] = await queryRunner.connection.manager.query(query, [name, languageCode]); - - if (parseInt(template.count) > 0) { - const update = `UPDATE "email_template" SET "hbs" = $1, "mjml" = $2 WHERE ("name" = $3 AND "languageCode" = $4) AND ("tenantId" IS NULL AND "organizationId" IS NULL)`; + const isSqlite = ['sqlite', 'better-sqlite3'].includes(queryRunner.connection.options.type); + let query = `SELECT COUNT(*) FROM "email_template" WHERE ("name" = $1 AND "languageCode" = $2) AND ("tenantId" IS NULL AND "organizationId" IS NULL)`; + if (isSqlite) { + query = `SELECT COUNT(*) FROM "email_template" WHERE ("name" = ? AND "languageCode" = ?) AND ("tenantId" IS NULL AND "organizationId" IS NULL)`; + } + const [template] = await queryRunner.connection.manager.query(query, [name, languageCode]); + + if (parseInt(template.count, 10) > 0) { + let update = `UPDATE "email_template" SET "hbs" = $1, "mjml" = $2 WHERE ("name" = $3 AND "languageCode" = $4) AND ("tenantId" IS NULL AND "organizationId" IS NULL)`; + if (isSqlite) { + update = `UPDATE "email_template" SET "hbs" = ?, "mjml" = ? WHERE ("name" = ? AND "languageCode" = ?) AND ("tenantId" IS NULL AND "organizationId" IS NULL)`; + } await queryRunner.connection.manager.query(update, [hbs, mjml, name, languageCode]); } else { - if (queryRunner.connection.options.type === 'sqlite') { + if (isSqlite) { payload.push(uuidV4()); - const insert = `INSERT INTO "email_template" ("name", "languageCode", "hbs", mjml, "id") VALUES($1, $2, $3, $4, $5)`; + const insert = `INSERT INTO "email_template" ("name", "languageCode", "hbs", "mjml", "id") VALUES(?, ?, ?, ?, ?)`; await queryRunner.connection.manager.query(insert, payload); } else { const insert = `INSERT INTO "email_template" ("name", "languageCode", "hbs", mjml) VALUES($1, $2, $3, $4)`; diff --git a/packages/core/src/employee/commands/handlers/update-employee-total-worked-hours.handler.ts b/packages/core/src/employee/commands/handlers/update-employee-total-worked-hours.handler.ts index e8a678980fe..a7d7be1da50 100644 --- a/packages/core/src/employee/commands/handlers/update-employee-total-worked-hours.handler.ts +++ b/packages/core/src/employee/commands/handlers/update-employee-total-worked-hours.handler.ts @@ -30,7 +30,7 @@ export class UpdateEmployeeTotalWorkedHoursHandler .createQueryBuilder() .select( `${ - config.dbConnectionOptions.type === 'sqlite' + ['sqlite', 'better-sqlite3'].includes(config.dbConnectionOptions.type) ? 'SUM((julianday("stoppedAt") - julianday("startedAt")) * 86400)' : 'SUM(extract(epoch from ("stoppedAt" - "startedAt")))' }`, diff --git a/packages/core/src/equipment-sharing/equipment-sharing.service.ts b/packages/core/src/equipment-sharing/equipment-sharing.service.ts index a38e63f6723..3c1956def13 100644 --- a/packages/core/src/equipment-sharing/equipment-sharing.service.ts +++ b/packages/core/src/equipment-sharing/equipment-sharing.service.ts @@ -38,7 +38,7 @@ export class EquipmentSharingService extends TenantAwareCrudService options.type === 'sqlite' ? 'text' : 'json' }) + @ApiPropertyOptional({ + type: () => + ['sqlite', 'better-sqlite3'].includes(options.type) + ? 'text' + : 'json', + }) @IsOptional() @IsString() @Column({ nullable: true, - type: options.type === 'sqlite' ? 'text' : 'json' + type: ['sqlite', 'better-sqlite3'].includes(options.type) + ? 'text' + : 'json', }) metaData?: string | IURLMetaData; @@ -94,7 +101,7 @@ export class Activity extends TenantOrganizationBaseEntity implements IActivity @ApiPropertyOptional({ type: () => String, enum: TimeLogSourceEnum, - default: TimeLogSourceEnum.WEB_TIMER + default: TimeLogSourceEnum.WEB_TIMER, }) @IsOptional() @IsEnum(TimeLogSourceEnum) diff --git a/packages/core/src/time-tracking/activity/activity.service.ts b/packages/core/src/time-tracking/activity/activity.service.ts index 4f3fc0069fd..129f1283665 100644 --- a/packages/core/src/time-tracking/activity/activity.service.ts +++ b/packages/core/src/time-tracking/activity/activity.service.ts @@ -45,7 +45,7 @@ export class ActivityService extends TenantAwareCrudService { query.addSelect(`"${query.alias}"."employeeId"`, `employeeId`); query.addSelect(`"${query.alias}"."date"`, `date`); - if (config.dbConnectionOptions.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(config.dbConnectionOptions.type)) { query.addSelect(`time("${query.alias}"."time")`, `time`); } else { query.addSelect( @@ -56,7 +56,7 @@ export class ActivityService extends TenantAwareCrudService { query.addSelect(`"${query.alias}"."title"`, `title`); query.groupBy(`"${query.alias}"."date"`); - if (config.dbConnectionOptions.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(config.dbConnectionOptions.type)) { query.addGroupBy(`time("${query.alias}"."time")`); } else { query.addGroupBy( @@ -206,7 +206,7 @@ export class ActivityService extends TenantAwareCrudService { ); query.andWhere( new Brackets((qb: WhereExpressionBuilder) => { - if (config.dbConnectionOptions.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(config.dbConnectionOptions.type)) { qb.andWhere(`datetime("${query.alias}"."date" || ' ' || "${query.alias}"."time") Between :startDate AND :endDate`, { startDate, endDate diff --git a/packages/core/src/time-tracking/activity/activity.subscriber.ts b/packages/core/src/time-tracking/activity/activity.subscriber.ts index 0768a674af0..f9ae5799f3e 100644 --- a/packages/core/src/time-tracking/activity/activity.subscriber.ts +++ b/packages/core/src/time-tracking/activity/activity.subscriber.ts @@ -27,7 +27,7 @@ export class ActivitySubscriber implements EntitySubscriberInterface { try { if (event) { const options: Partial = event.connection.options || getConfig().dbConnectionOptions; - if (options.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(options.type)) { const { entity } = event; try { if (isJsObject(entity.metaData)) { @@ -43,4 +43,4 @@ export class ActivitySubscriber implements EntitySubscriberInterface { console.log(error); } } -} \ No newline at end of file +} diff --git a/packages/core/src/time-tracking/statistic/statistic.service.ts b/packages/core/src/time-tracking/statistic/statistic.service.ts index 0b894ace8b8..70821ebe1de 100644 --- a/packages/core/src/time-tracking/statistic/statistic.service.ts +++ b/packages/core/src/time-tracking/statistic/statistic.service.ts @@ -122,7 +122,7 @@ export class StatisticService { const weekTimeStatistics = await weekQuery .innerJoin(`${weekQuery.alias}.timeLogs`, 'timeLogs') .select( - `${this.configService.dbConnectionOptions.type === 'sqlite' + `${['sqlite', 'better-sqlite3'].includes(this.configService.dbConnectionOptions.type) ? `COALESCE(ROUND(SUM((julianday(COALESCE("timeLogs"."stoppedAt", datetime('now'))) - julianday("timeLogs"."startedAt")) * 86400) / COUNT("${weekQuery.alias}"."id")), 0)` : `COALESCE(ROUND(SUM(extract(epoch from (COALESCE("timeLogs"."stoppedAt", NOW()) - "timeLogs"."startedAt"))) / COUNT("${weekQuery.alias}"."id")), 0)` }`, @@ -237,7 +237,7 @@ export class StatisticService { const todayTimeStatistics = await todayQuery .innerJoin(`${todayQuery.alias}.timeLogs`, 'timeLogs') .select( - `${this.configService.dbConnectionOptions.type === 'sqlite' + `${['sqlite', 'better-sqlite3'].includes(this.configService.dbConnectionOptions.type) ? `COALESCE(ROUND(SUM((julianday(COALESCE("timeLogs"."stoppedAt", datetime('now'))) - julianday("timeLogs"."startedAt")) * 86400) / COUNT("${todayQuery.alias}"."id")), 0)` : `COALESCE(ROUND(SUM(extract(epoch from (COALESCE("timeLogs"."stoppedAt", NOW()) - "timeLogs"."startedAt"))) / COUNT("${todayQuery.alias}"."id")), 0)` }`, @@ -405,7 +405,7 @@ export class StatisticService { .addSelect(`("user"."firstName" || ' ' || "user"."lastName")`, 'user_name') .addSelect(`"user"."imageUrl"`, 'user_image_url') .addSelect( - `${this.configService.dbConnectionOptions.type === 'sqlite' + `${['sqlite', 'better-sqlite3'].includes(this.configService.dbConnectionOptions.type) ? `COALESCE(ROUND(SUM((julianday(COALESCE("timeLogs"."stoppedAt", datetime('now'))) - julianday("timeLogs"."startedAt")) * 86400)), 0)` : `COALESCE(ROUND(SUM(extract(epoch from (COALESCE("timeLogs"."stoppedAt", NOW()) - "timeLogs"."startedAt")))), 0)` }`, @@ -468,7 +468,7 @@ export class StatisticService { const weekTimeQuery = this.timeSlotRepository.createQueryBuilder('time_slot'); weekTimeQuery .select( - `${this.configService.dbConnectionOptions.type === 'sqlite' + `${['sqlite', 'better-sqlite3'].includes(this.configService.dbConnectionOptions.type) ? `COALESCE(ROUND(SUM((julianday(COALESCE("timeLogs"."stoppedAt", datetime('now'))) - julianday("timeLogs"."startedAt")) * 86400) / COUNT("${weekTimeQuery.alias}"."id")), 0)` : `COALESCE(ROUND(SUM(extract(epoch from (COALESCE("timeLogs"."stoppedAt", NOW()) - "timeLogs"."startedAt"))) / COUNT("${weekTimeQuery.alias}"."id")), 0)` }`, @@ -554,7 +554,7 @@ export class StatisticService { let dayTimeQuery = this.timeSlotRepository.createQueryBuilder('time_slot'); dayTimeQuery .select( - `${this.configService.dbConnectionOptions.type === 'sqlite' + `${['sqlite', 'better-sqlite3'].includes(this.configService.dbConnectionOptions.type) ? `COALESCE(ROUND(SUM((julianday(COALESCE("timeLogs"."stoppedAt", datetime('now'))) - julianday("timeLogs"."startedAt")) * 86400) / COUNT("${dayTimeQuery.alias}"."id")), 0)` : `COALESCE(ROUND(SUM(extract(epoch from (COALESCE("timeLogs"."stoppedAt", NOW()) - "timeLogs"."startedAt"))) / COUNT("${dayTimeQuery.alias}"."id")), 0)` }`, @@ -774,7 +774,7 @@ export class StatisticService { .select(`"project"."name"`, "name") .addSelect(`"project"."id"`, "projectId") .addSelect( - `${this.configService.dbConnectionOptions.type === 'sqlite' + `${['sqlite', 'better-sqlite3'].includes(this.configService.dbConnectionOptions.type) ? `COALESCE(ROUND(SUM((julianday(COALESCE("${query.alias}"."stoppedAt", datetime('now'))) - julianday("${query.alias}"."startedAt")) * 86400) / COUNT("time_slot"."id")), 0)` : `COALESCE(ROUND(SUM(extract(epoch from (COALESCE("${query.alias}"."stoppedAt", NOW()) - "${query.alias}"."startedAt"))) / COUNT("time_slot"."id")), 0)` }`, @@ -848,7 +848,7 @@ export class StatisticService { const totalDurationQuery = this.timeLogRepository.createQueryBuilder('time_log'); totalDurationQuery .select( - `${this.configService.dbConnectionOptions.type === 'sqlite' + `${['sqlite', 'better-sqlite3'].includes(this.configService.dbConnectionOptions.type) ? `COALESCE(ROUND(SUM((julianday(COALESCE("${totalDurationQuery.alias}"."stoppedAt", datetime('now'))) - julianday("${totalDurationQuery.alias}"."startedAt")) * 86400)), 0)` : `COALESCE(ROUND(SUM(extract(epoch from (COALESCE("${totalDurationQuery.alias}"."stoppedAt", NOW()) - "${totalDurationQuery.alias}"."startedAt")))), 0)` }`, @@ -956,7 +956,7 @@ export class StatisticService { .select(`"task"."title"`, "title") .addSelect(`"task"."id"`, "taskId") .addSelect( - `${this.configService.dbConnectionOptions.type === 'sqlite' + `${['sqlite', 'better-sqlite3'].includes(this.configService.dbConnectionOptions.type) ? `COALESCE(ROUND(SUM((julianday(COALESCE("${query.alias}"."stoppedAt", datetime('now'))) - julianday("${query.alias}"."startedAt")) * 86400) / COUNT("time_slot"."id")), 0)` : `COALESCE(ROUND(SUM(extract(epoch from (COALESCE("${query.alias}"."stoppedAt", NOW()) - "${query.alias}"."startedAt"))) / COUNT("time_slot"."id")), 0)` }`, @@ -1039,7 +1039,7 @@ export class StatisticService { const totalDurationQuery = this.timeLogRepository.createQueryBuilder(); totalDurationQuery .select( - `${this.configService.dbConnectionOptions.type === 'sqlite' + `${['sqlite', 'better-sqlite3'].includes(this.configService.dbConnectionOptions.type) ? `COALESCE(ROUND(SUM((julianday(COALESCE("${totalDurationQuery.alias}"."stoppedAt", datetime('now'))) - julianday("${totalDurationQuery.alias}"."startedAt")) * 86400)), 0)` : `COALESCE(ROUND(SUM(extract(epoch from (COALESCE("${totalDurationQuery.alias}"."stoppedAt", NOW()) - "${totalDurationQuery.alias}"."startedAt")))), 0)` }`, diff --git a/packages/core/src/time-tracking/time-log/commands/handlers/get-conflict-time-log.handler.ts b/packages/core/src/time-tracking/time-log/commands/handlers/get-conflict-time-log.handler.ts index 98cb23b7b62..1d9711005ac 100644 --- a/packages/core/src/time-tracking/time-log/commands/handlers/get-conflict-time-log.handler.ts +++ b/packages/core/src/time-tracking/time-log/commands/handlers/get-conflict-time-log.handler.ts @@ -36,7 +36,7 @@ export class GetConflictTimeLogHandler .andWhere(`"${conflictQuery.alias}"."organizationId" = :organizationId`, { organizationId }) .andWhere(`"${conflictQuery.alias}"."deletedAt" IS null`) .andWhere( - this.configService.dbConnectionOptions.type === 'sqlite' + ['sqlite', 'better-sqlite3'].includes(this.configService.dbConnectionOptions.type) ? `'${startedAt}' >= "${conflictQuery.alias}"."startedAt" and '${startedAt}' <= "${conflictQuery.alias}"."stoppedAt"` : `("${conflictQuery.alias}"."startedAt", "${conflictQuery.alias}"."stoppedAt") OVERLAPS (timestamptz '${startedAt}', timestamptz '${stoppedAt}')` ); diff --git a/packages/core/src/time-tracking/time-log/commands/handlers/schedule-time-log-entries.handler.ts b/packages/core/src/time-tracking/time-log/commands/handlers/schedule-time-log-entries.handler.ts index a66dbeb89fe..c3a1f01ede8 100644 --- a/packages/core/src/time-tracking/time-log/commands/handlers/schedule-time-log-entries.handler.ts +++ b/packages/core/src/time-tracking/time-log/commands/handlers/schedule-time-log-entries.handler.ts @@ -103,7 +103,7 @@ export class ScheduleTimeLogEntriesHandler /** * Adjust stopped date as per database selection */ - if (getConfig().dbConnectionOptions.type === 'sqlite') { + if (['sqlite', 'better-sqlite3'].includes(getConfig().dbConnectionOptions.type)) { stoppedAt = moment.utc(timeLog.startedAt).add(duration, 'seconds').format('YYYY-MM-DD HH:mm:ss.SSS'); slotDifference = moment.utc(moment()).diff(stoppedAt, 'minutes'); } else { diff --git a/packages/desktop-libs/package.json b/packages/desktop-libs/package.json index 034bad8780f..c84e8cc32c2 100644 --- a/packages/desktop-libs/package.json +++ b/packages/desktop-libs/package.json @@ -30,6 +30,7 @@ "@electron/remote": "^2.0.8", "@gauzy/desktop-window": "^0.1.0", "active-win": "^8.1.0", + "better-sqlite3": "^8.7.0", "electron": "20.2.0", "electron-store": "^8.1.0", "electron-util": "^0.17.2", diff --git a/packages/desktop-libs/src/lib/offline/databases/better-sqlite-provider.ts b/packages/desktop-libs/src/lib/offline/databases/better-sqlite-provider.ts new file mode 100644 index 00000000000..5b12387eeb9 --- /dev/null +++ b/packages/desktop-libs/src/lib/offline/databases/better-sqlite-provider.ts @@ -0,0 +1,44 @@ +import { IServerLessProvider } from '../../interfaces'; +import { Knex } from 'knex'; +import path from 'path'; +import { app } from 'electron'; + +export class BetterSqliteProvider implements IServerLessProvider { + private static _instance: IServerLessProvider; + private readonly _connection: Knex; + + private constructor() { + this._connection = require('knex')(this.config); + console.log('[provider]: ', 'Better SQLite connected...'); + } + + public static get instance(): IServerLessProvider { + if (!this._instance) { + this._instance = new BetterSqliteProvider(); + } + return this._instance; + } + + public get connection(): Knex { + return this._connection; + } + + public get config(): Knex.Config { + return { + client: 'better-sqlite3', + connection: { + filename: path.resolve( + app?.getPath('userData') || __dirname, + 'gauzy.sqlite3' + ), + timezone: 'utc', + }, + migrations: { + directory: __dirname + '/migrations', + }, + useNullAsDefault: true, + debug: false, + asyncStackTraces: true, + }; + } +} diff --git a/packages/desktop-libs/src/lib/offline/databases/index.ts b/packages/desktop-libs/src/lib/offline/databases/index.ts index 67e99b7d720..6bc44328547 100644 --- a/packages/desktop-libs/src/lib/offline/databases/index.ts +++ b/packages/desktop-libs/src/lib/offline/databases/index.ts @@ -2,3 +2,4 @@ export * from './mysql-provider'; export * from './postgres-provider'; export * from './provider-factory'; export * from './sqlite-provider'; +export * from './better-sqlite-provider'; diff --git a/packages/desktop-libs/src/lib/offline/databases/provider-factory.ts b/packages/desktop-libs/src/lib/offline/databases/provider-factory.ts index f90f6aad9fe..1ae1d2c0d89 100644 --- a/packages/desktop-libs/src/lib/offline/databases/provider-factory.ts +++ b/packages/desktop-libs/src/lib/offline/databases/provider-factory.ts @@ -6,6 +6,7 @@ import { PostgresProvider } from './postgres-provider'; import { MysqlProvider } from './mysql-provider'; import { LocalStore } from '../../desktop-store'; import { AppError } from '../../error-handler'; +import { BetterSqliteProvider } from './better-sqlite-provider'; export class ProviderFactory implements IDatabaseProvider { private _dbContext: DatabaseProviderContext; @@ -34,15 +35,23 @@ export class ProviderFactory implements IDatabaseProvider { case 'mysql': this._dbContext.provider = MysqlProvider.instance; break; - default: + case 'sqlite': this._dbContext.provider = SqliteProvider.instance; break; + default: + this._dbContext.provider = BetterSqliteProvider.instance; + break; } } public get dialect(): string { - const cfg = LocalStore.getApplicationConfig().config; - return cfg && cfg.db ? cfg.db : 'sqlite'; + let cfg = LocalStore.getApplicationConfig().config; + if (!cfg?.db) { + // Set default database + LocalStore.updateAdditionalSetting({ db: 'better-sqlite' }); + cfg = LocalStore.getApplicationConfig().config; + } + return cfg?.db; } public async migrate(): Promise { @@ -84,4 +93,45 @@ export class ProviderFactory implements IDatabaseProvider { throw new AppError('PRKILL', error); } } + + public async check(arg: any): Promise { + const dialect = arg.db; + const connection = { + host: arg[dialect]?.dbHost, + user: arg[dialect]?.dbUsername, + password: arg[dialect]?.dbPassword, + database: arg[dialect]?.dbName, + port: arg[dialect]?.dbPort, + }; + let databaseOptions: Knex.Config = {}; + let driver = ''; + switch (dialect) { + case 'postgres': + driver = 'PostgresSQL'; + databaseOptions = { + client: 'pg', + connection, + }; + break; + case 'mysql': + driver = 'MySQL'; + databaseOptions = { + client: 'mysql', + connection, + }; + break; + case 'sqlite': + driver = 'SQLite'; + databaseOptions = SqliteProvider.instance.config; + break; + default: + driver = 'Better SQLite 3'; + databaseOptions = BetterSqliteProvider.instance.config; + break; + } + const instance = require('knex')(databaseOptions); + await instance.raw('SELECT 1'); + await instance.destroy(); + return driver; + } } diff --git a/packages/desktop-ui-lib/src/lib/settings/settings.component.html b/packages/desktop-ui-lib/src/lib/settings/settings.component.html index 52ed631fb52..0bd1522da37 100644 --- a/packages/desktop-ui-lib/src/lib/settings/settings.component.html +++ b/packages/desktop-ui-lib/src/lib/settings/settings.component.html @@ -1178,7 +1178,7 @@

" [value]="item" > - {{ item }} + {{ item | replace: '-' : ' ' | titlecase }} @@ -1571,7 +1571,7 @@

- +

{{ 'TIMER_TRACKER.SETTINGS.DB_HOST' | translate }}

diff --git a/packages/desktop-ui-lib/src/lib/settings/settings.component.ts b/packages/desktop-ui-lib/src/lib/settings/settings.component.ts index bb9bda33aee..c28f4ccdf35 100644 --- a/packages/desktop-ui-lib/src/lib/settings/settings.component.ts +++ b/packages/desktop-ui-lib/src/lib/settings/settings.component.ts @@ -354,7 +354,7 @@ export class SettingsComponent implements OnInit, AfterViewInit { screenshotNotification = null; config = { /* Default Selected dialect */ - db: 'sqlite', + db: 'better-sqlite', /* Default Mysql config */ mysql: { dbHost: '127.0.0.1', @@ -404,7 +404,7 @@ export class SettingsComponent implements OnInit, AfterViewInit { ? [this.serverTypes.custom, this.serverTypes.live] : [this.serverTypes.integrated, this.serverTypes.custom, this.serverTypes.live]; - driverOptions = ['sqlite', 'postgres', ...(this.isDesktopTimer ? ['mysql'] : [])]; + driverOptions = ['better-sqlite', 'sqlite', 'postgres', ...(this.isDesktopTimer ? ['mysql'] : [])]; muted: boolean; delayOptions: number[] = [0.5, 1, 3, 24]; @@ -1034,6 +1034,9 @@ export class SettingsComponent implements OnInit, AfterViewInit { case 'mysql': this.config.db = 'mysql'; break; + case 'better-sqlite': + this.config.db = 'better-sqlite'; + break; default: break; } diff --git a/packages/desktop-ui-lib/src/lib/settings/settings.module.ts b/packages/desktop-ui-lib/src/lib/settings/settings.module.ts index 8e34c33b117..c18d207d8a3 100644 --- a/packages/desktop-ui-lib/src/lib/settings/settings.module.ts +++ b/packages/desktop-ui-lib/src/lib/settings/settings.module.ts @@ -28,6 +28,7 @@ import { LanguageModule } from '../language/language.module'; import { TranslateModule } from '@ngx-translate/core'; import { Store } from '../services'; import { LanguageSelectorService } from '../language/language-selector.service'; +import {TaskRenderModule} from "../time-tracker/task-render"; @NgModule({ declarations: [SettingsComponent], @@ -52,7 +53,8 @@ import { LanguageSelectorService } from '../language/language-selector.service'; NbSpinnerModule, DesktopDirectiveModule, LanguageModule, - TranslateModule + TranslateModule, + TaskRenderModule ], providers: [ NbToastrService, diff --git a/packages/desktop-ui-lib/src/lib/setup/setup.component.ts b/packages/desktop-ui-lib/src/lib/setup/setup.component.ts index a0d0fd8f825..690f5c06cdf 100644 --- a/packages/desktop-ui-lib/src/lib/setup/setup.component.ts +++ b/packages/desktop-ui-lib/src/lib/setup/setup.component.ts @@ -278,7 +278,7 @@ export class SetupComponent implements OnInit { if (this.databaseDriver.sqlite) { return { - db: 'sqlite', + db: 'better-sqlite', }; } diff --git a/packages/desktop-ui-lib/src/lib/time-tracker/task-render/task-render.module.ts b/packages/desktop-ui-lib/src/lib/time-tracker/task-render/task-render.module.ts index 4f764edd9b7..921e5824b97 100644 --- a/packages/desktop-ui-lib/src/lib/time-tracker/task-render/task-render.module.ts +++ b/packages/desktop-ui-lib/src/lib/time-tracker/task-render/task-render.module.ts @@ -52,7 +52,8 @@ import { TaskDetailComponent } from './task-detail/task-detail.component'; TranslateModule, NbPopoverModule, NbBadgeModule, - NbCardModule + NbCardModule, ], + exports: [ReplacePipe], }) export class TaskRenderModule {} diff --git a/yarn.lock b/yarn.lock index 768f2049dc0..9cfb7e5c85e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10020,6 +10020,14 @@ before-after-hook@^2.2.0: resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.2.3.tgz#c51e809c81a4e354084422b9b26bad88249c517c" integrity sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ== +better-sqlite3@^8.7.0: + version "8.7.0" + resolved "https://registry.yarnpkg.com/better-sqlite3/-/better-sqlite3-8.7.0.tgz#bcc341856187b1d110a8a47234fa89c48c8ef538" + integrity sha512-99jZU4le+f3G6aIl6PmmV0cxUIWqKieHxsiF7G34CVFiE+/UabpYqkU0NJIkY/96mQKikHeBjtR27vFfs5JpEw== + dependencies: + bindings "^1.5.0" + prebuild-install "^7.1.1" + big-integer@^1.6.17: version "1.6.51" resolved "https://registry.yarnpkg.com/big-integer/-/big-integer-1.6.51.tgz#0df92a5d9880560d3ff2d5fd20245c889d130686" @@ -10079,6 +10087,13 @@ binary@~0.3.0: buffers "~0.1.1" chainsaw "~0.1.0" +bindings@^1.5.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.5.0.tgz#10353c9e945334bc0511a6d90b38fbc7c9c504df" + integrity sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ== + dependencies: + file-uri-to-path "1.0.0" + bl@^4.0.2, bl@^4.0.3, bl@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/bl/-/bl-4.1.0.tgz#451535264182bec2fbbc83a62ab98cf11d9f7b3a" @@ -17024,6 +17039,11 @@ file-type@^3.3.0: resolved "https://registry.yarnpkg.com/file-type/-/file-type-3.9.0.tgz#257a078384d1db8087bc449d107d52a52672b9e9" integrity sha512-RLoqTXE8/vPmMuTI88DAzhMYC99I8BWv7zYP4A1puo5HIjEJ5EX48ighy4ZyKMG9EDXxBgW6e++cn7d1xuFghA== +file-uri-to-path@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd" + integrity sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw== + file-uri-to-path@2: version "2.0.0" resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-2.0.0.tgz#7b415aeba227d575851e0a5b0c640d7656403fba" @@ -29147,7 +29167,7 @@ preact@^10.0.5: resolved "https://registry.yarnpkg.com/preact/-/preact-10.13.1.tgz#d220bd8771b8fa197680d4917f3cefc5eed88720" integrity sha512-KyoXVDU5OqTpG9LXlB3+y639JAGzl8JSBXLn1J9HTSB3gbKcuInga7bZnXLlxmK94ntTs1EFeZp0lrja2AuBYQ== -prebuild-install@7.1.1: +prebuild-install@7.1.1, prebuild-install@^7.1.1: version "7.1.1" resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-7.1.1.tgz#de97d5b34a70a0c81334fd24641f2a1702352e45" integrity sha512-jAXscXWMcCK8GgCoHOfIr0ODh5ai8mj63L2nWrjuAgXE6tDyYGnx4/8o/rCgU+B4JSyZBKbeZqzhtwtC3ovxjw==