--Create ctti user and grant permissions
CREATE ROLE ctti;
GRANT ALL PRIVILEGES ON DATABASE aact_db TO ctti;

/*
Add the root user if it doesn't exist. 
With the default configuration this shouldn't be an issue, 
but I can see myself forgetting and changing the default POSTGRES_USER
*/
DO LANGUAGE plpgsql
$do$
BEGIN
   IF NOT EXISTS (
      SELECT FROM pg_catalog.pg_roles  -- SELECT list can be empty for this
      WHERE  rolname = 'root') 
    THEN
      CREATE ROLE root LOGIN PASSWORD 'root'; --SECURITY ISSUE 
      GRANT ALL PRIVILEGES ON DATABASE aact_db TO root;
   END IF;
END
$do$
