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