-- phpMyAdmin SQL Dump
-- version 4.2.12deb2
-- http://www.phpmyadmin.net
--
-- Host: 192.168.0.12:3306
-- Generation Time: Apr 11, 2015 at 08:45 PM
-- Server version: 5.5.42-1
-- PHP Version: 5.6.7-1

SET FOREIGN_KEY_CHECKS=0;
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";

--
-- Database: `mailserver`
--
CREATE DATABASE IF NOT EXISTS `mailserver` DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
USE `mailserver`;

-- --------------------------------------------------------

--
-- Table structure for table `virtual_aliases`
--
-- Creation: Feb 23, 2015 at 10:14 AM
--

DROP TABLE IF EXISTS `virtual_aliases`;
CREATE TABLE IF NOT EXISTS `virtual_aliases` (
`id` int(11) NOT NULL,
  `domain_id` int(11) NOT NULL,
  `source` varchar(100) NOT NULL,
  `destination` varchar(100) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=70 DEFAULT CHARSET=utf8;

--
-- RELATIONS FOR TABLE `virtual_aliases`:
--   `domain_id`
--       `virtual_domains` -> `id`
--

-- --------------------------------------------------------

--
-- Table structure for table `virtual_domains`
--
-- Creation: Feb 23, 2015 at 10:14 AM
--

DROP TABLE IF EXISTS `virtual_domains`;
CREATE TABLE IF NOT EXISTS `virtual_domains` (
`id` int(11) NOT NULL,
  `name` varchar(50) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Table structure for table `virtual_users`
--
-- Creation: Feb 23, 2015 at 10:14 AM
--

DROP TABLE IF EXISTS `virtual_users`;
CREATE TABLE IF NOT EXISTS `virtual_users` (
`id` int(11) NOT NULL,
  `domain_id` int(11) NOT NULL,
  `password` varchar(255) NOT NULL,
  `email` varchar(100) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=41 DEFAULT CHARSET=utf8;

--
-- RELATIONS FOR TABLE `virtual_users`:
--   `domain_id`
--       `virtual_domains` -> `id`
--

--
-- Indexes for dumped tables
--

--
-- Indexes for table `virtual_aliases`
--
ALTER TABLE `virtual_aliases`
 ADD PRIMARY KEY (`id`), ADD KEY `domain_id` (`domain_id`);

--
-- Indexes for table `virtual_domains`
--
ALTER TABLE `virtual_domains`
 ADD PRIMARY KEY (`id`);

--
-- Indexes for table `virtual_users`
--
ALTER TABLE `virtual_users`
 ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `email` (`email`), ADD KEY `domain_id` (`domain_id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `virtual_aliases`
--
ALTER TABLE `virtual_aliases`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=70;
--
-- AUTO_INCREMENT for table `virtual_domains`
--
ALTER TABLE `virtual_domains`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=33;
--
-- AUTO_INCREMENT for table `virtual_users`
--
ALTER TABLE `virtual_users`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=41;
--
-- Constraints for dumped tables
--

--
-- Constraints for table `virtual_aliases`
--
ALTER TABLE `virtual_aliases`
ADD CONSTRAINT `virtual_aliases_ibfk_1` FOREIGN KEY (`domain_id`) REFERENCES `virtual_domains` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `virtual_users`
--
ALTER TABLE `virtual_users`
ADD CONSTRAINT `virtual_users_ibfk_1` FOREIGN KEY (`domain_id`) REFERENCES `virtual_domains` (`id`) ON DELETE CASCADE;
SET FOREIGN_KEY_CHECKS=1;
COMMIT;

