Migration
With Sequelize you have a way to sync your model and your database. The thing is, this synchronization will remove all of your data in order to recreate all of the tables representing the model. So, this feature is useful in testing, but not in a production mode.
In order to manipulate your database, you have the possibility to use umzung
, a framework agnostic library and migration tool for Nodejs. It is not related to any database, but provides an API in order to migrate or rollback the migration.
When you are using the command npm run migrate up
, which executes ts-node migrate.ts
, you can pass up/down
as a parameter. In order to track all of the migration already applied, a new table will be created with the default
name SequelizeMeta
, and all of the applied migrations will be stored in this table.
Our migration file can be found in the repository as the root with the name migrate.ts
. Also, all of the migrations files will be stored in the migrations
folder of the repository...