-- used_quota -- Used to store realtime mailbox quota in Dovecot. -- WARNING: Works only with Dovecot 1.2+. -- -- Note: Don't touch this table, it will be updated by Dovecot automatically. CREATE TABLE IF NOT EXISTS `used_quota` ( `username` VARCHAR(255) NOT NULL, `bytes` BIGINT NOT NULL DEFAULT 0, `messages` BIGINT NOT NULL DEFAULT 0, `domain` VARCHAR(255) NOT NULL DEFAULT '', PRIMARY KEY (`username`), INDEX (domain) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- Trigger `used_quota_before_insert` is used to set `used_quota.domain`. -- NOTE: `used_quota.domain` is not used by Dovecot, but used in iRedAdmin to -- get better SQL query performance while calculating per-domain used -- quota. DELIMITER // CREATE TRIGGER `used_quota_before_insert` BEFORE INSERT ON `used_quota` FOR EACH ROW BEGIN SET NEW.domain = SUBSTRING_INDEX(NEW.username, '@', -1); END; // DELIMITER ;