-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_sql.sh
39 lines (36 loc) · 976 Bytes
/
add_sql.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
37
38
39
# Construct the URI from the .env
DB_HOST=''
DB_NAME=''
DB_USER=''
DB_PORT=''
DB_PASSWORD=''
while IFS= read -r line
do
if [[ $line == DB_HOST* ]]
then
DB_HOST=$(cut -d "=" -f2- <<< $line | tr -d \')
elif [[ $line == DB_NAME* ]]
then
DB_NAME=$(cut -d "=" -f2- <<< $line | tr -d \' )
elif [[ $line == DB_USER* ]]
then
DB_USER=$(cut -d "=" -f2- <<< $line | tr -d \' )
elif [[ $line == DB_PORT* ]]
then
DB_PORT=$(cut -d "=" -f2- <<< $line | tr -d \')
elif [[ $line == DB_PASSWORD* ]]
then
DB_PASSWORD=$(cut -d "=" -f2- <<< $line | tr -d \')
fi
done < ".env"
URI="postgres://$DB_USER:$DB_PASSWORD@$DB_HOST:$DB_PORT/$DB_NAME"
# Run the scripts to insert data.
psql ${URI} -f sql/schema.sql
psql ${URI} -f sql/person.sql
psql ${URI} -f sql/beneficiary.sql
psql ${URI} -f sql/donor.sql
psql ${URI} -f sql/merchant.sql
psql ${URI} -f sql/food.sql
psql ${URI} -f sql/reward.sql
psql ${URI} -f sql/donation.sql
psql ${URI} -f sql/coupon.sql