levibostian / ExpressjsBlanky

Blank Express.js project to get up and running FAST.
MIT License
7 stars 0 forks source link

Script to add sequelize migration files already done to DB on deploy #7

Closed levibostian closed 5 years ago

levibostian commented 5 years ago

When you create a brand new database, Sequelize creates a table called SequelizeMeta. Inside contains a list of migration files already executed. This is great and all, but the problem is that it is empty when a new database is created for the first time which results in all migration files being executed on a database when the migration CLI command is run. This is bad because sequelize migration scripts are not designed to handle "IF NOT EXISTS" scenarios.

Create a script that populates this SequelizeMeta table when a new DB is created. Or, think of some other way to handle this such as using Sequelize seeds to pre-populate the table.

levibostian commented 5 years ago

Instead of doing this, we will instead only use migrations for a database and no longer using sequelize.sync() (well, except for tests).

What I explain above has been done.