-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdb
executable file
·51 lines (45 loc) · 1.32 KB
/
db
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
#!/bin/bash
if [[ "$(docker images -q graphql-dev 2> /dev/null)" == "" ]]; then
echo -ne 'building container...'
docker build -t graphql-dev -f dev.Dockerfile . > /dev/null 2>&1
echo -ne '\t\t [done]\n'
fi
migrate() {
docker run --rm \
--name refinery-gateway-migration \
-e POSTGRES=postgresql://postgres:kern@graphql-postgres:5432 \
--mount type=bind,source="$(pwd)"/,target=/app \
--network dev-setup_default \
--entrypoint /usr/local/bin/alembic \
graphql-dev upgrade head
}
commit() {
docker run --rm \
--name refinery-gateway-migration \
-e POSTGRES=postgresql://postgres:kern@graphql-postgres:5432 \
--mount type=bind,source="$(pwd)"/,target=/app \
--network dev-setup_default \
--entrypoint /usr/local/bin/alembic \
graphql-dev revision --autogenerate -m "$@"
}
alembic() {
docker run --rm \
--name refinery-gateway-migration \
-e POSTGRES=postgresql://postgres:kern@graphql-postgres:5432 \
--mount type=bind,source="$(pwd)"/,target=/app \
--network dev-setup_default \
--entrypoint /usr/local/bin/alembic \
graphql-dev "$@"
}
if [ "$1" == "commit" ]; then
if [ -z ${2+x} ];
then echo "Please provide a commit message";
else commit "$2";
fi
exit 0
fi
if [ "$1" == "migrate" ]; then
migrate
else
alembic "$@"
fi