ar_redadeg/scripts/create_database.sh
Maël 0286523bbe update create role and database
ménage, maintenance, documentation
2020-02-10 13:31:30 +01:00

30 lines
1,017 B
Bash
Executable file

#!/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;"
# create role
psql -h $dbhost -d postgres -c "CREATE USER redadeg WITH PASSWORD 'redadeg' SUPERUSER;"
# 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;"
# 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 ;"
# vérifications
psql -h $dbhost -d redadeg -c "SELECT * FROM postgis_version();"
psql -h $dbhost -d redadeg -c "SELECT * FROM pgr_version();"