Basic Koa-based backend with Postgres with router and body parsing middleware.
Name | Description |
---|---|
start |
Starts the server and postgres in watch mode |
build |
Builds the project |
db:migrate |
Runs database migrations |
Migrations are handled with postgres-migrations.
Migrations should only be run once, but this is a good principle to follow regardless.
Once applied (to production), a migration cannot be changed.
This is enforced by storing a hash of the file contents for each migration in the migrations table.
These hashes are checked when running migrations.
Backwards incompatible changes can usually be made in a few stages.
For an example, see this blog post.
A migration file must match the following pattern:
[id][separator][name][extension]
Example:
migrations
├ 00001-create-initial-tables.sql
├ 00002-alter-initial-tables.sql
└ 00003-alter-initial-tables-again.sql
Migrations will be performed in the order of the ids. If ids are not consecutive or if multiple migrations have the same id, the migration run will fail.
Note that file names cannot be changed later.