CREATE DATABASE mail OWNER postgres;
CREATE TABLE users (
	userid VARCHAR(128) NOT NULL,
	password VARCHAR(128) NOT NULL,
	active boolean NOT NULL,
	PRIMARY KEY (userid),
	UNIQUE (userid)
);
CREATE TABLE aliases (
	target VARCHAR(128) NOT NULL,
	alias VARCHAR(128) NOT NULL,
	active boolean NOT NULL,
	PRIMARY KEY (alias),
	UNIQUE (alias)
);
CREATE ROLE dovecot PASSWORD 'CHANGEME' LOGIN;
GRANT SELECT ON TABLE users TO dovecot;
CREATE ROLE postfix PASSWORD 'CHANGEME' LOGIN;
GRANT SELECT ON TABLE users, aliases TO postfix;
