vmail-stack/vmail.sql

281 lines
7.3 KiB
MySQL
Raw Permalink Normal View History

2021-03-30 15:42:12 -07:00
-- Host: localhost
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
--
-- Database: `vmail`
--
-- --------------------------------------------------------
--
-- Table structure for table `vm_aliases`
--
2021-12-30 16:50:23 -08:00
CREATE TABLE `vm_aliases` (
`id` int(10) UNSIGNED NOT NULL,
2022-11-29 16:33:15 -08:00
`mbox` varchar(128) NOT NULL,
`domain` varchar(255) NOT NULL,
2021-12-30 16:50:23 -08:00
`alias` varchar(128) NOT NULL
2021-03-30 15:42:12 -07:00
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `vm_autoresponders`
--
2021-12-30 16:50:23 -08:00
CREATE TABLE `vm_autoresponders` (
`id` int(10) UNSIGNED NOT NULL,
2022-11-29 16:33:15 -08:00
`mbox` varchar(128) NOT NULL,
`domain` varchar(255) NOT NULL,
2021-03-30 15:42:12 -07:00
`subject` varchar(128) NOT NULL,
`body` text NOT NULL,
2022-11-29 16:33:15 -08:00
`mode` enum('Vacation','Autoresponder') NOT NULL DEFAULT 'Vacation',
2021-03-30 15:42:12 -07:00
`status` tinyint(1) NOT NULL DEFAULT 1,
2022-11-29 16:33:15 -08:00
`start` date DEFAULT NULL,
`end` date DEFAULT NULL
2021-03-30 15:42:12 -07:00
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `vm_domains`
--
2021-12-30 16:50:23 -08:00
CREATE TABLE `vm_domains` (
`id` int(11) UNSIGNED NOT NULL,
2021-03-30 15:42:12 -07:00
`domain` varchar(255) NOT NULL,
`status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '1 for enabled, 0 for disabled',
2021-12-30 16:50:23 -08:00
`mbox_limit` smallint(6) UNSIGNED DEFAULT 10 COMMENT 'Maximum number of mailboxes for this domain',
`mbox_quota_default` smallint(6) UNSIGNED DEFAULT 1 COMMENT 'Default mailbox quota in GB',
`mbox_ratelimit_default` smallint(6) DEFAULT 100 COMMENT 'Default hourly rate limit for new mboxes'
2021-03-30 15:42:12 -07:00
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `vm_filters`
--
2021-12-30 16:50:23 -08:00
CREATE TABLE `vm_filters` (
`id` int(10) UNSIGNED NOT NULL,
2022-11-29 16:33:15 -08:00
`mbox` varchar(128) NOT NULL,
`domain` varchar(255) NOT NULL,
2021-12-30 16:50:23 -08:00
`filter` text NOT NULL
2021-03-30 15:42:12 -07:00
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `vm_forwards`
--
2021-12-30 16:50:23 -08:00
CREATE TABLE `vm_forwards` (
`id` int(10) UNSIGNED NOT NULL,
2022-11-29 16:33:15 -08:00
`mbox` varchar(128) NOT NULL,
`domain` varchar(255) NOT NULL,
2021-03-30 15:42:12 -07:00
`forward_to` varchar(128) NOT NULL,
2021-12-30 16:50:23 -08:00
`save_local` tinyint(1) NOT NULL DEFAULT 0
2021-03-30 15:42:12 -07:00
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `vm_greylisting`
--
2021-12-30 16:50:23 -08:00
CREATE TABLE `vm_greylisting` (
`id` bigint(20) UNSIGNED NOT NULL,
2021-03-30 15:42:12 -07:00
`relay_hostname` varchar(255) DEFAULT NULL,
`relay_ip` varchar(80) DEFAULT NULL,
`sender` varchar(255) DEFAULT NULL,
`recipient` varchar(255) DEFAULT NULL,
`message_id` varchar(255) DEFAULT NULL,
`block_expires` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
`record_expires` datetime NOT NULL DEFAULT '9999-12-31 23:59:59',
`create_time` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
`type` enum('AUTO','MANUAL') NOT NULL DEFAULT 'MANUAL',
`passcount` bigint(20) NOT NULL DEFAULT 0,
2021-12-30 16:50:23 -08:00
`blockcount` bigint(20) NOT NULL DEFAULT 0
2021-03-30 15:42:12 -07:00
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `vm_greylisting_resenders`
--
2021-12-30 16:50:23 -08:00
CREATE TABLE `vm_greylisting_resenders` (
`id` bigint(20) NOT NULL,
2021-03-30 15:42:12 -07:00
`hostname` varchar(255) NOT NULL,
`count` bigint(20) UNSIGNED NOT NULL DEFAULT 1,
2021-12-30 16:50:23 -08:00
`timestamp` timestamp NOT NULL DEFAULT current_timestamp()
2021-03-30 15:42:12 -07:00
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `vm_mboxes`
--
2021-12-30 16:50:23 -08:00
CREATE TABLE `vm_mboxes` (
`id` int(10) UNSIGNED NOT NULL,
2021-03-30 15:42:12 -07:00
`mbox` varchar(128) NOT NULL,
2022-11-29 16:33:15 -08:00
`domain` varchar(255) NOT NULL,
2021-03-30 15:42:12 -07:00
`passwd` char(128) NOT NULL,
`status` tinyint(1) NOT NULL DEFAULT 1,
2021-04-20 14:46:59 -07:00
`quota` int(10) UNSIGNED DEFAULT NULL,
2021-12-30 16:50:23 -08:00
`ratelimit` smallint(6) DEFAULT NULL,
`filter` tinyint(4) NOT NULL DEFAULT 2
2021-03-30 15:42:12 -07:00
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
2021-12-30 16:50:23 -08:00
-- Indexes for dumped tables
--
--
-- Indexes for table `vm_aliases`
2021-03-30 15:42:12 -07:00
--
2021-12-30 16:50:23 -08:00
ALTER TABLE `vm_aliases`
ADD PRIMARY KEY (`id`),
2022-11-29 16:33:15 -08:00
ADD UNIQUE KEY `alias` (`mbox`,`domain`,`alias`) USING BTREE,
ADD KEY `email` (`mbox`,`domain`) USING BTREE;
2021-12-30 16:50:23 -08:00
--
-- Indexes for table `vm_autoresponders`
--
ALTER TABLE `vm_autoresponders`
ADD PRIMARY KEY (`id`),
2022-11-29 16:33:15 -08:00
ADD UNIQUE KEY `email` (`mbox`,`domain`) USING BTREE;
2021-12-30 16:50:23 -08:00
--
-- Indexes for table `vm_domains`
--
ALTER TABLE `vm_domains`
ADD PRIMARY KEY (`id`),
2022-11-29 16:33:15 -08:00
ADD UNIQUE KEY `domain` (`domain`) USING BTREE;
2021-12-30 16:50:23 -08:00
--
-- Indexes for table `vm_filters`
--
ALTER TABLE `vm_filters`
ADD PRIMARY KEY (`id`),
2022-11-29 16:33:15 -08:00
ADD UNIQUE KEY `email` (`mbox`,`domain`) USING BTREE;
2021-12-30 16:50:23 -08:00
--
-- Indexes for table `vm_forwards`
--
ALTER TABLE `vm_forwards`
ADD PRIMARY KEY (`id`),
2022-11-29 16:33:15 -08:00
ADD UNIQUE KEY `email` (`mbox`,`domain`) USING BTREE;
2021-12-30 16:50:23 -08:00
--
-- Indexes for table `vm_greylisting`
--
ALTER TABLE `vm_greylisting`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `vm_greylisting_resenders`
--
ALTER TABLE `vm_greylisting_resenders`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `vm_mboxes`
--
ALTER TABLE `vm_mboxes`
ADD PRIMARY KEY (`id`),
2022-11-29 16:33:15 -08:00
ADD UNIQUE KEY `email` (`mbox`,`domain`) USING BTREE,
ADD KEY `domain_delete_mboxes` (`domain`);
2021-12-30 16:50:23 -08:00
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `vm_aliases`
--
ALTER TABLE `vm_aliases`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `vm_autoresponders`
--
ALTER TABLE `vm_autoresponders`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `vm_domains`
--
ALTER TABLE `vm_domains`
MODIFY `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `vm_filters`
--
ALTER TABLE `vm_filters`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `vm_forwards`
--
ALTER TABLE `vm_forwards`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `vm_greylisting`
--
ALTER TABLE `vm_greylisting`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `vm_greylisting_resenders`
--
ALTER TABLE `vm_greylisting_resenders`
MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `vm_mboxes`
--
ALTER TABLE `vm_mboxes`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;
2021-03-30 15:42:12 -07:00
--
-- Constraints for dumped tables
--
--
-- Constraints for table `vm_aliases`
--
ALTER TABLE `vm_aliases`
2022-11-29 16:33:15 -08:00
ADD CONSTRAINT `mbox_delete_aliases` FOREIGN KEY (`mbox`,`domain`) REFERENCES `vm_mboxes` (`mbox`, `domain`) ON DELETE CASCADE ON UPDATE NO ACTION;
2021-03-30 15:42:12 -07:00
--
-- Constraints for table `vm_autoresponders`
--
ALTER TABLE `vm_autoresponders`
2022-11-29 16:33:15 -08:00
ADD CONSTRAINT `mbox_delete_autoresponders` FOREIGN KEY (`mbox`,`domain`) REFERENCES `vm_mboxes` (`mbox`, `domain`) ON DELETE CASCADE ON UPDATE NO ACTION;
2021-03-30 15:42:12 -07:00
--
-- Constraints for table `vm_filters`
--
ALTER TABLE `vm_filters`
2022-11-29 16:33:15 -08:00
ADD CONSTRAINT `mbox_delete_filters` FOREIGN KEY (`mbox`,`domain`) REFERENCES `vm_mboxes` (`mbox`, `domain`) ON DELETE CASCADE ON UPDATE NO ACTION;
2021-03-30 15:42:12 -07:00
--
-- Constraints for table `vm_forwards`
--
ALTER TABLE `vm_forwards`
2022-11-29 16:33:15 -08:00
ADD CONSTRAINT `mbox_delete_forwards` FOREIGN KEY (`mbox`,`domain`) REFERENCES `vm_mboxes` (`mbox`, `domain`) ON DELETE CASCADE ON UPDATE NO ACTION;
2021-03-30 15:42:12 -07:00
--
-- Constraints for table `vm_mboxes`
--
ALTER TABLE `vm_mboxes`
2022-11-29 16:33:15 -08:00
ADD CONSTRAINT `domain_delete_mboxes` FOREIGN KEY (`domain`) REFERENCES `vm_domains` (`domain`) ON DELETE CASCADE ON UPDATE NO ACTION;
2021-03-30 15:42:12 -07:00
COMMIT;