node.js - How to use migrations in Sequelize? -
i have used orms such entityframework, waterline , mongoose. started using sequelize. have created sample model. later wanted add column table corresponding same model. when edit model, new field doesn't seem reflecting in table unless drop table. supposed use migrations? got confused after reading documentation. me out?
yes, should use migrations if edit model in sequelize when application starts create table if doesn't exist. not check if schema different doesn't update schema of table.
if you, install sequelize-cli
, run sequelize init
command. sets project ready use migrations.
please note using sequelize migrations have explicitly define primary key, updatedat , createdat columns otherwise not great created!
the docs not bad migrations: http://sequelize.readthedocs.org/en/latest/docs/migrations/
Comments
Post a Comment