-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrop_db.sh
executable file
·36 lines (28 loc) · 1.16 KB
/
drop_db.sh
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
#!/usr/bin/env bash
# Executes docker-compose to drop the database.
# Environment:
# APREXIS_VARIETY the version of Aprexis to run (api or platform).
# APREXIS_DOCKER_COMPOSE_FILE the docker compose file to use to build the system. Default depends on APREXIS_VARIETY.
# Author: Ian Brown
# Since: 2021/05/25
# Version: 1.0.0
SHELL_DIR=`dirname "$0"`
APREXIS_VARIETY=${APREXIS_VARIETY:-api}
APREXIS_DOCKER_COMPOSE_FILE=docker-compose-${APREXIS_VARIETY}.yml
if [ "${APREXIS_VARIETY}" = 'engine' ]; then
APREXIS_SHELL='engine'
else
APREXIS_SHELL='platform'
fi
if [ $# -eq 0 ]; then
${SHELL_DIR}/start_db.sh
fi
echo "Dropping existing database"
docker-compose -f ${APREXIS_DOCKER_COMPOSE_FILE} \
run -T --no-deps --rm ${APREXIS_SHELL} bash --login -c "/aprexis/setup-for-rails.sh; psql -l -h postgres -U postgres | grep aprexis_development | wc -l" && \
docker-compose -f ${APREXIS_DOCKER_COMPOSE_FILE} \
run -T --no-deps --rm ${APREXIS_SHELL} bash --login -c \
"/aprexis/setup-for-rails.sh; bundle exec rails app:db:environment:set RAILS_ENV=development; bundle exec rails db:drop"
if [ $# -eq 0 ]; then
${SHELL_DIR}/stop_db.sh
fi