xxxxxxxxxx
- Create Migration: npx sequelize-cli migration:generate --name NAME_OF_YOUR_MIGRATION/MIGRATION_TITLE
- Migration Up: npx sequelize-cli db:migrate
- Migration Down(one): npx sequelize-cli db:migrate:undo
- Migration Down(all): npx sequelize-cli db:migrate:undo:all
xxxxxxxxxx
queryInterface.changeColumn(
'table_name',
'Column_name',
{
type: Sequelize.TEXT,
},
),
queryInterface.sequelize.query('drop type enum_tableName_columnName;')
.then(() => queryInterface.changeColumn(
'table_name',
'column_name',
{
type: Sequelize.ENUM('value1','value2'),
},
)),
xxxxxxxxxx
queryInterface.createTable(
'Posts',
{
title: {
type: Sequelize.DataTypes.STRING(100),
allowNull: false
}
}
);
xxxxxxxxxx
$ yarn add github:scimonster/sequelize-auto-migrations#a063aa6535a3f580623581bf866cef2d609531ba
xxxxxxxxxx
I recommend using sequelize migrations in development and production so that you are fully acclimate with the process which will give safe results,
also sequelize sync without force will only create new tables with the specified schema which are not present in database, it wont reflect alterations in existing table schema.
Sequelize migrations will help you update your database in a systematic and incremental manner.
Good luck !