Forked from s1moe2/20181118235404-some-migration.js
Created
October 16, 2019 09:54
-
-
Save apjyotirmay/66a568f66bda5fbdb36524d253b7b7b1 to your computer and use it in GitHub Desktop.
Sequelize migration add/drop multiple columns (transacting)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
up: (queryInterface, Sequelize) => { | |
return queryInterface.sequelize.transaction((t) => { | |
return Promise.all([ | |
queryInterface.addColumn('table_name', 'column_name1', { | |
type: Sequelize.STRING | |
}, { transaction: t }), | |
queryInterface.addColumn('table_name', 'column_name2', { | |
type: Sequelize.STRING, | |
}, { transaction: t }) | |
]) | |
}) | |
}, | |
down: (queryInterface, Sequelize) => { | |
return queryInterface.sequelize.transaction((t) => { | |
return Promise.all([ | |
queryInterface.removeColumn('table_name', 'column_name1', { transaction: t }), | |
queryInterface.removeColumn('table_name', 'column_name2', { transaction: t }) | |
]) | |
}) | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment