-
Notifications
You must be signed in to change notification settings - Fork 12
DB Migrations
tiblu edited this page Oct 23, 2018
·
15 revisions
Database migrations are a way to update database structure (migrate) to a new one or roll back to previous one. For example when citizenos-api code change requires a change in DB structure, these changes can be easily applied and reverted on an existing database. You can think of it as database versioning.
Citizen OS API uses Sequelize ORM and their standard migrations system.
Please read before going any further:
There are some shortcuts described in package.json:
-
dbstatus- Migration status. Runs Sequelizedb:migrate:status. -
dbmigrate- Run migration. Runs Sequelizedb:migrate. -
dbrollback- Roll back migration. Runs Sequelizedb:migrate:undo.
These are used as any other NPM script - npm run <command>.
Please read before going any further:
RULES:
- Any change in the model has to be described as a migration.
- You have to test that migration and rollback works.