diff --git a/app/dao/db/index.js b/app/dao/db/index.js index ab1fb031..546d705c 100644 --- a/app/dao/db/index.js +++ b/app/dao/db/index.js @@ -87,7 +87,7 @@ databases.forEach((database) => { dbModels.forEach(async function (dbModel) { let tableName = dbModel.replace(/\.js$/g, ''); - tableObj[_.camelCase(tableName)] = sequelize.import(dbModelsPath + '/' + tableName); + tableObj[_.camelCase(tableName)] = require(`${dbModelsPath}/${tableName}`)(sequelize, Sequelize); try { diff --git a/app/service/gateway/GatewayObjManager.js b/app/service/gateway/GatewayObjManager.js index 7ffab261..dfd8cfb7 100644 --- a/app/service/gateway/GatewayObjManager.js +++ b/app/service/gateway/GatewayObjManager.js @@ -98,7 +98,7 @@ class GatewayObjManager{ let dbModels = fs.readdirSync(dbModelsPath); dbModels.forEach(function (dbModel) { let tableName = dbModel.replace(/\.js$/g, ''); - dbObj[_.camelCase(tableName)] = sequelize.import(dbModelsPath + '/' + tableName); + dbObj[_.camelCase(tableName)] = require(`${dbModelsPath}/${tableName}`)(sequelize, Sequelize); dbObj[_.camelCase(tableName)].sync({ alter: false }); }) dbObj.seq = sequelize diff --git a/dcache/db/index.js b/dcache/db/index.js index a71370e6..5c82244d 100644 --- a/dcache/db/index.js +++ b/dcache/db/index.js @@ -77,7 +77,7 @@ databases.forEach((database) => { dbModels.forEach(async (dbModel) => { const tableName = dbModel.replace(/\.js$/g, ''); try { - tableObj[_.camelCase(tableName)] = sequelize.import(`${dbModelsPath}/${tableName}`); + tableObj[_.camelCase(tableName)] = require(`${dbModelsPath}/${tableName}`)(sequelize, Sequelize); // sync 无表创建表, alter 新增字段 // tableObj[_.camelCase(tableName)].sync(); await tableObj[_.camelCase(tableName)].sync({ alter: true }); diff --git a/dcache/db/index_tpl.js b/dcache/db/index_tpl.js index 5a41373b..0053d96a 100644 --- a/dcache/db/index_tpl.js +++ b/dcache/db/index_tpl.js @@ -61,7 +61,7 @@ module.exports = { dbModels.forEach(async (dbModel) => { const tableName = dbModel.replace(/\.js$/g, ''); try { - tableObj[_.camelCase(tableName)] = sequelize.import(`${dbModelsPath}/${tableName}`); + tableObj[_.camelCase(tableName)] = require(`${dbModelsPath}/${tableName}`)(sequelize, Sequelize); // sync 无表创建表, alter 新增字段 // tableObj[_.camelCase(tableName)].sync(); await tableObj[_.camelCase(tableName)].sync({ alter: true }); diff --git a/package.json b/package.json index db363fb6..23495822 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "q": "^1.5.1", "request": "^2.87.0", "request-promise-any": "^1.0.5", - "sequelize": "^5.21.2", + "sequelize": "^6.3.5", "sha1": "^1.1.1", "svg-captcha": "^1.4.0", "url": "^0.11.0", diff --git a/sso/app/dao/db/index.js b/sso/app/dao/db/index.js index 42ad16eb..822062cf 100644 --- a/sso/app/dao/db/index.js +++ b/sso/app/dao/db/index.js @@ -74,7 +74,7 @@ databases.forEach((database)=>{ let tableName = dbModel.replace(/\.js$/g, ''); try { - tableObj[_.camelCase(tableName)] = sequelize.import(dbModelsPath + '/' + tableName); + tableObj[_.camelCase(tableName)] = require(`${dbModelsPath}/${tableName}`)(sequelize, Sequelize); await tableObj[_.camelCase(tableName)].sync({alter: true}); logger.info('database ' + database + '.' + tableName + ' sync succ');