Database schema is managed using Goose database migration tool
Database can be setup using Docker.
Configure the database environment
in docker-compose.yml
. (If you hate defaults...)
environment:
- MYSQL_DATABASE: <schema_name>
- MYSQL_USER: <username>
- MYSQL_PASSWORD: <password>
- MYSQL_ROOT_PASSWORD: <root_password>
Then execute, to start docker image in detached mode
docker-compose up -d
Migrations are handled with Golang + Goose library
To install goose
go get -u github.com/pressly/goose/cmd/goose
For a full list of migration commands see Goose usage
cd migrations
goose mysql "kcapp:abcd1234@tcp(localhost:3366)/kcapp?parseTime=true" status
cd migrations
goose mysql "kcapp:abcd1234@tcp(localhost:3366)/kcapp?parseTime=true" up
To create a new migration run
cd migrations
goose create create_table_my_new_table sql