vmail-stack/vmail.sql

230 lines
6.4 KiB
MySQL
Raw 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";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `vmail`
--
2021-04-20 14:46:59 -07:00
CREATE DATABASE IF NOT EXISTS `vmail` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
USE `vmail`;
2021-03-30 15:42:12 -07:00
-- --------------------------------------------------------
--
-- Table structure for table `vm_aliases`
--
2021-04-20 14:46:59 -07:00
CREATE TABLE IF NOT EXISTS `vm_aliases` (
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
2021-03-30 15:42:12 -07:00
`mbox_id` int(10) UNSIGNED NOT NULL,
2021-04-20 14:46:59 -07:00
`alias` varchar(128) NOT NULL,
PRIMARY KEY (`id`),
KEY `mbox_delete_aliases` (`mbox_id`)
2021-03-30 15:42:12 -07:00
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
2021-04-20 14:46:59 -07:00
--
-- RELATIONSHIPS FOR TABLE `vm_aliases`:
-- `mbox_id`
-- `vm_mboxes` -> `id`
--
2021-03-30 15:42:12 -07:00
-- --------------------------------------------------------
--
-- Table structure for table `vm_autoresponders`
--
2021-04-20 14:46:59 -07:00
CREATE TABLE IF NOT EXISTS `vm_autoresponders` (
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
2021-03-30 15:42:12 -07:00
`mbox_id` int(10) UNSIGNED NOT NULL,
`subject` varchar(128) NOT NULL,
`body` text NOT NULL,
`mode` enum('Vacation','Autoresponder') NOT NULL,
`status` tinyint(1) NOT NULL DEFAULT 1,
`start` datetime DEFAULT NULL,
2021-04-20 14:46:59 -07:00
`end` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `autoresponder` (`mbox_id`)
2021-03-30 15:42:12 -07:00
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
2021-04-20 14:46:59 -07:00
--
-- RELATIONSHIPS FOR TABLE `vm_autoresponders`:
-- `mbox_id`
-- `vm_mboxes` -> `id`
--
2021-03-30 15:42:12 -07:00
-- --------------------------------------------------------
--
-- Table structure for table `vm_domains`
--
2021-04-20 14:46:59 -07:00
CREATE TABLE IF NOT EXISTS `vm_domains` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
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',
`mbox_limit` smallint(6) UNSIGNED DEFAULT NULL COMMENT 'Maximum number of mailboxes for this domain',
2021-04-20 14:46:59 -07:00
`mbox_quota_default` smallint(6) UNSIGNED DEFAULT NULL COMMENT 'Default mailbox quota in GB',
PRIMARY KEY (`id`),
KEY `domain` (`domain`(191))
2021-03-30 15:42:12 -07:00
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
2021-04-20 14:46:59 -07:00
--
-- RELATIONSHIPS FOR TABLE `vm_domains`:
--
2021-03-30 15:42:12 -07:00
-- --------------------------------------------------------
--
-- Table structure for table `vm_filters`
--
2021-04-20 14:46:59 -07:00
CREATE TABLE IF NOT EXISTS `vm_filters` (
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
2021-03-30 15:42:12 -07:00
`mbox_id` int(11) UNSIGNED NOT NULL,
2021-04-20 14:46:59 -07:00
`filter` text NOT NULL,
PRIMARY KEY (`id`),
KEY `mbox_delete_filters` (`mbox_id`)
2021-03-30 15:42:12 -07:00
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
2021-04-20 14:46:59 -07:00
--
-- RELATIONSHIPS FOR TABLE `vm_filters`:
-- `mbox_id`
-- `vm_mboxes` -> `id`
--
2021-03-30 15:42:12 -07:00
-- --------------------------------------------------------
--
-- Table structure for table `vm_forwards`
--
2021-04-20 14:46:59 -07:00
CREATE TABLE IF NOT EXISTS `vm_forwards` (
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
2021-03-30 15:42:12 -07:00
`mbox_id` int(10) UNSIGNED NOT NULL,
`forward_to` varchar(128) NOT NULL,
2021-04-20 14:46:59 -07:00
`save_local` tinyint(1) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE KEY `mbox_id` (`mbox_id`)
2021-03-30 15:42:12 -07:00
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
2021-04-20 14:46:59 -07:00
--
-- RELATIONSHIPS FOR TABLE `vm_forwards`:
-- `mbox_id`
-- `vm_mboxes` -> `id`
--
2021-03-30 15:42:12 -07:00
-- --------------------------------------------------------
--
-- Table structure for table `vm_greylisting`
--
2021-04-20 14:46:59 -07:00
CREATE TABLE IF NOT EXISTS `vm_greylisting` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
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-04-20 14:46:59 -07:00
`blockcount` bigint(20) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`)
2021-03-30 15:42:12 -07:00
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
2021-04-20 14:46:59 -07:00
--
-- RELATIONSHIPS FOR TABLE `vm_greylisting`:
--
2021-03-30 15:42:12 -07:00
-- --------------------------------------------------------
--
-- Table structure for table `vm_greylisting_resenders`
--
2021-04-20 14:46:59 -07:00
CREATE TABLE IF NOT EXISTS `vm_greylisting_resenders` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
2021-03-30 15:42:12 -07:00
`hostname` varchar(255) NOT NULL,
`count` bigint(20) UNSIGNED NOT NULL DEFAULT 1,
2021-04-20 14:46:59 -07:00
`timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
PRIMARY KEY (`id`)
2021-03-30 15:42:12 -07:00
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
2021-04-20 14:46:59 -07:00
--
-- RELATIONSHIPS FOR TABLE `vm_greylisting_resenders`:
--
2021-03-30 15:42:12 -07:00
-- --------------------------------------------------------
--
-- Table structure for table `vm_mboxes`
--
2021-04-20 14:46:59 -07:00
CREATE TABLE IF NOT EXISTS `vm_mboxes` (
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
2021-03-30 15:42:12 -07:00
`domain_id` int(10) UNSIGNED NOT NULL,
`mbox` varchar(128) NOT NULL,
`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,
PRIMARY KEY (`id`),
KEY `email` (`domain_id`,`mbox`) USING BTREE
2021-03-30 15:42:12 -07:00
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
2021-04-20 14:46:59 -07:00
-- RELATIONSHIPS FOR TABLE `vm_mboxes`:
-- `domain_id`
-- `vm_domains` -> `id`
2021-03-30 15:42:12 -07:00
--
--
-- Constraints for dumped tables
--
--
-- Constraints for table `vm_aliases`
--
ALTER TABLE `vm_aliases`
ADD CONSTRAINT `mbox_delete_aliases` FOREIGN KEY (`mbox_id`) REFERENCES `vm_mboxes` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION;
--
-- Constraints for table `vm_autoresponders`
--
ALTER TABLE `vm_autoresponders`
ADD CONSTRAINT `mbox_delete_autoresponders` FOREIGN KEY (`mbox_id`) REFERENCES `vm_mboxes` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION;
--
-- Constraints for table `vm_filters`
--
ALTER TABLE `vm_filters`
ADD CONSTRAINT `mbox_delete_filters` FOREIGN KEY (`mbox_id`) REFERENCES `vm_mboxes` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION;
--
-- Constraints for table `vm_forwards`
--
ALTER TABLE `vm_forwards`
ADD CONSTRAINT `mbox_delete_forwards` FOREIGN KEY (`mbox_id`) REFERENCES `vm_mboxes` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION;
--
-- Constraints for table `vm_mboxes`
--
ALTER TABLE `vm_mboxes`
ADD CONSTRAINT `domain_delete_mboxes` FOREIGN KEY (`domain_id`) REFERENCES `vm_domains` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;