--
-- Host: localhost    Database: dns
-- ------------------------------------------------------


--
-- Table structure for table `comments`
--

CREATE TABLE `comments` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `domain_id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `type` varchar(10) NOT NULL,
  `modified_at` int(11) NOT NULL,
  `account` varchar(40) NOT NULL,
  `comment` mediumtext NOT NULL,
  PRIMARY KEY (`id`),
  KEY `comments_domain_id_idx` (`domain_id`),
  KEY `comments_name_type_idx` (`name`,`type`),
  KEY `comments_order_idx` (`domain_id`,`modified_at`)
) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8;

--
-- Table structure for table `cryptokeys`
--

CREATE TABLE `cryptokeys` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `domain_id` int(11) NOT NULL,
  `flags` int(11) NOT NULL,
  `active` tinyint(1) DEFAULT NULL,
  `content` text,
  PRIMARY KEY (`id`),
  KEY `domainidindex` (`domain_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `domainmetadata`
--

CREATE TABLE `domainmetadata` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `domain_id` int(11) NOT NULL,
  `kind` varchar(32) DEFAULT NULL,
  `content` text,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;

--
-- Table structure for table `domains`
--

CREATE TABLE `domains` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `master` varchar(128) DEFAULT NULL,
  `last_check` int(11) DEFAULT NULL,
  `type` varchar(6) NOT NULL,
  `notified_serial` int(11) DEFAULT NULL,
  `account` varchar(40) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `name_index` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=1391 DEFAULT CHARSET=latin1;

--
-- Table structure for table `domains_private`
--

CREATE TABLE `domains_private` (
  `id` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `records`
--

CREATE TABLE `records` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `domain_id` int(11) DEFAULT NULL,
  `name` varchar(255) DEFAULT NULL,
  `type` varchar(10) DEFAULT NULL,
  `content` varchar(64000) DEFAULT NULL,
  `ttl` int(11) DEFAULT NULL,
  `prio` int(11) DEFAULT NULL,
  `change_date` int(11) DEFAULT NULL,
  `disabled` tinyint(1) DEFAULT '0',
  `ordername` varchar(255) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL,
  `auth` tinyint(1) DEFAULT '1',
  PRIMARY KEY (`id`),
  KEY `rec_name_index` (`name`),
  KEY `nametype_index` (`name`,`type`),
  KEY `domain_id` (`domain_id`)
) ENGINE=InnoDB AUTO_INCREMENT=47390 DEFAULT CHARSET=latin1;

--
-- Temporary table structure for view `records_private`
--

/*!50001 DROP VIEW IF EXISTS `records_private`*/;
/*!50001 CREATE TABLE `records_private` (
  `id` tinyint NOT NULL,
  `domain_id` tinyint NOT NULL,
  `name` tinyint NOT NULL,
  `type` tinyint NOT NULL,
  `content` tinyint NOT NULL,
  `ttl` tinyint NOT NULL,
  `prio` tinyint NOT NULL,
  `change_date` tinyint NOT NULL,
  `disabled` tinyint NOT NULL,
  `ordername` tinyint NOT NULL,
  `auth` tinyint NOT NULL
) ENGINE=MyISAM */;

--
-- Temporary table structure for view `records_public`
--

/*!50001 DROP VIEW IF EXISTS `records_public`*/;
/*!50001 CREATE TABLE `records_public` (
  `id` tinyint NOT NULL,
  `domain_id` tinyint NOT NULL,
  `name` tinyint NOT NULL,
  `type` tinyint NOT NULL,
  `content` tinyint NOT NULL,
  `ttl` tinyint NOT NULL,
  `prio` tinyint NOT NULL,
  `change_date` tinyint NOT NULL,
  `disabled` tinyint NOT NULL,
  `ordername` tinyint NOT NULL,
  `auth` tinyint NOT NULL
) ENGINE=MyISAM */;

--
-- Table structure for table `supermasters`
--

CREATE TABLE `supermasters` (
  `ip` varchar(64) NOT NULL,
  `nameserver` varchar(255) NOT NULL,
  `account` varchar(40) NOT NULL,
  PRIMARY KEY (`ip`,`nameserver`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `translations`
--

CREATE TABLE `translations` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `content` varchar(255) NOT NULL,
  `translation` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=latin1;

--
-- Table structure for table `tsigkeys`
--

CREATE TABLE `tsigkeys` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) DEFAULT NULL,
  `algorithm` varchar(50) DEFAULT NULL,
  `secret` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `namealgoindex` (`name`,`algorithm`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Final view structure for view `records_private`
--

/*!50001 DROP TABLE IF EXISTS `records_private`*/;
/*!50001 DROP VIEW IF EXISTS `records_private`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `records_private` AS select `r`.`id` AS `id`,`r`.`domain_id` AS `domain_id`,`r`.`name` AS `name`,`r`.`type` AS `type`,coalesce(`t`.`translation`,`r`.`content`) AS `content`,`r`.`ttl` AS `ttl`,`r`.`prio` AS `prio`,`r`.`change_date` AS `change_date`,`r`.`disabled` AS `disabled`,`r`.`ordername` AS `ordername`,`r`.`auth` AS `auth` from (`records` `r` left join `translations` `t` on((`r`.`content` = `t`.`content`))) */;

--
-- Final view structure for view `records_public`
--

/*!50001 DROP TABLE IF EXISTS `records_public`*/;
/*!50001 DROP VIEW IF EXISTS `records_public`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `records_public` AS select `r`.`id` AS `id`,`r`.`domain_id` AS `domain_id`,`r`.`name` AS `name`,`r`.`type` AS `type`,`r`.`content` AS `content`,`r`.`ttl` AS `ttl`,`r`.`prio` AS `prio`,`r`.`change_date` AS `change_date`,`r`.`disabled` AS `disabled`,`r`.`ordername` AS `ordername`,`r`.`auth` AS `auth` from (`records` `r` left join `domains_private` `dp` on((`r`.`domain_id` = `dp`.`id`))) where isnull(`dp`.`id`) */;


