
-- Job Arranger create database SQL for PostgreSQL  - 2014/09/17 -

-- Copyright (C) 2012 FitechForce, Inc. All Rights Reserved.
-- Copyright (C) 2013 Daiwa Institute of Research Business Innovation Ltd. All Rights Reserved.

DO
$$
BEGIN
   IF NOT EXISTS (SELECT FROM pg_roles WHERE rolname = 'zabbix') THEN
      CREATE USER zabbix WITH PASSWORD 'zabbix';
   END IF;
END
$$;
 
SELECT 'CREATE DATABASE jobarranger OWNER zabbix'
WHERE NOT EXISTS (
    SELECT FROM pg_database WHERE datname = 'jobarranger'
)\gexec

