db_init.sh 521 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
6
psql -c "CREATE USER apisub WITH ENCRYPTED PASSWORD 'password'"
psql -c "CREATE DATABASE apisub WITH OWNER apisub"
7
8
9
10
11
psql -d apisub -f "$SQL/apisub_functions.sql"
psql -d apisub -f "$SQL/apisub_admin.sql"
psql -d apisub -f "$SQL/apisub_tables.sql"
psql -d apisub -f "$SQL/apisub_views.sql"
psql -d apisub -f "$SQL/apisub_dataset.sql"
12
psql -d apisub -c "GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO apisub"