|
|
|
-- Postfix Admin Release 2.x --
|
|
|
|
----------------------------------------------------------
|
|
|
|
--
|
|
|
|
-- Copyright (c) 2002 - 2005 High5!
|
|
|
|
-- Created by: Mischa Peters <mischa at high5 dot net>
|
|
|
|
--
|
|
|
|
-- This is the complete database structure for Postfix Admin.
|
|
|
|
-- If you are installing from scratch you can use this file otherwise you
|
|
|
|
-- need to use the TABLE_CHANGES.TXT or TABLE_BACKUP_MX.TXT that comes with Postfix Admin.
|
|
|
|
-- You can find these in DOCUMENTS/
|
|
|
|
--
|
|
|
|
-- There are 2 entries for a database user in the file.
|
|
|
|
-- One you can use for Postfix and one for Postfix Admin.
|
|
|
|
--
|
|
|
|
-- You can create the database from the shell with:
|
|
|
|
-- createuser -P postfix
|
|
|
|
-- createuser -P postfixadmin
|
|
|
|
-- createuser -P vacation
|
|
|
|
-- createdb postfix
|
|
|
|
-- psql postfix
|
|
|
|
-- postfix=# \i postfix.sql
|
|
|
|
-- postfix=# \q
|
|
|
|
-- exit
|
|
|
|
--
|
|
|
|
-- Postfix / PgSQL
|
|
|
|
|
|
|
|
--
|
|
|
|
DROP TABLE admin,alias,domain,domain_admins,log,mailbox CASCADE;
|
|
|
|
--
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Table structure for table domain
|
|
|
|
--
|
|
|
|
CREATE TABLE domain (
|
|
|
|
domain character varying(255) NOT NULL,
|
|
|
|
description character varying(255) NOT NULL default '',
|
|
|
|
aliases integer NOT NULL default 0,
|
|
|
|
mailboxes integer NOT NULL default 0,
|
|
|
|
maxquota integer NOT NULL default 0,
|
|
|
|
quota integer NOT NULL default 0,
|
|
|
|
transport character varying(255) default NULL,
|
|
|
|
backupmx boolean NOT NULL default false,
|
|
|
|
created timestamp with time zone default now(),
|
|
|
|
modified timestamp with time zone default now(),
|
|
|
|
active boolean NOT NULL default true,
|
|
|
|
Constraint "domain_key" Primary Key ("domain")
|
|
|
|
);
|
|
|
|
CREATE INDEX domain_domain_active ON domain(domain,active);
|
|
|
|
COMMENT ON TABLE domain IS 'Postfix Admin - Virtual Domains';
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Table structure for table admin
|
|
|
|
--
|
|
|
|
CREATE TABLE "admin" (
|
|
|
|
"username" character varying(255) NOT NULL,
|
|
|
|
"password" character varying(255) NOT NULL default '',
|
|
|
|
"created" timestamp with time zone default now(),
|
|
|
|
"modified" timestamp with time zone default now(),
|
|
|
|
"active" boolean NOT NULL default true,
|
|
|
|
Constraint "admin_key" Primary Key ("username")
|
|
|
|
);
|
|
|
|
COMMENT ON TABLE admin IS 'Postfix Admin - Virtual Admins';
|
|
|
|
--
|
|
|
|
-- Table structure for table alias
|
|
|
|
--
|
|
|
|
CREATE TABLE alias (
|
|
|
|
address character varying(255) NOT NULL,
|
|
|
|
goto text NOT NULL,
|
|
|
|
domain character varying(255) NOT NULL REFERENCES domain,
|
|
|
|
created timestamp with time zone default now(),
|
|
|
|
modified timestamp with time zone default now(),
|
|
|
|
active boolean NOT NULL default true,
|
|
|
|
Constraint "alias_key" Primary Key ("address")
|
|
|
|
);
|
|
|
|
CREATE INDEX alias_address_active ON alias(address,active);
|
|
|
|
COMMENT ON TABLE alias IS 'Postfix Admin - Virtual Aliases';
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Table structure for table domain_admins
|
|
|
|
--
|
|
|
|
CREATE TABLE domain_admins (
|
|
|
|
username character varying(255) NOT NULL,
|
|
|
|
domain character varying(255) NOT NULL REFERENCES domain,
|
|
|
|
created timestamp with time zone default now(),
|
|
|
|
active boolean NOT NULL default true
|
|
|
|
);
|
|
|
|
COMMENT ON TABLE domain_admins IS 'Postfix Admin - Domain Admins';
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Table structure for table log
|
|
|
|
--
|
|
|
|
CREATE TABLE log (
|
|
|
|
timestamp timestamp with time zone default now(),
|
|
|
|
username character varying(255) NOT NULL default '',
|
|
|
|
domain character varying(255) NOT NULL default '',
|
|
|
|
action character varying(255) NOT NULL default '',
|
|
|
|
data text NOT NULL default ''
|
|
|
|
);
|
|
|
|
COMMENT ON TABLE log IS 'Postfix Admin - Log';
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Table structure for table mailbox
|
|
|
|
--
|
|
|
|
CREATE TABLE mailbox (
|
|
|
|
username character varying(255) NOT NULL,
|
|
|
|
password character varying(255) NOT NULL default '',
|
|
|
|
name character varying(255) NOT NULL default '',
|
|
|
|
maildir character varying(255) NOT NULL default '',
|
|
|
|
quota integer NOT NULL default 0,
|
|
|
|
domain character varying(255) NOT NULL REFERENCES domain,
|
|
|
|
created timestamp with time zone default now(),
|
|
|
|
modified timestamp with time zone default now(),
|
|
|
|
active boolean NOT NULL default true,
|
|
|
|
Constraint "mailbox_key" Primary Key ("username")
|
|
|
|
);
|
|
|
|
CREATE INDEX mailbox_username_active ON mailbox(username,active);
|
|
|
|
COMMENT ON TABLE mailbox IS 'Postfix Admin - Virtual Mailboxes';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GRANT
|
|
|
|
SELECT,INSERT,UPDATE,DELETE
|
|
|
|
ON
|
|
|
|
admin,
|
|
|
|
alias,
|
|
|
|
domain,
|
|
|
|
domain_admins,
|
|
|
|
log,
|
|
|
|
mailbox,
|
|
|
|
TO postfixadmin;
|
|
|
|
|
|
|
|
GRANT SELECT ON alias,domain,mailbox TO postfix;
|
|
|
|
|
|
|
|
-- Vacation Stuff ...
|
|
|
|
|
|
|
|
DROP TABLE vacation,vacation_notification CASCADE;
|
|
|
|
|
|
|
|
CREATE TABLE vacation (
|
|
|
|
email character varying(255) PRIMARY KEY,
|
|
|
|
subject character varying(255) NOT NULL DEFAULT '',
|
|
|
|
body text NOT NULL DEFAULT '',
|
|
|
|
cache text NOT NULL DEFAULT '',
|
|
|
|
"domain" character varying(255) NOT NULL REFERENCES "domain",
|
|
|
|
created timestamp with time zone DEFAULT now(),
|
|
|
|
active boolean DEFAULT true NOT NULL
|
|
|
|
);
|
|
|
|
CREATE INDEX vacation_email_active ON vacation(email,active);
|
|
|
|
|
|
|
|
CREATE TABLE vacation_notification (
|
|
|
|
on_vacation character varying(255) NOT NULL REFERENCES vacation(email) ON DELETE CASCADE,
|
|
|
|
notified character varying(255) NOT NULL,
|
|
|
|
notified_at timestamp with time zone NOT NULL DEFAULT now(),
|
|
|
|
CONSTRAINT vacation_notification_pkey primary key(on_vacation,notified)
|
|
|
|
);
|
|
|
|
-- Note: It's important that the primary key constraint on vacation_notification
|
|
|
|
-- be given a name which includes the '_pkey' substring (default PostgreSQL naming
|
|
|
|
-- for primary keys). The vacation-script looks for this substring to
|
|
|
|
-- distinguish between an acceptable and non-acceptable error.
|
|
|
|
|
|
|
|
|
|
|
|
GRANT
|
|
|
|
SELECT,INSERT,UPDATE,DELETE
|
|
|
|
ON
|
|
|
|
vacation
|
|
|
|
TO postfixadmin;
|
|
|
|
|
|
|
|
GRANT SELECT ON vacation TO vacation;
|
|
|
|
GRANT SELECT,INSERT,DELETE ON vacation_notification TO vacation;
|
|
|
|
|
|
|
|
--
|
|
|
|
--
|
|
|
|
-- superadmin user & password (login: admin@domain.tld, password: admin)
|
|
|
|
INSERT INTO domain (domain) VALUES ('ALL');
|
|
|
|
INSERT INTO domain_admins (username, domain, active) VALUES ('admin@domain.tld','ALL','1');
|
|
|
|
INSERT INTO admin (username, password, active) VALUES ('admin@domain.tld','$1$0fec9189$bgI6ncWrldPOsXnkUBIjl1','1');
|