fix: support mysql lower_case_table_names=1

This commit is contained in:
chenos 2023-02-25 00:54:45 +08:00
parent 94e38e453a
commit 9d1b10d635
2 changed files with 3 additions and 2 deletions

View File

@ -30,6 +30,7 @@ DB_TABLE_PREFIX=
# DB_USER=nocobase # DB_USER=nocobase
# DB_PASSWORD=nocobase # DB_PASSWORD=nocobase
# DB_LOGGING=on # DB_LOGGING=on
# DB_UNDERSCORED=true
################# CACHE ################# ################# CACHE #################
# default is memory cache, when develop mode,code's change will be clear memory cache, so can use 'cache-manager-fs-hash' # default is memory cache, when develop mode,code's change will be clear memory cache, so can use 'cache-manager-fs-hash'

View File

@ -482,8 +482,8 @@ export class Application<StateT = DefaultState, ContextT = DefaultContext> exten
if (this.db.inDialect('mysql')) { if (this.db.inDialect('mysql')) {
const result = await this.db.sequelize.query(`SHOW VARIABLES LIKE 'lower_case_table_names'`, { plain: true }); const result = await this.db.sequelize.query(`SHOW VARIABLES LIKE 'lower_case_table_names'`, { plain: true });
if (result?.Value === '1') { if (result?.Value === '1' && !this.db.options.underscored) {
console.log(chalk.red(`mysql variable 'lower_case_table_names' must be set to '0' or '2'`)); console.log(`Your database lower_case_table_names=1, please add ${chalk.yellow('DB_UNDERSCORED=true')} to the .env file`);
if (options?.exit) { if (options?.exit) {
process.exit(); process.exit();
} }