--
-- Host: localhost    Database: zigsbys8_maincalls
-- ------------------------------------------------------


--
-- Current Database: `zigsbys8_maincalls`
--

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `zigsbys8_maincalls` /*!40100 DEFAULT CHARACTER SET latin1 */;

USE `zigsbys8_maincalls`;

--
-- Table structure for table `annotation_types`
--

CREATE TABLE `annotation_types` (
  `id` tinyint(4) NOT NULL AUTO_INCREMENT,
  `description` varchar(32) NOT NULL,
  `tenant_id` bigint(20) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `tenant_id` (`tenant_id`)
) ENGINE=MyISAM AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `annotation_types`
--

INSERT INTO `annotation_types` VALUES (1,'called',1),(2,'read',1),(3,'noted',1),(4,'changed',1),(5,'labeled',1),(6,'sms',1);

--
-- Table structure for table `annotations`
--

CREATE TABLE `annotations` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `annotation_type` tinyint(4) NOT NULL,
  `message_id` bigint(20) NOT NULL,
  `user_id` int(11) NOT NULL,
  `description` text CHARACTER SET latin1 NOT NULL,
  `created` datetime NOT NULL,
  `tenant_id` bigint(20) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `annotation_type_message_id` (`annotation_type`,`message_id`,`created`),
  KEY `created` (`created`),
  KEY `tenant_id` (`tenant_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Dumping data for table `annotations`
--


--
-- Table structure for table `audio_files`
--

CREATE TABLE `audio_files` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `label` varchar(255) DEFAULT NULL,
  `user_id` int(11) NOT NULL,
  `url` varchar(255) DEFAULT NULL,
  `recording_call_sid` varchar(100) DEFAULT NULL,
  `tag` varchar(100) DEFAULT NULL,
  `cancelled` tinyint(4) DEFAULT '0',
  `created` datetime DEFAULT NULL,
  `updated` datetime DEFAULT NULL,
  `tenant_id` bigint(20) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`),
  KEY `url` (`url`),
  KEY `recording_call_sid` (`recording_call_sid`),
  KEY `tag` (`tag`),
  KEY `tenant_id` (`tenant_id`)
) ENGINE=MyISAM AUTO_INCREMENT=8 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `audio_files`
--

INSERT INTO `audio_files` VALUES (1,'Recording with (704) 326-6746',1,NULL,'CAe5f558b73888c8c6e79796c112dc903d','global',1,'2011-03-05 13:21:44','2011-03-05 13:22:18',1),(2,'Recording with (704) 326-6746',1,NULL,'CAd9e739835384b4fed5b270a29f871994','global',1,'2011-03-05 13:22:21','2011-03-05 13:22:47',1),(3,'Recording with (704) 326-6746',1,NULL,'CAfb9b90212bd74139b67549dd1e5f6056','global',1,'2011-03-05 13:22:52','2011-03-05 13:27:17',1),(4,'Recording with (704) 326-6746',1,NULL,'CA771564277654ebb2669519d5fcf1229f','global',1,'2011-03-05 13:28:35','2011-03-05 13:28:53',1),(5,'Recording with (704) 326-6746',1,NULL,'CA95db4757db42ca708961c39779f33219','global',1,'2011-03-05 13:32:08','2011-03-05 13:32:24',1),(6,'Recording with (704) 326-6746',1,NULL,'CA3a2ab1b237d3fdc35a8242e54c81b04b','global',1,'2011-03-05 14:04:18','2011-03-05 14:04:41',1),(7,'Recording with (704) 326-6746',1,NULL,'CAdd1d272f009d8ab3b94400a2dbe096c4','user_id:1',1,'2011-03-05 14:08:14','2011-03-05 14:08:28',1);

--
-- Table structure for table `auth_types`
--

CREATE TABLE `auth_types` (
  `id` tinyint(4) NOT NULL AUTO_INCREMENT,
  `description` varchar(255) NOT NULL,
  `tenant_id` bigint(20) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `tenant_id` (`tenant_id`)
) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `auth_types`
--

INSERT INTO `auth_types` VALUES (1,'openvbx',1),(2,'google',1);

--
-- Table structure for table `flow_store`
--

