Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
52 lines (43 loc) · 1.81 KB
/
Copy pathMakefile
File metadata and controls
52 lines (43 loc) · 1.81 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
SHELL := /bin/bash
.PHONY: reset-db-to-defaults
##
## Note:
## Hasura commands require the flag --admin-secret defined in the .env file
## or via the flag in the command itself.
##
# Main commands
# ----------------------------------------------------------------
reset-db-to-defaults:
@echo "====================================================================="
@echo " ERD - eScience Center "
@echo "====================================================================="
@echo "=> Restore/install Sample DB. All local database changes will be lost: "
@read -p "Continue to restore the data? [y/N]" -n 1 -r; \
if [[ $$REPLY =~ ^[Yy] ]]; \
then \
make restore-data; \
fi
restore-data:
@docker-compose down
@docker-compose up -d postgres
@echo "Waking up postgres container..."
@./scripts/wait-for localhost:`docker port erd-postgres | sed 's/\(.*\)\/.*/\1/'`
docker exec -i erd-postgres dropdb -U postgres postgres
docker exec -i erd-postgres createdb -U postgres postgres
docker-compose up -d
@echo "Waking up hasura container..."
@./scripts/wait-for localhost:`docker port erd-hasura | sed 's/\(.*\)\/.*/\1/'`
docker exec -i erd-postgres psql --username postgres postgres < ./CI/dev-data-dump.sql
make hasura-apply-migrations
make hasura-apply-metadata
@echo "DONE."
# HASURA METADATA
################################
hasura-metadata-export:
cd hasura && npx hasura metadata export --admin-secret adminpassword
hasura-apply-metadata:
cd hasura && npx hasura metadata apply --admin-secret adminpassword # --endpoint http://another-graphql-instance.herokuapp.com
hasura-apply-migrations:
cd hasura && npx hasura migrate apply --admin-secret adminpassword
hasura-restore-full:
cat db/dev.dumpall.sql | docker exec -i postgres-container psql -U postgres -d postgres < db/dev.dumpall.sql