It is important that any changes made to the database models include migrations that can modify the database state from one state to another.
Whilst we use Sequelize as our ORM layer, we do not use the migration tooling it provides - we have our own.
Creating migrations
Filename
A migration is provided as a JavaScript in the directory forge/db/migrations
. Its file name must follow the pattern:
YYYYMMDD-nn-description.js
YYYYMMDD
- the date the migration is addednn
- a two digit numberdescription
- a name for the migration
For example 20220204-01-add-billing.js
.
This ensures the migrations have a natural order to be applied. The nn
part of the name allows multiple migrations to be added on the same day, but kept in the right order.