apisub_init.sh 745 Bytes
Newer Older
Stephane Crozat's avatar
Stephane Crozat committed
1
#!/bin/bash
Stephane Crozat's avatar
Stephane Crozat committed
2
3
SH=`dirname $0`
SQL="$SH/../sql"
Stéphane Crozat's avatar
Stéphane Crozat committed
4
5
psql -c "DROP DATABASE IF EXISTS apisub"
psql -c "DROP USER IF EXISTS apisub"
6
psql -c "CREATE USER apisub WITH ENCRYPTED PASSWORD '$1'"
7
psql -c "CREATE DATABASE apisub WITH OWNER apisub"
8
9
10
psql -d apisub -f "$SQL/apisub_functions.sql"
psql -d apisub -f "$SQL/apisub_admin.sql"
psql -d apisub -f "$SQL/apisub_tables.sql"
11
psql -d apisub -f "$SQL/apisub_data.sql"
Stephane Crozat's avatar
Stephane Crozat committed
12
psql -d apisub -c "\copy student (utclogin, level) FROM '$SQL/../data/students.csv' WITH CSV DELIMITER ';'"
13
psql -d apisub -f "$SQL/apisub_views.sql"
14
psql -d apisub -c "GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO apisub"
15
psql -d apisub -c 'CREATE EXTENSION IF NOT EXISTS "pgcrypto"'
16
17

# psql -d apisub -f "$SQL/apisub_dataset.sql"