Skip to content

Commit b77c474

Browse files
authored
Update SchemaMigrationService.js
1 parent e4822e4 commit b77c474

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

api/services/SchemaMigrationService.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ module.exports = class SchemaMigrationService extends Service {
1313
* @param model model object
1414
*/
1515
dropModel(model) {
16-
return model.sequelize.query('SET FOREIGN_KEY_CHECKS = 0').then(() => {
16+
const dialect = connection.dialect.connectionManager.dialectName
17+
return model.sequelize.query(dialect === 'sqlite' ? 'PRAGMA foreign_keys = OFF' : 'SET FOREIGN_KEY_CHECKS = 0').then(() => {
1718
return model.sync({force: true})
1819
}).then(() => {
19-
return model.sequelize.query('SET FOREIGN_KEY_CHECKS = 1')
20+
return model.sequelize.query(dialect === 'sqlite' ? 'PRAGMA foreign_keys = ON' : 'SET FOREIGN_KEY_CHECKS = 1')
2021
}).catch(err => {
2122
return model.sync({force: true})
2223
})

0 commit comments

Comments
 (0)