mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-12-01 04:52:17 -05:00
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'
|
'use strict'
|
||||||
|
const isSQLite = require('../utils').isSQLite
|
||||||
module.exports = {
|
module.exports = {
|
||||||
up: function (queryInterface, Sequelize) {
|
up: function (queryInterface, Sequelize) {
|
||||||
return queryInterface.changeColumn('Notes', 'title', {
|
return queryInterface.changeColumn('Notes', 'title', {
|
||||||
type: Sequelize.TEXT
|
type: Sequelize.TEXT
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
// manual added index will be removed in sqlite
|
if (isSQLite(queryInterface.sequelize)) {
|
||||||
return queryInterface.addIndex('Notes', ['shortid'])
|
// manual added index will be removed in sqlite
|
||||||
|
return queryInterface.addIndex('Notes', ['shortid'])
|
||||||
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -13,7 +16,10 @@ module.exports = {
|
||||||
return queryInterface.changeColumn('Notes', 'title', {
|
return queryInterface.changeColumn('Notes', 'title', {
|
||||||
type: Sequelize.STRING
|
type: Sequelize.STRING
|
||||||
}).then(function () {
|
}).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