From 0270553601a2720006ad400a0e7951c1f9631c33 Mon Sep 17 00:00:00 2001 From: chenos Date: Wed, 1 Jun 2022 11:41:46 +0800 Subject: [PATCH] fix(database): add timezone support --- packages/app/server/src/config/database.ts | 1 + packages/core/database/src/database.ts | 4 ++++ packages/core/database/src/mock-database.ts | 1 + 3 files changed, 6 insertions(+) diff --git a/packages/app/server/src/config/database.ts b/packages/app/server/src/config/database.ts index 25c7beb7e..750bcfe67 100644 --- a/packages/app/server/src/config/database.ts +++ b/packages/app/server/src/config/database.ts @@ -9,4 +9,5 @@ export default { database: process.env.DB_DATABASE, host: process.env.DB_HOST, port: process.env.DB_PORT as any, + timezone: process.env.DB_TIMEZONE, } as IDatabaseOptions; diff --git a/packages/core/database/src/database.ts b/packages/core/database/src/database.ts index c2a87f7d4..233c2e8df 100644 --- a/packages/core/database/src/database.ts +++ b/packages/core/database/src/database.ts @@ -92,6 +92,10 @@ export class Database extends EventEmitter implements AsyncEmitter { } } + if (options.dialect === 'sqlite') { + delete opts.timezone; + } + this.sequelize = new Sequelize(opts); this.options = opts; this.collections = new Map(); diff --git a/packages/core/database/src/mock-database.ts b/packages/core/database/src/mock-database.ts index db56b0388..9581581f4 100644 --- a/packages/core/database/src/mock-database.ts +++ b/packages/core/database/src/mock-database.ts @@ -33,6 +33,7 @@ export function getConfigByEnv() { charset: 'utf8mb4', collate: 'utf8mb4_unicode_ci', }, + timezone: process.env.DB_TIMEZONE, }; }