-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a new database table for subjects
We need to store basic information about the infrasture we store results for. Create a table called `subjects` for this purpose. This partially addresses #29.
- Loading branch information
Showing
5 changed files
with
42 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP TABLE IF EXISTS subjects; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CREATE TABLE IF NOT EXISTS subjects ( | ||
id serial PRIMARY KEY, | ||
name VARCHAR(255), | ||
type VARCHAR(50) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,31 @@ | ||
# Database Migrations | ||
|
||
This folder contains database migrations for the compliance service using | ||
[golang-migrate/migrate](https://github.com/golang-migrate/migrate). Please | ||
refer to migrate | ||
[documentation](https://github.com/golang-migrate/migrate/tree/master/cmd/migrate). | ||
[golang-migrate/migrate](https://github.com/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](https://github.com/golang-migrate/migrate/tree/master/cmd/migrate) | ||
for installation instructions. | ||
|
||
## Examples | ||
|
||
These examples assume you have a PostgreSQL server accessible with a database | ||
named `compliance`, and you've properly | ||
[escaped](https://github.com/golang-migrate/migrate#database-urls) the database | ||
password. You can refer to the deployment documentation in the | ||
[README.md](../README.md) for instructions on using terraform to deploy a | ||
database using AWS RDS. | ||
|
||
Apply all migrations: | ||
|
||
```console | ||
$ POSTGRESQL_URL="postgres://$USER:$PASSWORD@$DATABASE_ENDPOINT/compliance | ||
$ ./migrate -database $POSTGRESQL_URL -path migrations up | ||
``` | ||
|
||
Apply all down migrations: | ||
|
||
```console | ||
$ ./migrate -database $POSTGRESQL_URL -path migrations down | ||
``` |