26 lines
769 B
Makefile

PGSQL_CONTAINER_ID=`cat postgres.container.id`
DB_NAME="personal_measure"
start-db: start-postgres
postgres.container.id:
docker run --name postgres-$(DB_NAME) -e POSTGRES_PASSWORD=password -p 5500:5432 -d postgres > postgres.container.id
sleep 5
PGPASSWORD=password psql -p 5500 -U postgres -h localhost -c "CREATE DATABASE $(DB_NAME);"
db_migrate up -c database-local.json
start-postgres: postgres.container.id
docker start $(PGSQL_CONTAINER_ID)
db_migrate up -c database-local.json
stop-postgres: postgres.container.id
docker stop $(PGSQL_CONTAINER_ID)
delete-postgres-container:
-docker stop $(PGSQL_CONTAINER_ID)
docker container rm $(PGSQL_CONTAINER_ID)
rm postgres.container.id
connect:
PGPASSWORD=password psql -p 5500 -U postgres -h localhost