-- Crete role: vmail, read-only.
CREATE USER PH_VMAIL_DB_BIND_USER
    WITH ENCRYPTED PASSWORD 'PH_VMAIL_DB_BIND_PASSWD'
    NOSUPERUSER NOCREATEDB NOCREATEROLE;

-- Create role: vmailadmin, read + write.
CREATE USER PH_VMAIL_DB_ADMIN_USER
    WITH ENCRYPTED PASSWORD 'PH_VMAIL_DB_ADMIN_PASSWD'
    NOSUPERUSER NOCREATEDB NOCREATEROLE;

-- Create database to store mail accounts
CREATE DATABASE PH_VMAIL_DB_NAME WITH TEMPLATE template0 ENCODING 'UTF8';

-- Grant privilege
ALTER DATABASE PH_VMAIL_DB_NAME OWNER TO PH_VMAIL_DB_ADMIN_USER;
