CREATE DATABASE management;
CREATE DATABASE auth;
CREATE DATABASE notification;
CREATE DATABASE adminapi;
CREATE DATABASE authz;

CREATE USER management;

GRANT SELECT, INSERT, UPDATE, DELETE ON DATABASE management TO management;
GRANT SELECT, INSERT, UPDATE ON DATABASE eventstore TO management;
GRANT SELECT, INSERT, UPDATE ON TABLE eventstore.* TO management;


CREATE USER adminapi;

GRANT SELECT, INSERT, UPDATE, DELETE, DROP ON DATABASE adminapi TO adminapi;

GRANT SELECT, INSERT, UPDATE ON DATABASE eventstore TO adminapi;
GRANT SELECT, INSERT, UPDATE ON TABLE eventstore.* TO adminapi;

GRANT SELECT, INSERT, UPDATE, DROP, DELETE  ON DATABASE auth TO adminapi;

GRANT SELECT, INSERT, UPDATE, DROP, DELETE ON DATABASE authz TO adminapi;

GRANT SELECT, INSERT, UPDATE, DROP, DELETE ON DATABASE management TO adminapi;

GRANT SELECT, INSERT, UPDATE, DROP, DELETE ON DATABASE notification TO adminapi;


CREATE USER auth;

GRANT SELECT, INSERT, UPDATE, DELETE ON DATABASE auth TO auth;
GRANT SELECT, INSERT, UPDATE ON DATABASE eventstore TO auth;
GRANT SELECT, INSERT, UPDATE ON TABLE eventstore.* TO auth;


CREATE USER notification;

GRANT SELECT, INSERT, UPDATE, DELETE ON DATABASE notification TO notification;
GRANT SELECT, INSERT, UPDATE ON DATABASE eventstore TO notification;
GRANT SELECT, INSERT, UPDATE ON TABLE eventstore.* TO notification;

CREATE USER authz;

GRANT SELECT, INSERT, UPDATE, DELETE ON DATABASE authz TO authz;
GRANT SELECT, INSERT, UPDATE ON DATABASE eventstore TO authz;
GRANT SELECT, INSERT, UPDATE ON TABLE eventstore.* TO authz;
GRANT SELECT, INSERT, UPDATE ON DATABASE auth TO authz;
