Skip to content

Latest commit

 

History

History
45 lines (34 loc) · 1.36 KB

README.md

File metadata and controls

45 lines (34 loc) · 1.36 KB

Database Migrations

This folder contains database migrations for the compliance service using golang-migrate/migrate.

This project requires using the migrate CLI to change the database schema and to add new migrations. Please refer to the documentation for installation instructions or simply run make tools/migrate from the root of this project.

Examples

These examples assume you have a PostgreSQL server accessible with a database named compliance, and you've properly escaped the database password. You can refer to the deployment documentation in the README.md for instructions on using terraform to deploy a database using AWS RDS.

Apply all migrations:

$ POSTGRESQL_URL="postgres://$USER:$PASSWORD@$DATABASE_ENDPOINT/compliance
$ ./migrate -database $POSTGRESQL_URL -path migrations up

Apply all down migrations:

$ ./migrate -database $POSTGRESQL_URL -path migrations down

Test

To run a quick and easy test of the migrations, use the test.sh script:

bash migrations/test.sh

If you don't have the migrate CLI tool installed in your $PATH, run:

make tools/migrate
PATH=$PATH:$(pwd)/tools bash migrations/test.sh