ar_redadeg/scripts/create_database.sh

30 lines
1,017 B
Bash
Raw Normal View History

2019-01-01 19:52:23 +00:00
#!/bin/sh
# utiliser un compte SUPERUSER pour exécuter ce script
dbhost=localhost
#psql -h $dbhost -d postgres -c "DROP DATABASE IF EXISTS redadeg; DROP ROLE IF EXISTS redadeg;"
2019-01-01 19:52:23 +00:00
# create role
psql -h $dbhost -d postgres -c "CREATE USER redadeg WITH PASSWORD 'redadeg' SUPERUSER;"
2019-01-01 19:52:23 +00:00
# create database with owner redadeg
psql -h $dbhost -d postgres -c "CREATE DATABASE redadeg WITH OWNER = redadeg ENCODING = 'UTF8';"
# extensions postgis
psql -h $dbhost -d redadeg -c "CREATE EXTENSION postgis;"
psql -h $dbhost -d redadeg -c "CREATE EXTENSION postgis_topology;"
psql -h $dbhost -d redadeg -c "CREATE EXTENSION pgrouting;"
2019-01-01 19:52:23 +00:00
# permissions
psql -h $dbhost -d redadeg -c "ALTER SCHEMA public OWNER TO redadeg;"
psql -h $dbhost -d redadeg -c "ALTER TABLE topology.layer OWNER TO redadeg ;"
psql -h $dbhost -d redadeg -c "ALTER TABLE topology.topology OWNER TO redadeg ;"
2019-01-01 19:52:23 +00:00
# vérifications
psql -h $dbhost -d redadeg -c "SELECT * FROM postgis_version();"
psql -h $dbhost -d redadeg -c "SELECT * FROM pgr_version();"
2019-01-01 19:52:23 +00:00