DO
$do$
BEGIN
   IF NOT EXISTS (SELECT FROM pg_catalog.pg_roles WHERE rolname = 'ncp_db') THEN
      CREATE USER ncp_db WITH PASSWORD 'ncpDbApp';
END IF;
END
$do$;

DO
$do$
BEGIN
   IF NOT EXISTS (SELECT FROM pg_database WHERE datname = 'no_copy_') THEN
      CREATE DATABASE no_copy_ OWNER ncp_db;
END IF;
END
$do$;

GRANT ALL PRIVILEGES ON DATABASE no_copy_ TO ncp_db;