Development Tasks

Database Migrations

Database migrations are managed using golang-migrate/migrate. The CLI is already available when using Remote-Containers, otherwise it will need to be installed.

How to add a migration

A migration can be added by creating an up and down migration file in the migrations folder. The migration file names should be named according to {sequentialNumber}{description}.up.sql and {sequentialNumber}{description}.down.sql. Migrations can be created with the following command.

make migration name=<NAME>

Populate the up and down scripts. Up scripts should be idempotent. Down scripts should revert all changes made by up script

How to run a migration

Migrations can be applied using the CLI

make migrate-up

Generating Swagger Docs

When using Remote-Containers, swagger documentation can be updated using.

make swagger

Otherwise, follow instructions in ./docs/README.md to install swagger first.

Querying Postgres

The following options are available if using Remote-Containers.

Troubleshooting devContainer

Sometimes i'm getting an error when tryign to build the containers.

Command failed: docker inspect --type image memberdashboard_dev

This happened after I ran a docker system prune -a, but I think I've seen it before.

To fix this, build the containers with the following command then reopen vscode in Container

docker-compose -f docker-compose.yml -f .devcontainer/docker-compose.yml build