- Useful tools to install
- Migrate CLI - https://github.com/golang-migrate/migrate/tree/master/cmd/migrate
- Just - https://github.com/casey/just
- Running the backend tests:
just backend_test
- Creating a new migration
In the backend
directory, run:
migrate create -ext sql -dir db/migrations/sql -seq <migration_name>
- Fixing a migration
In the backend directory: when you encounter the following error when a migration is faulty
error: Dirty database version 2. Fix and force version.
run the following command:
migrate -database "your_database_url" -path db/migrations/sql force 1
then:
migrate -path db/migrations/sql -database "your_database_url" up