mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-19 01:35:18 -04:00

Instead of using sequelize-cli and ensure migrations by shellscript, this patch automates database migrations properly to the umzug library. The sequelize CLI becomes a dev dependencies as it's still useful for generating migrations. This should eliminate the need for crude generating of database config files and alike. Instead we utilize the pre-configured sequelize connection that CodiMD will use anyway. Signed-off-by: Sheogorath <sheogorath@shivering-isles.com>
28 lines
817 B
JavaScript
28 lines
817 B
JavaScript
'use strict'
|
|
function isSQLite (sequelize) {
|
|
return sequelize.options.dialect === 'sqlite'
|
|
}
|
|
|
|
module.exports = {
|
|
up: async function (queryInterface, Sequelize) {
|
|
return queryInterface.changeColumn('Notes', 'title', {
|
|
type: Sequelize.TEXT
|
|
}).then(function () {
|
|
if (isSQLite(queryInterface.sequelize)) {
|
|
// manual added index will be removed in sqlite
|
|
return queryInterface.addIndex('Notes', ['shortid'])
|
|
}
|
|
})
|
|
},
|
|
|
|
down: async function (queryInterface, Sequelize) {
|
|
return queryInterface.changeColumn('Notes', 'title', {
|
|
type: Sequelize.STRING
|
|
}).then(function () {
|
|
if (isSQLite(queryInterface.sequelize)) {
|
|
// manual added index will be removed in sqlite
|
|
return queryInterface.addIndex('Notes', ['shortid'])
|
|
}
|
|
})
|
|
}
|
|
}
|