First of all, I am using node.js with sequelize ORM and Postgres SQL.
I have 2 simple questions:
Every time I rerun my node application sequelize is dropping and creating all tables in database. How to prevent it from doing that (I don't want my records in database to be deleted)? I have tried to set my NODE_ENV to test but it didn't help.
How does sequelize migration knows where it stopped (which migration have executed and which not). When I was using database migration in Grails framework, for example, it automatically created a table in the database where it kept all migration timestamps that executed before and when I rerun my application it looks at that table and knows which migrations are already done and which are not. I don't see any table when using node/sequelize, so how it works? :)
Thanks, Ivan
As you already figured out, the tables are being dropped because you are doing
sequelize.sync({ force: true })
The force true part being the culprit
To your second question - the state of migrations is saved in a table in your db - i believe it's called sequelize_meta
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With