Docker
env | grep ^PG
PGPASSWORD=my_password
PGHOST=localhost
PGPORT=5432
PGUSER=postgres
PGDATABASE=golang_crud_example_dev
- ./manage/destroy_db_container (optional)
- ./manage/create_db_container
- ./manage/create_db
- ./manage/seed_db
- ./manage/psql # test the connection
- [HTTP_SOCKET=localhost:8080] ./manage/run
./manage/reset_db
./manage/psql-pipe -a < ./db/migrations/up/1.sql
./manage/psql-pipe -a < ./db/migrations/down/1.sql
cat ./db/migrations/down/{02..01}.sql | ./manage/psql-pipe -a
cat ./db/migrations/up/{01..02}.sql | ./manage/psql-pipe -a
or
find ./db/migrations/down/ -type f -name "*.sql" | sort -rn | xargs cat | ./manage/psql-pipe
find ./db/migrations/up/ -type f -name "*.sql" | sort -n | xargs cat | ./manage/psql-pipe
./manage/psql-pipe -c "SELECT max(version) FROM migrations"
./manage/pg_dump -s $PGDATABASE >./db/schema.sql
cat ./queries/addresses.sql | ./manage/psql-pipe