Repository navigation
docs(migrations): added advanced skeleton example - #10190
Conversation
sushantdhiman
left a comment
There was a problem hiding this comment.
While this actually wont ensure complete rollback (SequelizeMeta entry wont be rolled back) but this effectively demonstrate how to use transactions so I will accept this
Codecov Report
@@ Coverage Diff @@
## master #10190 +/- ##
=======================================
Coverage 96.34% 96.34%
=======================================
Files 63 63
Lines 9420 9420
=======================================
Hits 9076 9076
Misses 344 344Continue to review full report at Codecov.
|
|
@sunshinewyin Thank you for looking into this PR and for your feedback. module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.sequelize.transaction((t) => {
return Promise.all([
queryInterface.addColumn('Users', 'petName', {
type: Sequelize.STRING
}, { transaction: t }),
queryInterface.addColumn('UserWRONGNAME', 'favoriteColor', {
type: Sequelize.STRING,
}, { transaction: t })
])
})
},
down: (queryInterface, Sequelize) => {
return queryInterface.sequelize.transaction((t) => {
return Promise.all([
queryInterface.removeColumn('User', 'petName', { transaction: t }),
queryInterface.removeColumn('User', 'favoriteColor', { transaction: t })
])
})
}
}; |
Description of change
Added an example of a more advanced migration skeleton