-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
28 lines (22 loc) · 1.34 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
dev:
docker-compose -f docker-compose-local-db.yml up --build
clean:
docker system prune -f && docker volume prune -f
clean-images:
docker images prune
# Requires argument `dbname` to specify the name of the new DB, usage: `make local-db dbname=my_db dbfile=mydb.sql`
# Requires argument `dbfile` to specify the name of the DB dump file to recreate, usage: `make local-db dbname=my_db dbfile=mydb.sql`
local-db:
cd db && docker exec --workdir / rubin-obs-api-postgres-1 psql -U craft -c "create database $(dbname);"
cd db && docker exec --workdir / rubin-obs-api-postgres-1 psql -U craft -d $(dbname) -f $(dbfile)
echo "\n\n\n\nDon't forget to update your docker-compose-local-db.yaml with the DB name: $(dbname)"
db-list:
cd db && docker exec --workdir / rubin-obs-api-postgres-1 psql -U craft -c "SELECT (pg_stat_file('base/'||oid ||'/PG_VERSION')).modification, datname FROM pg_database;"
cloud-db-list:
curl https://us-central1-edc-prod-eef0.cloudfunctions.net/sql-helper/databases\?project\=rubinobs
# Requires argument `dbname` to specify the name of the DB to be exported, usage: `make cloud-db-export dbname=prod_db`
cloud-db-export:
curl --header "Content-Type: application/json" \
--request POST \
--data '{"project":"rubinobs"}' \
https://us-central1-edc-prod-eef0.cloudfunctions.net/sql-helper/databases\?action\=export\&database\=$(dbname)