fix: Other dialect duplicated add index problem
Detect is using SQLite to add index
This commit is contained in:
parent
e26bb0503f
commit
e46874d04a
2 changed files with 14 additions and 3 deletions
|
@ -1,11 +1,14 @@
|
|||
'use strict'
|
||||
const isSQLite = require('../utils').isSQLite
|
||||
module.exports = {
|
||||
up: function (queryInterface, Sequelize) {
|
||||
return queryInterface.changeColumn('Notes', 'title', {
|
||||
type: Sequelize.TEXT
|
||||
}).then(function () {
|
||||
// manual added index will be removed in sqlite
|
||||
return queryInterface.addIndex('Notes', ['shortid'])
|
||||
if (isSQLite(queryInterface.sequelize)) {
|
||||
// manual added index will be removed in sqlite
|
||||
return queryInterface.addIndex('Notes', ['shortid'])
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
|
@ -13,7 +16,10 @@ module.exports = {
|
|||
return queryInterface.changeColumn('Notes', 'title', {
|
||||
type: Sequelize.STRING
|
||||
}).then(function () {
|
||||
return queryInterface.addIndex('Notes', ['shortid'])
|
||||
if (isSQLite(queryInterface.sequelize)) {
|
||||
// manual added index will be removed in sqlite
|
||||
return queryInterface.addIndex('Notes', ['shortid'])
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
5
lib/utils.js
Normal file
5
lib/utils.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
'use strict'
|
||||
|
||||
exports.isSQLite = function isSQLite (sequelize) {
|
||||
return sequelize.options.dialect === 'sqlite'
|
||||
}
|
Loading…
Reference in a new issue