-- CREATE DIRECTORY FOR TABLESPACE
  # sudo mkdir /data/postgres/tablespaces/ts_pg_roadreport_dev

-- GRANT PERMISSION ON TS FOR postgres
  # sudo chown postgres:postgres /data/postgres/tablespaces/ts_pg_roadreport_dev
-- CREATE TABLESPACE FOR DATA

CREATE TABLESPACE "ts_pg_roadreport_dev"
OWNER postgres
LOCATION '/data/postgres/tablespaces/ts_pg_roadreport_dev';


-- CREATE DATABASE

CREATE DATABASE "pg_roadreport_dev"
    WITH
    OWNER = postgres
    ENCODING = 'UTF8'
    TABLESPACE = "ts_pg_roadreport_dev"
    CONNECTION LIMIT = -1;

-- ENABLE UUID SUPPORT
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";

-- CREATE USER
CREATE ROLE "roadreportpgdb" LOGIN PASSWORD 'roadreportpgdb1qaz';

-- ADD USER ACCESS IN PG HBA_CONF

-- Refresh PG_CONF
SELECT pg_reload_conf();
