From 8d29d8a744dfec3b3667b9844b38beaf7006b489 Mon Sep 17 00:00:00 2001 From: Asara Date: Sat, 18 Jan 2020 14:58:55 -0500 Subject: [PATCH] Update Readme to include migrations --- README.md | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b1e58c9..fe264bd 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,15 @@ Install steps are for Debian 9 (stretch) export GOPATH=${HOME}/go ``` -3. Clone repo and configure the settings +3. Install migrate + ``` + # this assumes you have ${GOPATH}/bin in your ${PATH} + go get -u -d github.com/mattes/migrate/cli github.com/lib/pq + go build -tags 'postgres' -o ${GOPATH}/bin/migrate github.com/mattes/migrate/cli + + ``` + +4. Clone repo and configure the settings ``` mkdir -p ${GOPATH}/src/git.minhas.io/asara cd ${GOPATH}/src/git.minhas.io/asara @@ -45,7 +53,7 @@ Install steps are for Debian 9 (stretch) # make sure the extension is .env (db.env, secrets.env, website.env... etc.) ``` -4. Configure docker postgres for testing +5. Configure docker postgres for testing ``` # make sure your user is in the docker group sudo usermod -aG docker $(whoami) @@ -61,14 +69,17 @@ Install steps are for Debian 9 (stretch) CREATE DATABASE ${DB_NAME}; CREATE USER ${DB_USER} WITH ENCRYPTED PASSWORD '${DB_PW}'; GRANT ALL PRIVILEGES ON DATABASE ${DB_NAME} TO ${DB_USER}; + ALTER DATABASE ${DB_NAME} OWNER TO ${DB_USER}; EOF ``` -5. Run the application! +6. Run the application! ``` cd ${GOPATH}/src/git.minhas.io/asara/sudoscientist-go-backend for i in settings/*; do source $i; done export DB_HOST=$(docker inspect -f "{{ .NetworkSettings.IPAddress }}" sudosci-db) + PSQL_QUERY_STRING="postgres://${DB_USER}:${DB_PW}@${DB_HOST}:${DB_PORT}/${DB_NAME}?sslmode=${DB_SSL}" + migrate -path migrations/ -database ${PSQL_QUERY_STRING} up go get go run main.go ```