Code of Let’s Go Further book by Alex Edwards
Log in to database (first time):
docker exec -it postgresql-greenlight psql -U postgres
Create database:
CREATE DATABASE greenlight;
Connect to database:
\c greenlight
Create database user:
CREATE ROLE greenlight WITH LOGIN PASSWORD 'pa55word';
Add citext extension: Note: This adds a case-insensitive character string type to PostgreSQL.
CREATE EXTENSION IF NOT EXISTS citext;
Log in with new user:
docker exec -it postgresql-greenlight psql --host=localhost --dbname=greenlight --username=greenlight
Install migration tool:
brew install golang-migrate
Grant privileges to user:
GRANT ALL ON SCHEMA public TO greenlight;
To run migrations:
migrate -path=./migrations -database="postgres://greenlight:pa55word@localhost/greenlight?sslmode=disable" up