-- Create the role required by the backup file
DO
$do$
BEGIN
   IF NOT EXISTS (
      SELECT FROM pg_catalog.pg_roles
      WHERE  rolname = 'globaldbmigrationuser') THEN

      CREATE ROLE globaldbmigrationuser WITH LOGIN PASSWORD 'temp_password';
      GRANT ALL PRIVILEGES ON DATABASE global TO globaldbmigrationuser;
   END IF;
END
$do$;

-- Ensure itguys has access
GRANT globaldbmigrationuser TO itguys;
