Prevent continued database publishing in node.js application

First of all, I use node.js with ORM and Postgres SQL sequencing.

I have 2 simple questions:

  1. Every time I restart, my sequelize application deletes and creates all the tables in the database. How to prevent this (I do not want my database entries to be deleted)? I tried to set my NODE_ENV to check, but that didn't help.

  2. How the sequelation migration occurs, knows where it stopped (which migrations were completed and which did not). For example, when I used a database migration in the Grails platform, it automatically created a table in the database in which all the timestamps of the migration that were executed before were stored, and when I restart my application, it looks at this table and knows which migrations already completed, and which not. I don't see tables when using node / sequelize, so how does it work? :)

Thank you Ivan

+7
source share
1 answer

As you already found out, tables are discarded because you do

sequelize.sync({ force: true }) 

The strength of the true part is the culprit

To your second question - the migration state is stored in a table in your db - I believe that it is called sequelize_meta

+10
source share

All Articles