sequelize generate migration
npx sequelize-cli migration:generate --name add-title-post-table
sequelize generate migration
npx sequelize-cli migration:generate --name add-title-post-table
sequelize migration default value
queryInterface.addColumn('OrderBackups', 'my_column', {
type: Sequelize.INTEGER,
defaultValue: 0
})
sequelize migration add column
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.sequelize.transaction((t) => {
return Promise.all([
queryInterface.addColumn('table_name', 'field_one_name', {
type: Sequelize.STRING
}, { transaction: t }),
queryInterface.addColumn('table_name', 'field_two_name', {
type: Sequelize.STRING,
}, { transaction: t })
])
})
},
down: (queryInterface, Sequelize) => {
return queryInterface.sequelize.transaction((t) => {
return Promise.all([
queryInterface.removeColumn('table_name', 'field_one_name', { transaction: t }),
queryInterface.removeColumn('table_name', 'field_two_name', { transaction: t })
])
})
}
};
sequelize migration add default value
queryInterface.addColumn('My_table', 'my_column', {
type: Sequelize.INTEGER,
defaultValue: 0
})
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us