CREATE TABLE `flow_store` (
  `key` varchar(255) NOT NULL,
  `value` text,
  `flow_id` int(11) NOT NULL,
  `tenant_id` bigint(20) NOT NULL,
  UNIQUE KEY `key_flow` (`key`,`flow_id`),
  KEY `key` (`key`,`flow_id`),
  KEY `tenant_id` (`tenant_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Dumping data for table `flow_store`
--


--
-- Table structure for table `flows`
--

CREATE TABLE `flows` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(100) NOT NULL,
  `user_id` int(11) NOT NULL,
  `created` datetime DEFAULT NULL,
  `updated` datetime DEFAULT NULL,
  `data` text,
  `sms_data` text,
  `tenant_id` bigint(20) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `name` (`name`,`tenant_id`),
  KEY `user_id` (`user_id`),
  KEY `tenant_id` (`tenant_id`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `flows`
--

INSERT INTO `flows` VALUES (1,'Zigsby Main',1,NULL,NULL,'{\"start\":{\"name\":\"Call Start\",\"data\":{\"next\":\"start/7c65f8\"},\"id\":\"start\",\"type\":\"standard---start\"},\"7c65f8\":{\"name\":\"Dial\",\"data\":{\"dial-whom-selector\":\"user-or-group\",\"dial-whom-user-or-group_id\":\"1\",\"dial-whom-user-or-group_type\":\"user\",\"dial-whom-number\":\"\",\"no-answer-action\":\"voicemail\",\"no-answer-group-voicemail_say\":\"\",\"no-answer-group-voicemail_play\":\"\",\"no-answer-group-voicemail_mode\":\"\",\"no-answer-group-voicemail_tag\":\"global\",\"number\":\"\",\"library\":\"\",\"no-answer-redirect\":\"\",\"no-answer-redirect-number\":\"\",\"version\":\"3\"},\"id\":\"7c65f8\",\"type\":\"standard---dial\"}}',NULL,1);

--
-- Table structure for table `group_annotations`
--

CREATE TABLE `group_annotations` (
  `group_id` int(11) NOT NULL,
  `annotation_id` bigint(20) NOT NULL,
  `tenant_id` bigint(20) NOT NULL,
  PRIMARY KEY (`group_id`,`annotation_id`),
  KEY `tenant_id` (`tenant_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Dumping data for table `group_annotations`
--


--
-- Table structure for table `group_messages`
--

CREATE TABLE `group_messages` (
  `group_id` int(11) NOT NULL,
  `message_id` int(11) NOT NULL,
  `tenant_id` bigint(20) NOT NULL,
  PRIMARY KEY (`group_id`,`message_id`),
  KEY `tenant_id` (`tenant_id`),
  KEY `message_id` (`message_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Dumping data for table `group_messages`
--


--
-- Table structure for table `groups`
--

CREATE TABLE `groups` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(100) DEFAULT NULL,
  `is_active` tinyint(4) NOT NULL DEFAULT '1',
  `tenant_id` bigint(20) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `tenant_id` (`tenant_id`)
) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `groups`
--

INSERT INTO `groups` VALUES (1,'Sales',1,1),(2,'Support',1,1);

--
-- Table structure for table `groups_users`
--

CREATE TABLE `groups_users` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `group_id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `tenant_id` bigint(20) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `group_id` (`group_id`),
  KEY `tenant_id` (`tenant_id`),
  KEY `user_id` (`user_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Dumping data for table `groups_users`
--


--
-- Table structure for table `messages`
--

CREATE TABLE `messages` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `created` datetime DEFAULT NULL,
  `updated` datetime DEFAULT NULL,
  `read` datetime DEFAULT NULL,
  `call_sid` varchar(40) DEFAULT NULL,
  `caller` varchar(20) DEFAULT NULL,
  `called` varchar(20) DEFAULT NULL,
  `type` varchar(10) DEFAULT NULL,
  `status` varchar(10) DEFAULT NULL,
  `content_url` varchar(255) DEFAULT NULL,
  `content_text` varchar(5000) DEFAULT NULL,
  `notes` varchar(5000) DEFAULT NULL,
  `size` smallint(6) DEFAULT NULL,
  `assigned_to` bigint(20) DEFAULT NULL,
  `archived` tinyint(4) NOT NULL DEFAULT '0',
  `ticket_status` enum('open','closed','pending') NOT NULL DEFAULT 'open',
  `tenant_id` bigint(20) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `call_sid` (`call_sid`),
  KEY `tenant_id` (`tenant_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Dumping data for table `messages`
--


--
-- Table structure for table `numbers`
--

CREATE TABLE `numbers` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `name` varchar(100) DEFAULT NULL,
  `value` text NOT NULL,
  `is_active` tinyint(1) DEFAULT '1',
  `sms` tinyint(1) DEFAULT '0',
  `sequence` smallint(6) DEFAULT NULL,
  `tenant_id` bigint(20) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`),
  KEY `tenant_id` (`tenant_id`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `numbers`
--

INSERT INTO `numbers` VALUES (1,1,'Chris Cell','+17043266746',1,0,NULL,1);

--
-- Table structure for table `plugin_store`
--

CREATE TABLE `plugin_store` (
  `key` varchar(255) NOT NULL,
  `value` text,
  `plugin_id` varchar(34) NOT NULL,
  `tenant_id` bigint(20) NOT NULL,
  UNIQUE KEY `key_plugin` (`key`,`plugin_id`,`tenant_id`),
  KEY `key` (`key`,`plugin_id`),
  KEY `tenant_id` (`tenant_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Dumping data for table `plugin_store`
--


--
-- Table structure for table `rest_access`
--

CREATE TABLE `rest_access` (
  `key` varchar(32) NOT NULL,
  `locked` tinyint(4) NOT NULL DEFAULT '0',
  `created` datetime NOT NULL,
  `user_id` int(11) NOT NULL,
  `tenant_id` bigint(20) NOT NULL,
  PRIMARY KEY (`key`),
  KEY `tenant_id` (`tenant_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Dumping data for table `rest_access`
--

INSERT INTO `rest_access` VALUES ('0bfbacb09f2235d2f80b5201519dd81b',1,'2011-03-05 13:22:21',1,1),('2a8766e24b2920aabbb29d8aa61147c2',1,'2011-03-05 14:04:18',1,1),('347baadf8942932868139465c8faa64c',1,'2011-03-05 14:08:14',1,1),('48969042acb80647b98a5ce916ba84da',1,'2011-03-05 13:32:07',1,1),('50f74973edb85e782365e689361c91ef',1,'2011-03-05 13:22:51',1,1),('626de9a9adaadb03484f967a1bc2fbd3',1,'2011-03-05 13:28:34',1,1),('d1e95edda5837c88bb8000beff2d8427',1,'2011-03-05 13:21:44',1,1);

--
-- Table structure for table `settings`
--

CREATE TABLE `settings` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `tenant_id` bigint(20) NOT NULL,
  `name` varchar(32) NOT NULL,
  `value` varchar(255) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `name` (`name`),
  KEY `tenant_id` (`tenant_id`,`name`)
) ENGINE=MyISAM AUTO_INCREMENT=16 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `settings`
--

INSERT INTO `settings` VALUES (1,1,'dash_rss',''),(2,1,'theme',''),(3,1,'version','0.90'),(4,1,'iphone_theme',''),(5,1,'enable_sandbox_number','1'),(6,1,'twilio_endpoint','https://api.twilio.com/2010-04-01'),(7,1,'recording_host',''),(8,1,'twilio_sid','AC029a65932d6fcacffc41f26ff125dbb7'),(9,1,'twilio_token','02c91a477cc5d931be6847a93a7f34ba'),(10,1,'from_email','admin@zigsby.com'),(11,1,'theme',''),(12,1,'iphone_theme',''),(13,1,'trial_number','(415) 599-2671'),(14,1,'schema-version','46'),(15,1,'rewrite_enabled','1');

--
-- Table structure for table `tenants`
--

CREATE TABLE `tenants` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `url_prefix` varchar(255) NOT NULL,
  `local_prefix` varchar(1000) NOT NULL,
  `active` tinyint(4) NOT NULL DEFAULT '1',
  PRIMARY KEY (`id`),
  KEY `name` (`name`),
  KEY `url_prefix` (`url_prefix`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tenants`
--

INSERT INTO `tenants` VALUES (1,'default','','',1);

--
-- Table structure for table `user_annotations`
--

CREATE TABLE `user_annotations` (
  `user_id` int(11) NOT NULL,
  `annotation_id` bigint(20) NOT NULL,
  `tenant_id` bigint(20) NOT NULL,
  PRIMARY KEY (`user_id`,`annotation_id`),
  KEY `tenant_id` (`tenant_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Dumping data for table `user_annotations`
--


--
-- Table structure for table `user_messages`
--

CREATE TABLE `user_messages` (
  `user_id` int(11) NOT NULL,
  `message_id` int(11) NOT NULL,
  `tenant_id` bigint(20) NOT NULL,
  PRIMARY KEY (`user_id`,`message_id`),
  KEY `tenant_id` (`tenant_id`),
  KEY `message_id` (`message_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Dumping data for table `user_messages`
--


--
-- Table structure for table `users`
--

CREATE TABLE `users` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `is_admin` tinyint(1) DEFAULT NULL,
  `is_active` tinyint(1) DEFAULT '1',
  `first_name` varchar(100) DEFAULT NULL,
  `last_name` varchar(100) DEFAULT NULL,
  `password` varchar(40) DEFAULT NULL,
  `invite_code` varchar(32) DEFAULT NULL,
  `email` varchar(200) DEFAULT NULL,
  `pin` varchar(40) DEFAULT NULL,
  `notification` varchar(20) DEFAULT NULL,
  `auth_type` tinyint(4) NOT NULL DEFAULT '1',
  `voicemail` text NOT NULL,
  `tenant_id` bigint(20) NOT NULL,
  `last_seen` datetime DEFAULT NULL,
  `last_login` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `email` (`email`,`tenant_id`),
  KEY `tenant_id` (`tenant_id`),
  KEY `auth_type` (`auth_type`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `users`
--

INSERT INTO `users` VALUES (1,1,1,'Chris','C','ef1186224ce05f7274ad5600c4e9cfaf6451d7e3','ef1186224ce05f7274ad5600c4e9cfaf','admin@zigsby.com',NULL,NULL,1,'Please leave a message after the beep.',1,'2011-03-05 14:08:29','2011-03-05 14:03:44');


