CREATE DATABASE mail OWNER postgres;
CREATE ROLE dovecot PASSWORD '%%DOVECOT_PASSWORD%%';
CREATE ROLE postfix PASSWORD '%%POSTFIX_PASSWORD%%';

\c mail;
CREATE TABLE users (
	userid VARCHAR(128) NOT NULL,
	password VARCHAR(128) NOT NULL,
	active boolean NOT NULL,
	PRIMARY KEY (userid),
	UNIQUE (userid)
);
\c postgres;
GRANT SELECT ON TABLE users TO dovecot;
GRANT SELECT ON TABLE users TO postfix;
