CREATE USER keycloak; --kc1992
CREATE USER wikijs; --wikijsrocks

CREATE DATABASE keycloak;
GRANT ALL PRIVILEGES ON DATABASE logdata TO keycloak;

CREATE DATABASE wiki;
GRANT ALL PRIVILEGES ON DATABASE orderdata TO wikijs;


-- from postgres-init.yml
CREATE DATABASE wikijs;
CREATE USER wikijs with password 'wikiPGsql1992';
GRANT CONNECT ON DATABASE wikijs to wikijs;
GRANT USAGE ON SCHEMA public TO wikijs;
GRANT SELECT,update,INSERT,delete ON ALL TABLES IN SCHEMA public TO wikijs;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO wikijs;

-- unused, init by docker-compose.yml
CREATE DATABASE keycloak;
CREATE USER keycloak with password 'Wiki1992.920';
GRANT CONNECT ON DATABASE keycloak to keycloak;
GRANT USAGE ON SCHEMA public TO keycloak;
GRANT SELECT,update,INSERT,delete ON ALL TABLES IN SCHEMA public TO keycloak;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO keycloak;