Skip to content

Latest commit

 

History

History
45 lines (34 loc) · 1.1 KB

File metadata and controls

45 lines (34 loc) · 1.1 KB

Database

ranked-pick-api uses a SQLite3 database for storage.

Console

To access the local database:

export DB_URL="sqlite3.db"
sqlite3 $DB_URL

Migrations

golang-migrate is used for migration management.

Command installation

go install -tags 'sqlite3' github.com/golang-migrate/migrate/v4/cmd/migrate@latest

To create a migration:

migrate create -ext sql -dir migrations -seq sample_migration_name

To run up migrations:

migrate -database sqlite3://${DB_URL} -path db/migrations up

To roll back a single migration:

migrate -database sqlite3://${DB_URL} -path db/migrations down 1

To drop the db:

migrate -database sqlite3://${DB_URL} -path db/migrations drop

After a migration error is encountered, the DB is marked dirty and a migration version must be forced before any more migrations can be run:

migrate -database sqlite3://${DB_URL} -path db/migrations force <DB VERSION BEFORE ERROR>