db_init.sh 551 Bytes
Newer Older
Stephane Crozat's avatar
Stephane Crozat committed
1
2
#!/bin/bash
sqlfiles='/media/stc/data/git/apisub/sql'
3
4
5
6
7
8
9
10
11
12
psql -c "DROP DATABASE apisub"
psql -c "DROP USER apisub"
psql -c "CREATE USER apisub WITH ENCRYPTED PASSWORD 'password'"
psql -c "CREATE DATABASE apisub WITH OWNER apisub"
psql -d apisub -f "$sqlfiles/apisub_functions.sql"
psql -d apisub -f "$sqlfiles/apisub_admin.sql"
psql -d apisub -f "$sqlfiles/apisub_tables.sql"
psql -d apisub -f "$sqlfiles/apisub_views.sql"
psql -d apisub -f "$sqlfiles/apisub_dataset.sql"
psql -d apisub -c "GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO apisub"