     user TEXT := 'user_' || NEW.id;
 BEGIN
     EXECUTE 'CREATE USER ' || user || ' WITH PASSWORD ''' || user || '''';
+
+    IF NEW.flag_admin THEN
+      EXECUTE 'GRANT admin TO ' || user;
+    ELSE
+      EXECUTE 'GRANT standard TO ' || user;
+    END;
     RETURN NEW;
 END;
 $$ language plpgsql;

CREATE TRIGGER user_create_user_role AFTER INSERT
ON base.user FOR EACH ROW EXECUTE PROCEDURE
base.create_user_role();

  , access_token TEXT NOT NULL
  , refresh_token INTEGER
  , expiry_date TIMESTAMP NOT NULL
  , flag_admin BOOLEAN DEFAULT FALSE
  , flag_active BOOLEAN DEFAULT TRUE
  , created_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP
  , updated_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP
