fix(database): add timezone support

This commit is contained in:
chenos 2022-06-01 11:41:46 +08:00
parent ec34c34e31
commit 0270553601
3 changed files with 6 additions and 0 deletions

View File

@ -9,4 +9,5 @@ export default {
database: process.env.DB_DATABASE, database: process.env.DB_DATABASE,
host: process.env.DB_HOST, host: process.env.DB_HOST,
port: process.env.DB_PORT as any, port: process.env.DB_PORT as any,
timezone: process.env.DB_TIMEZONE,
} as IDatabaseOptions; } as IDatabaseOptions;

View File

@ -92,6 +92,10 @@ export class Database extends EventEmitter implements AsyncEmitter {
} }
} }
if (options.dialect === 'sqlite') {
delete opts.timezone;
}
this.sequelize = new Sequelize(opts); this.sequelize = new Sequelize(opts);
this.options = opts; this.options = opts;
this.collections = new Map(); this.collections = new Map();

View File

@ -33,6 +33,7 @@ export function getConfigByEnv() {
charset: 'utf8mb4', charset: 'utf8mb4',
collate: 'utf8mb4_unicode_ci', collate: 'utf8mb4_unicode_ci',
}, },
timezone: process.env.DB_TIMEZONE,
}; };
} }