SET FOREIGN_KEY_CHECKS=0;

/*Table structure for table `t_account` */

DROP TABLE IF EXISTS `t_account`;

CREATE TABLE `t_account` (
  `oid` bigint(20) NOT NULL default '0',
  `id` varchar(32) default NULL,
  `type` int(11) default NULL,
  `start_date` timestamp NULL default '0000-00-00 00:00:00',
  `status` int(11) default NULL,
  `end_date` timestamp NULL default '0000-00-00 00:00:00',
  `account_name` varchar(100) default NULL,
  `account2address` bigint(20) default NULL,
  `owner` bigint(20) default NULL,
  `perms` int(11) default NULL,
  `permission` int(11) default NULL,
  `group_id` bigint(20) default NULL,
  PRIMARY KEY  (`oid`),
  KEY `FK_t_account` (`account2address`),
  CONSTRAINT `t_account_ibfk_1` FOREIGN KEY (`account2address`) REFERENCES `t_address` (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_activity` */

DROP TABLE IF EXISTS `t_activity`;

CREATE TABLE `t_activity` (
  `oid` bigint(20) NOT NULL default '0',
  `last_modified` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  `action` varchar(64) default NULL,
  `focus` varchar(64) default NULL,
  `username` varchar(64) default NULL,
  `user_id` bigint(20) default NULL,
  `focus_type` bigint(20) default NULL,
  `focus_id` bigint(20) default NULL,
  `text` varchar(128) default NULL,
  PRIMARY KEY  (`oid`),
  KEY `FK_t_activity` (`user_id`),
  CONSTRAINT `t_activity_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `oms_user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_address` */

DROP TABLE IF EXISTS `t_address`;

CREATE TABLE `t_address` (
  `oid` bigint(20) NOT NULL default '0',
  `recipient` varchar(64) default NULL,
  `address` varchar(32) default NULL,
  `address2` varchar(32) default NULL,
  `city` varchar(32) default NULL,
  `county` varchar(32) default NULL,
  `country` varchar(32) default NULL,
  `zipcode` varchar(16) default NULL,
  PRIMARY KEY  (`oid`),
  UNIQUE KEY `oid` (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_case` */

DROP TABLE IF EXISTS `t_case`;

CREATE TABLE `t_case` (
  `oid` bigint(20) NOT NULL default '0',
  `ref` varchar(32) NOT NULL,
  `title` varchar(128) NOT NULL,
  `case_type1` int(11) default NULL,
  `case_type2` int(11) default NULL,
  `case_type3` int(11) default NULL,
  `creation_time` timestamp NULL default NULL,
  `close_time` timestamp NULL default '0000-00-00 00:00:00',
  `importance` int(11) default NULL,
  `urgency` int(11) default NULL,
  `priority` int(11) default NULL,
  `status` int(11) default NULL,
  `owner` bigint(20) default NULL,
  `creator` bigint(20) default NULL,
  `group_id` bigint(20) default NULL,
  `last_modified_by` bigint(20) default NULL,
  `closed_by` bigint(20) default NULL,
  `permission` int(11) default NULL,
  `access` int(11) default NULL,
  `last_modified` timestamp NULL default '0000-00-00 00:00:00',
  PRIMARY KEY  (`oid`),
  UNIQUE KEY `id` (`ref`),
  KEY `owner` (`owner`),
  KEY `creator` (`creator`),
  KEY `last_modified_by` (`last_modified_by`),
  KEY `closed_by` (`closed_by`),
  KEY `group_id` (`group_id`),
  CONSTRAINT `t_case_ibfk_1` FOREIGN KEY (`owner`) REFERENCES `oms_user` (`id`),
  CONSTRAINT `t_case_ibfk_10` FOREIGN KEY (`closed_by`) REFERENCES `oms_user` (`id`),
  CONSTRAINT `t_case_ibfk_2` FOREIGN KEY (`creator`) REFERENCES `oms_user` (`id`),
  CONSTRAINT `t_case_ibfk_4` FOREIGN KEY (`last_modified_by`) REFERENCES `oms_user` (`id`),
  CONSTRAINT `t_case_ibfk_5` FOREIGN KEY (`group_id`) REFERENCES `oms_employee_group` (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;

/*Table structure for table `t_catalogue` */

DROP TABLE IF EXISTS `t_catalogue`;

CREATE TABLE `t_catalogue` (
  `oid` bigint(20) NOT NULL,
  `name` varchar(40) default NULL,
  `activation_date` timestamp NULL default NULL,
  `deactivation_date` timestamp NULL default NULL,
  `version` int(11) default NULL,
  `status` int(11) default NULL,
  PRIMARY KEY  (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_company` */

DROP TABLE IF EXISTS `t_company`;

CREATE TABLE `t_company` (
  `oid` bigint(20) NOT NULL default '0',
  `type` int(11) default NULL,
  `creation_time` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  `status` int(11) default NULL,
  `owner` bigint(20) default NULL,
  `group_id` bigint(20) default NULL,
  `perms` int(11) default NULL,
  PRIMARY KEY  (`oid`),
  UNIQUE KEY `oid` (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_contact` */

DROP TABLE IF EXISTS `t_contact`;

CREATE TABLE `t_contact` (
  `oid` bigint(20) NOT NULL default '0',
  `name` varchar(32) default NULL,
  `surname1` varchar(32) default NULL,
  `surname2` varchar(32) default NULL,
  `status` int(11) NOT NULL default '0',
  `contact2person` bigint(20) default '0' COMMENT 'OTO relation with Person',
  `contact2info` bigint(20) default NULL,
  `start_date` timestamp NULL default NULL,
  `end_date` timestamp NULL default NULL,
  `contact2site` bigint(20) default NULL,
  `owner` bigint(20) default NULL,
  `perms` int(11) default NULL,
  `group_id` bigint(20) default NULL,
  `primary_phone` varchar(20) default NULL,
  `primary_email` varchar(32) default NULL,
  PRIMARY KEY  (`oid`),
  KEY `contact2person` (`contact2person`),
  KEY `FK_t_contact` (`contact2info`),
  KEY `FK_t_contact_ibfk1` (`contact2site`),
  CONSTRAINT `t_contact_ibfk_2` FOREIGN KEY (`contact2info`) REFERENCES `t_contact_info` (`oid`),
  CONSTRAINT `t_contact_ibfk_3` FOREIGN KEY (`contact2person`) REFERENCES `t_person` (`oid`),
  CONSTRAINT `t_contact_ibfk_4` FOREIGN KEY (`contact2site`) REFERENCES `t_site` (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC COMMENT='InnoDB free: 11264 kB';

/*Table structure for table `t_contact_info` */

DROP TABLE IF EXISTS `t_contact_info`;

CREATE TABLE `t_contact_info` (
  `oid` bigint(20) NOT NULL default '0',
  `phone` varchar(32) default NULL,
  `phone2` varchar(32) default NULL,
  `email` varchar(32) default NULL,
  `web` varchar(128) default NULL,
  `contact_info2contact` bigint(20) default NULL,
  PRIMARY KEY  (`oid`),
  KEY `FK_t_contact_info` (`contact_info2contact`),
  CONSTRAINT `t_contact_info_ibfk_1` FOREIGN KEY (`contact_info2contact`) REFERENCES `t_contact` (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_contract` */

DROP TABLE IF EXISTS `t_contract`;

CREATE TABLE `t_contract` (
  `oid` bigint(20) NOT NULL default '0',
  `contract_id` int(11) default NULL,
  `description` varchar(32) default NULL,
  `start_date` timestamp NULL default NULL,
  `end_date` timestamp NULL default NULL,
  `last_modified` timestamp NULL default NULL,
  PRIMARY KEY  (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_delivery_note` */

DROP TABLE IF EXISTS `t_delivery_note`;

CREATE TABLE `t_delivery_note` (
  `oid` bigint(20) NOT NULL,
  `delivery_date` datetime default NULL,
  `delivered_to` varchar(32) default NULL,
  `accepted_by` varchar(32) default NULL,
  `status` int(11) default NULL COMMENT 'accepted, rejected, pending delivery',
  `delivery2order` bigint(20) default NULL,
  `delivery2account` bigint(20) default NULL,
  `[REDACTED]` bigint(20) default NULL,
  PRIMARY KEY  (`oid`),
  KEY `FK_t_delivery_note` (`delivery2account`),
  KEY `FK_t_delivery_note2order` (`delivery2order`),
  KEY `FK_t_delivery_note2invoice` (`delivery2invoice`),
  CONSTRAINT `t_delivery_note_ibfk_1` FOREIGN KEY (`delivery2account`) REFERENCES `t_account` (`oid`),
  CONSTRAINT `t_delivery_note_ibfk_2` FOREIGN KEY (`delivery2order`) REFERENCES `t_order` (`oid`),
  CONSTRAINT `t_delivery_note_ibfk_3` FOREIGN KEY (`delivery2invoice`) REFERENCES `t_invoice` (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_html_section` */

DROP TABLE IF EXISTS `t_html_section`;

CREATE TABLE `t_html_section` (
  `oid` bigint(20) NOT NULL,
  `domain` varchar(20) default NULL,
  `name` varchar(20) default NULL,
  `html` varchar(4000) default NULL,
  `lang` varchar(5) default NULL,
  PRIMARY KEY  (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_interaction` */

DROP TABLE IF EXISTS `t_interaction`;

CREATE TABLE `t_interaction` (
  `oid` bigint(20) NOT NULL,
  `title` varchar(40) NOT NULL,
  `channel` varchar(20) default NULL,
  `type1` varchar(20) default NULL,
  `type2` varchar(20) default NULL,
  `type3` varchar(20) default NULL,
  `creation_time` timestamp NULL default NULL,
  `close_time` timestamp NULL default NULL,
  `created_by` bigint(20) default NULL,
  `description` varchar(255) default NULL,
  `text` varchar(4000) default NULL,
  `group_id` bigint(20) default NULL,
  `access` int(11) default NULL,
  `perms` int(11) default NULL,
  `status` int(11) default NULL,
  `interaction2contact` bigint(20) default NULL,
  `interaction2site` bigint(20) default NULL,
  `last_modified` timestamp NULL default NULL,
  PRIMARY KEY  (`oid`),
  KEY `FK_t_interaction2contact` (`interaction2contact`),
  KEY `FK_t_interaction2site` (`interaction2site`),
  KEY `FK_t_interaction` (`created_by`),
  CONSTRAINT `t_interaction_ibfk_1` FOREIGN KEY (`interaction2contact`) REFERENCES `t_contact` (`oid`),
  CONSTRAINT `t_interaction_ibfk_2` FOREIGN KEY (`interaction2site`) REFERENCES `t_site` (`oid`),
  CONSTRAINT `t_interaction_ibfk_3` FOREIGN KEY (`created_by`) REFERENCES `oms_user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_invoice` */

DROP TABLE IF EXISTS `t_invoice`;

CREATE TABLE `t_invoice` (
  `oid` bigint(20) NOT NULL,
  `invoice_id` int(11) NOT NULL,
  `issue_date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  `total_amount` double default NULL,
  `invoice2site` bigint(20) default NULL,
  `invoice2account` bigint(20) default NULL,
  `[REDACTED]` bigint(20) default NULL,
  `invoice2contact` bigint(20) default NULL,
  PRIMARY KEY  (`oid`),
  UNIQUE KEY `invoice_id` (`invoice_id`),
  KEY `FK_t_invoice2account` (`invoice2account`),
  KEY `FK_t_invoice2contact` (`invoice2contact`),
  KEY `FK_t_invoice2employee` (`invoice2employee`),
  KEY `FK_t_invoice` (`invoice2site`),
  CONSTRAINT `t_invoice_ibfk_1` FOREIGN KEY (`invoice2account`) REFERENCES `t_account` (`oid`),
  CONSTRAINT `t_invoice_ibfk_2` FOREIGN KEY (`invoice2contact`) REFERENCES `t_contact` (`oid`),
  CONSTRAINT `t_invoice_ibfk_4` FOREIGN KEY (`invoice2site`) REFERENCES `t_site` (`oid`),
  CONSTRAINT `t_invoice_ibfk_5` FOREIGN KEY (`invoice2employee`) REFERENCES `oms_employee` (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_invoice_detail` */

DROP TABLE IF EXISTS `t_invoice_detail`;

CREATE TABLE `t_invoice_detail` (
  `oid` bigint(20) NOT NULL default '0',
  `quantity` double NOT NULL,
  `unit_cost` double NOT NULL,
  `total_cost` double NOT NULL,
  `invoice_id` bigint(20) NOT NULL,
  `product_id` bigint(20) NOT NULL,
  `invoice_detail2invoice_subse` bigint(20) default NULL,
  `[REDACTED]` bigint(20) default NULL,
  `[REDACTED]` bigint(20) default NULL,
  PRIMARY KEY  (`oid`),
  KEY `invoice_id` (`invoice_id`),
  KEY `product_id` (`product_id`),
  CONSTRAINT `t_invoice_detail_ibfk_1` FOREIGN KEY (`invoice_id`) REFERENCES `t_invoice` (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_invoice_section` */

DROP TABLE IF EXISTS `t_invoice_section`;

CREATE TABLE `t_invoice_section` (
  `oid` bigint(20) NOT NULL default '0',
  `invoice_id` int(11) default NULL,
  `start_date` timestamp NULL default NULL,
  `end_date` timestamp NULL default NULL,
  `last_modified` timestamp NULL default NULL,
  `desciption` varchar(32) default NULL,
  `[REDACTED]` bigint(20) default NULL,
  `[REDACTED]` bigint(20) default NULL,
  PRIMARY KEY  (`oid`),
  KEY `FK_t_invoice_section` (`invoice_section2invoice`),
  CONSTRAINT `t_invoice_section_ibfk_1` FOREIGN KEY (`invoice_section2invoice`) REFERENCES `t_invoice` (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_invoice_subsection` */

DROP TABLE IF EXISTS `t_invoice_subsection`;

CREATE TABLE `t_invoice_subsection` (
  `oid` bigint(20) NOT NULL default '0',
  `invoice_id` int(11) default NULL,
  `start_date` timestamp NULL default NULL,
  `end_date` timestamp NULL default NULL,
  `last_modified` timestamp NULL default NULL,
  `desription` varchar(32) default NULL,
  `[REDACTED]` bigint(20) default NULL,
  `[REDACTED]` bigint(20) default NULL,
  `[REDACTED]` bigint(20) default NULL,
  PRIMARY KEY  (`oid`),
  KEY `FK_t_invoice_subsection2section` (`invoice_subsection2section`),
  KEY `FK_t_invoice_subsection2prod` (`invoice_subsection2prod_inst`),
  KEY `FK_t_invoice_subsection` (`invoice_subsection2svc_inst`),
  CONSTRAINT `t_invoice_subsection_ibfk_1` FOREIGN KEY (`invoice_subsection2section`) REFERENCES `t_invoice_section` (`oid`),
  CONSTRAINT `t_invoice_subsection_ibfk_2` FOREIGN KEY (`invoice_subsection2prod_inst`) REFERENCES `t_prod_inst` (`oid`),
  CONSTRAINT `t_invoice_subsection_ibfk_3` FOREIGN KEY (`invoice_subsection2svc_inst`) REFERENCES `t_svc_inst` (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_leads` */

DROP TABLE IF EXISTS `t_leads`;

CREATE TABLE `t_leads` (
  `oid` bigint(20) NOT NULL,
  `date_entered` datetime default NULL,
  `date_modified` datetime default NULL,
  `last_modified_by` bigint(20) default NULL,
  `created_by` bigint(20) default NULL,
  `description` text,
  `assigned_user` bigint(20) default NULL,
  `salutation` varchar(5) default NULL,
  `first_name` varchar(100) default NULL,
  `last_name` varchar(100) default NULL,
  `title` varchar(100) default NULL,
  `department` varchar(100) default NULL,
  `do_not_call` tinyint(1) default '0',
  `phone_home` varchar(25) default NULL,
  `phone_mobile` varchar(25) default NULL,
  `phone_work` varchar(25) default NULL,
  `phone_other` varchar(25) default NULL,
  `phone_fax` varchar(25) default NULL,
  `primary_address_street` varchar(150) default NULL,
  `primary_address_city` varchar(100) default NULL,
  `primary_address_state` varchar(100) default NULL,
  `primary_address_postalcode` varchar(20) default NULL,
  `primary_address_country` varchar(255) default NULL,
  `alt_address_street` varchar(150) default NULL,
  `alt_address_city` varchar(100) default NULL,
  `alt_address_state` varchar(100) default NULL,
  `alt_address_postalcode` varchar(20) default NULL,
  `alt_address_country` varchar(255) default NULL,
  `assistant` varchar(75) default NULL,
  `assistant_phone` varchar(25) default NULL,
  `converted` tinyint(1) default '0',
  `refered_by` varchar(100) default NULL,
  `lead_source` varchar(100) default NULL,
  `lead_source_description` text,
  `status` varchar(100) default NULL,
  `status_description` text,
  `reports_to_id` bigint(20) default NULL,
  `account_name` varchar(255) default NULL,
  `account_description` text,
  `lead2contact` bigint(20) default NULL,
  `lead2account` bigint(20) default NULL,
  `lead2opportunity` bigint(20) default NULL,
  `opportunity_name` varchar(255) default NULL,
  `opportunity_amount` varchar(50) default NULL,
  `lead2campaign` bigint(20) default NULL,
  PRIMARY KEY  (`oid`),
  KEY `idx_lead_acct_name_first` (`account_name`),
  KEY `idx_lead_last_first` (`last_name`,`first_name`),
  KEY `idx_lead_opp` (`lead2opportunity`),
  KEY `idx_leads_acct` (`lead2account`),
  KEY `idx_user` (`assigned_user`),
  KEY `idx_lead_assigned` (`assigned_user`),
  KEY `idx_lead_contact` (`lead2contact`),
  CONSTRAINT `t_leads_ibfk_1` FOREIGN KEY (`lead2contact`) REFERENCES `t_contact` (`oid`),
  CONSTRAINT `t_leads_ibfk_2` FOREIGN KEY (`lead2account`) REFERENCES `t_account` (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_m_activity` */

DROP TABLE IF EXISTS `t_m_activity`;

CREATE TABLE `t_m_activity` (
  `oid` bigint(20) NOT NULL,
  `name` varchar(50) default NULL,
  PRIMARY KEY  (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_m_currency` */

DROP TABLE IF EXISTS `t_m_currency`;

CREATE TABLE `t_m_currency` (
  `oid` int(20) NOT NULL,
  `name` varchar(64) NOT NULL,
  `code` varchar(5) NOT NULL,
  `symbol` varchar(5) default NULL,
  `subdivision` varchar(64) default NULL,
  `subdivision_factor` int(11) default NULL,
  `country_id` int(20) default NULL,
  PRIMARY KEY  (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_m_folder` */

DROP TABLE IF EXISTS `t_m_folder`;

CREATE TABLE `t_m_folder` (
  `oid` bigint(20) NOT NULL default '0',
  `name` varchar(32) NOT NULL default '',
  `level` smallint(6) NOT NULL default '0',
  `folder2parent` bigint(20) default NULL,
  `perms` int(11) default NULL,
  `owner` bigint(20) default NULL,
  `group_id` bigint(20) default NULL,
  PRIMARY KEY  (`oid`),
  KEY `FK_t_m_folder2parent` (`folder2parent`),
  KEY `FK_t_m_folder2owner2` (`owner`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_m_product` */

DROP TABLE IF EXISTS `t_m_product`;

CREATE TABLE `t_m_product` (
  `oid` bigint(20) NOT NULL default '0',
  `product_id` varchar(64) NOT NULL,
  `name` varchar(64) NOT NULL,
  `product_group` varchar(64) NOT NULL,
  `manufacturer` varchar(64) default NULL,
  `model` varchar(64) default NULL,
  `edition` varchar(64) default NULL,
  `price` double NOT NULL,
  `tax_rate` float default NULL,
  `product2prod_package` bigint(20) default NULL,
  `picture` mediumblob,
  PRIMARY KEY  (`oid`),
  UNIQUE KEY `product_id` (`product_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_m_queue` */

DROP TABLE IF EXISTS `t_m_queue`;

CREATE TABLE `t_m_queue` (
  `oid` bigint(20) NOT NULL default '0',
  `name` varchar(32) NOT NULL default '',
  `status` int(11) NOT NULL default '0',
  `queue2admin` bigint(20) default NULL,
  `perms` int(11) default NULL,
  `owner` bigint(20) default NULL,
  `group_id` bigint(20) default NULL,
  PRIMARY KEY  (`oid`),
  UNIQUE KEY `oid` (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_m_role` */

DROP TABLE IF EXISTS `t_m_role`;

CREATE TABLE `t_m_role` (
  `oid` bigint(20) NOT NULL default '0',
  `name` varchar(32) NOT NULL default '',
  PRIMARY KEY  (`oid`),
  UNIQUE KEY `oid` (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_m_service` */

DROP TABLE IF EXISTS `t_m_service`;

CREATE TABLE `t_m_service` (
  `oid` bigint(20) NOT NULL default '0',
  `id` varchar(32) NOT NULL default '',
  `product_group` int(11) default NULL,
  `product_subgroup` int(11) default NULL,
  `service_type` int(11) default NULL,
  `start_date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  `end_date` timestamp NOT NULL default '0000-00-00 00:00:00',
  `status` int(11) NOT NULL default '0',
  PRIMARY KEY  (`oid`),
  UNIQUE KEY `id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_meetings` */

DROP TABLE IF EXISTS `t_meetings`;

CREATE TABLE `t_meetings` (
  `oid` int(20) NOT NULL,
  `name` varchar(50) default NULL,
  `date_entered` datetime default NULL,
  `last_modified` datetime default NULL,
  `last_modified_by` bigint(20) default NULL,
  `created_by` bigint(20) default NULL,
  `description` text,
  `deleted` tinyint(1) default '0',
  `assigned_user_id` bigint(20) default NULL,
  `location` varchar(50) default NULL,
  `date_start` datetime default NULL,
  `date_end` datetime default NULL,
  `status` int(11) default NULL,
  `alarm_time` datetime default NULL,
  PRIMARY KEY  (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_notes` */

DROP TABLE IF EXISTS `t_notes`;

CREATE TABLE `t_notes` (
  `oid` bigint(20) NOT NULL default '0',
  `text` varchar(4000) default NULL,
  `created_by` bigint(20) default NULL,
  `internal` tinyint(1) default NULL,
  `last_modified` timestamp NULL default NULL,
  PRIMARY KEY  (`oid`),
  UNIQUE KEY `oid` (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_opportunity` */

DROP TABLE IF EXISTS `t_opportunity`;

CREATE TABLE `t_opportunity` (
  `oid` bigint(20) default NULL,
  `ref` varchar(32) default NULL,
  `title` varchar(255) default NULL,
  `creation_time` datetime default NULL,
  `status` int(11) default NULL,
  `creator` bigint(20) default NULL,
  `owner` bigint(20) default NULL,
  `last_modified_by` bigint(20) default NULL,
  `closed_by` bigint(20) default NULL,
  `group_id` bigint(20) default NULL,
  `access` int(11) default NULL,
  `perms` int(11) default NULL,
  `last_modified` datetime default NULL,
  `close_time` bigint(20) default NULL,
  KEY `owner` (`owner`),
  KEY `creator` (`creator`),
  KEY `last_modified_by` (`last_modified_by`),
  KEY `closed_by` (`closed_by`),
  KEY `group_id` (`group_id`),
  CONSTRAINT `t_opportunity_ibfk_1` FOREIGN KEY (`creator`) REFERENCES `oms_user` (`id`),
  CONSTRAINT `t_opportunity_ibfk_2` FOREIGN KEY (`closed_by`) REFERENCES `oms_user` (`id`),
  CONSTRAINT `t_opportunity_ibfk_3` FOREIGN KEY (`last_modified_by`) REFERENCES `oms_user` (`id`),
  CONSTRAINT `t_opportunity_ibfk_4` FOREIGN KEY (`owner`) REFERENCES `oms_user` (`id`),
  CONSTRAINT `t_opportunity_ibfk_5` FOREIGN KEY (`group_id`) REFERENCES `oms_employee_group` (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_order` */

DROP TABLE IF EXISTS `t_order`;

CREATE TABLE `t_order` (
  `oid` bigint(20) NOT NULL default '0',
  `ref` varchar(32) default NULL,
  `title` varchar(255) default NULL,
  `date` datetime default NULL,
  `status` int(11) default NULL,
  `creation_time` timestamp NULL default NULL,
  `close_time` timestamp NULL default NULL,
  `order2site` bigint(20) default NULL,
  `owner` bigint(20) default NULL,
  `perms` int(11) default NULL,
  `group_id` bigint(20) default NULL,
  `last_modified` datetime default NULL,
  `base_amount` float default NULL,
  `tax_amount` float default NULL,
  `total_amount` float default NULL,
  `shipping_amount` float default NULL,
  `other_charges` float default NULL,
  `comments` varchar(4000) default NULL,
  `last_modified_by` bigint(20) default NULL,
  `creator` bigint(20) default NULL,
  `closed_by` bigint(20) default NULL,
  PRIMARY KEY  (`oid`),
  KEY `FK_t_order` (`order2site`),
  CONSTRAINT `t_order_ibfk_1` FOREIGN KEY (`order2site`) REFERENCES `t_site` (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_package_info` */

DROP TABLE IF EXISTS `t_package_info`;

CREATE TABLE `t_package_info` (
  `oid` bigint(20) NOT NULL,
  `ref` varchar(32) default NULL,
  `provider` varchar(32) default NULL,
  `emission_date` datetime default NULL,
  `reception_date` datetime default NULL,
  `status` int(11) default NULL,
  `last_modified` datetime default NULL,
  PRIMARY KEY  (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_part_info` */

DROP TABLE IF EXISTS `t_part_info`;

CREATE TABLE `t_part_info` (
  `oid` bigint(20) NOT NULL default '0',
  `product_id` int(11) default NULL,
  `part_id` int(11) default NULL,
  `description` varchar(32) default NULL,
  `default_price` float(100,3) default NULL,
  `model_no` varchar(11) default NULL,
  PRIMARY KEY  (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_person` */

DROP TABLE IF EXISTS `t_person`;

CREATE TABLE `t_person` (
  `oid` bigint(20) NOT NULL default '0',
  `title` varchar(32) default NULL,
  `firstname` varchar(32) default NULL,
  `lastname` varchar(32) default NULL,
  `lastname2` varchar(32) default NULL,
  `middlename` varchar(32) default NULL,
  `id_type` int(11) default NULL,
  `id_number` varchar(32) default NULL,
  `date_of_birth` datetime default NULL,
  `[REDACTED]` bigint(20) default NULL,
  `picture` mediumblob,
  PRIMARY KEY  (`oid`),
  KEY `FK_t_person` (`person2economics`),
  CONSTRAINT `t_person_ibfk_1` FOREIGN KEY (`person2economics`) REFERENCES `t_person_economics` (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_person_economics` */

DROP TABLE IF EXISTS `t_person_economics`;

CREATE TABLE `t_person_economics` (
  `oid` bigint(20) NOT NULL,
  `marital_status` int(11) default NULL,
  `number_of_children` int(11) default NULL,
  `job_title` varchar(64) default NULL,
  `company` varchar(64) default NULL,
  `academic_level` varchar(64) default NULL,
  `incomes_per_year` int(11) default NULL,
  `bank_account_number` varchar(64) default NULL,
  `credit_card_number` varchar(64) default NULL,
  PRIMARY KEY  (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_price` */

DROP TABLE IF EXISTS `t_price`;

CREATE TABLE `t_price` (
  `oid` bigint(20) NOT NULL default '0',
  `id` int(11) default NULL,
  `price_type` int(11) default NULL,
  `price` double(100,3) default NULL,
  `start_date` timestamp NULL default NULL,
  `end_time` timestamp NULL default '0000-00-00 00:00:00',
  `last_modified` timestamp NULL default '0000-00-00 00:00:00',
  PRIMARY KEY  (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_price_inst` */

DROP TABLE IF EXISTS `t_price_inst`;

CREATE TABLE `t_price_inst` (
  `oid` bigint(20) NOT NULL default '0',
  `price_id` int(11) default NULL,
  `id` int(11) default NULL,
  `currency_id` int(11) default NULL,
  `last_modified` timestamp NULL default '0000-00-00 00:00:00',
  `start_date` timestamp NULL default NULL,
  `end_date` timestamp NULL default '0000-00-00 00:00:00',
  `price_inst2price` bigint(20) default NULL,
  PRIMARY KEY  (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_prod_inst` */

DROP TABLE IF EXISTS `t_prod_inst`;

CREATE TABLE `t_prod_inst` (
  `oid` bigint(20) NOT NULL default '0',
  `product_id` varchar(32) default NULL,
  `product_name` varchar(100) default NULL,
  `quantity` int(32) default NULL,
  `unit_price` decimal(20,3) default NULL,
  `actual_price` decimal(20,3) default NULL,
  `discount` decimal(20,3) default NULL,
  `tax_rate` decimal(20,3) default NULL,
  `tax_amount` decimal(20,3) default NULL,
  `extended_price` decimal(20,3) default NULL,
  `start_date` timestamp NULL default NULL,
  `end_date` timestamp NULL default '0000-00-00 00:00:00',
  `status` int(11) default NULL,
  `prod_inst2site` bigint(20) default NULL,
  `prod_inst2product` bigint(20) default NULL,
  PRIMARY KEY  (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_prod_package` */

DROP TABLE IF EXISTS `t_prod_package`;

CREATE TABLE `t_prod_package` (
  `oid` bigint(20) NOT NULL default '0',
  `prod_pack_id` int(11) default NULL,
  `pack_name` varchar(32) default NULL,
  `no_of_types_of_prod` int(11) default NULL,
  `start_date` timestamp NULL default NULL,
  `end_date` timestamp NULL default '0000-00-00 00:00:00',
  `actual_price` float(100,3) default NULL,
  `discount` float(100,3) default NULL,
  `extended_price` double(100,3) default NULL,
  PRIMARY KEY  (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_prod_part` */

DROP TABLE IF EXISTS `t_prod_part`;

CREATE TABLE `t_prod_part` (
  `oid` bigint(20) NOT NULL default '0',
  `product_id` int(11) default NULL,
  `part_id` int(11) default NULL,
  `part_name` varchar(100) default NULL,
  `description` varchar(100) default NULL,
  `start_date` timestamp NULL default NULL,
  `end_date` timestamp NULL default '0000-00-00 00:00:00',
  `no_of_parts` int(11) default NULL,
  `unit_price` double(100,3) default NULL,
  `actual_price` double(100,3) default NULL,
  `discount` float(100,3) default NULL,
  `extened_price` double(100,3) default NULL,
  `status` int(11) default NULL,
  `product_part2product` bigint(20) default NULL,
  PRIMARY KEY  (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_project` */

DROP TABLE IF EXISTS `t_project`;

CREATE TABLE `t_project` (
  `oid` bigint(20) NOT NULL auto_increment,
  `id` bigint(20) default NULL,
  `date_entered` datetime default NULL,
  `assigned_user_id` bigint(20) default NULL,
  `last_modified_by` bigint(20) default NULL,
  `created_by` bigint(20) default NULL,
  `name` varchar(50) NOT NULL,
  `description` text,
  `deleted` tinyint(1) NOT NULL default '0',
  `estimated_start_date` date NOT NULL,
  `estimated_end_date` date NOT NULL,
  `status` varchar(255) default NULL,
  `priority` varchar(255) default NULL,
  `last_modified` datetime default NULL,
  PRIMARY KEY  (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_quote` */

DROP TABLE IF EXISTS `t_quote`;

CREATE TABLE `t_quote` (
  `oid` bigint(20) NOT NULL default '0',
  `ref` varchar(32) NOT NULL,
  `title` varchar(255) default NULL,
  `creation_time` datetime default NULL,
  `status` int(11) default NULL,
  `contact_id` bigint(20) default NULL,
  `invoice_id` bigint(20) default NULL,
  `creator` bigint(20) default NULL,
  `owner` bigint(20) default NULL,
  `last_modified_by` bigint(20) default NULL,
  `closed_by` bigint(20) default NULL,
  `group_id` bigint(20) default NULL,
  `access` int(11) default NULL,
  `perms` int(11) default NULL,
  `close_time` timestamp NULL default NULL,
  PRIMARY KEY  (`oid`),
  KEY `FK_t_quote` (`contact_id`),
  KEY `FK_t_quote2invoice` (`invoice_id`),
  KEY `owner` (`owner`),
  KEY `creator` (`creator`),
  KEY `last_modified_by` (`last_modified_by`),
  KEY `closed_by` (`closed_by`),
  KEY `group_id` (`group_id`),
  CONSTRAINT `t_quote_ibfk_1` FOREIGN KEY (`contact_id`) REFERENCES `t_contact` (`oid`),
  CONSTRAINT `t_quote_ibfk_2` FOREIGN KEY (`invoice_id`) REFERENCES `t_invoice` (`oid`),
  CONSTRAINT `t_quote_ibfk_3` FOREIGN KEY (`owner`) REFERENCES `oms_user` (`id`),
  CONSTRAINT `t_quote_ibfk_4` FOREIGN KEY (`last_modified_by`) REFERENCES `oms_user` (`id`),
  CONSTRAINT `t_quote_ibfk_5` FOREIGN KEY (`creator`) REFERENCES `oms_user` (`id`),
  CONSTRAINT `t_quote_ibfk_6` FOREIGN KEY (`closed_by`) REFERENCES `oms_user` (`id`),
  CONSTRAINT `t_quote_ibfk_7` FOREIGN KEY (`group_id`) REFERENCES `oms_employee_group` (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_site` */

DROP TABLE IF EXISTS `t_site`;

CREATE TABLE `t_site` (
  `oid` bigint(20) NOT NULL auto_increment,
  `name` varchar(100) default NULL,
  `site2account` bigint(20) default NULL,
  `site2address` bigint(20) default NULL,
  `start_date` timestamp NULL default NULL,
  `end_date` timestamp NULL default NULL,
  `perms` int(11) default NULL,
  `owner` bigint(20) default NULL,
  `group_id` bigint(20) default NULL,
  PRIMARY KEY  (`oid`),
  KEY `FK_t_site` (`site2account`),
  CONSTRAINT `t_site_ibfk_1` FOREIGN KEY (`site2account`) REFERENCES `t_account` (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC COMMENT='InnoDB free: 9216 kB';

/*Table structure for table `t_solution` */

DROP TABLE IF EXISTS `t_solution`;

CREATE TABLE `t_solution` (
  `oid` bigint(20) NOT NULL default '0',
  `ref` varchar(32) default NULL,
  `title` varchar(32) NOT NULL,
  `description` varchar(255) NOT NULL,
  `solution` varchar(255) NOT NULL,
  `owner` bigint(20) default NULL,
  `last_modified_by` bigint(20) default NULL,
  `timestamp` timestamp NULL default NULL,
  `creation_time` timestamp NULL default NULL,
  `status` int(11) default NULL,
  `closed_by` bigint(20) default NULL,
  `close_time` timestamp NULL default NULL,
  `creator` bigint(20) default NULL,
  PRIMARY KEY  (`oid`),
  UNIQUE KEY `oid` (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_svc_inst` */

DROP TABLE IF EXISTS `t_svc_inst`;

CREATE TABLE `t_svc_inst` (
  `oid` bigint(20) NOT NULL,
  `id` varchar(32) default NULL,
  `service_name` varchar(40) default NULL,
  `effective_date` timestamp NULL default '0000-00-00 00:00:00',
  `expire_date` timestamp NULL default '0000-00-00 00:00:00',
  `no_of_services` int(11) default NULL,
  `unit_price` double(100,3) default NULL,
  `actual_price` double(100,3) default NULL,
  `discount` double(100,3) default NULL,
  `extended_prise` double(100,3) default NULL,
  `status` int(11) default NULL,
  `svc_inst2site` bigint(20) default NULL,
  `svc_inst2service` bigint(20) default NULL,
  `last_modified` datetime default NULL,
  PRIMARY KEY  (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_tasks` */

DROP TABLE IF EXISTS `t_tasks`;

CREATE TABLE `t_tasks` (
  `oid` bigint(20) NOT NULL,
  `name` varchar(50) default NULL,
  `date_entered` datetime default NULL,
  `last_modified_by` bigint(20) default NULL,
  `created_by` bigint(20) default NULL,
  `description` text,
  `deleted` tinyint(1) default '0',
  `assigned_user_id` bigint(20) default NULL,
  `status` varchar(25) default NULL,
  `date_due_flag` tinyint(1) default '1',
  `date_due` datetime default NULL,
  `date_start_flag` tinyint(1) default '1',
  `date_start` datetime default NULL,
  `contact_id` bigint(20) default NULL,
  `priority` varchar(25) default NULL,
  `last_modified` datetime default NULL,
  `subtask2task` bigint(20) default NULL,
  PRIMARY KEY  (`oid`),
  KEY `FK_t_tasks` (`subtask2task`),
  CONSTRAINT `t_tasks_ibfk_1` FOREIGN KEY (`subtask2task`) REFERENCES `t_tasks` (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Table structure for table `t_topic` */

DROP TABLE IF EXISTS `t_topic`;

CREATE TABLE `t_topic` (
  `oid` bigint(20) NOT NULL,
  `title` varchar(60) default NULL,
  `interaction_id` bigint(20) default NULL,
  PRIMARY KEY  (`oid`),
  KEY `FK_t_topic` (`interaction_id`),
  CONSTRAINT `t_topic_ibfk_1` FOREIGN KEY (`interaction_id`) REFERENCES `t_interaction` (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;



/*Table structure for table `mtm_case_task` */

DROP TABLE IF EXISTS `mtm_case_task`;

CREATE TABLE `mtm_case_task` (
  `id` bigint(20) NOT NULL default '0',
  `role1_id` int(11) default '0',
  `role2_id` int(11) default '0',
  `id1` int(11) NOT NULL default '0',
  `id2` int(11) NOT NULL default '0',
  `rel_id` int(11) NOT NULL default '0',
  PRIMARY KEY  (`id`),
  UNIQUE KEY `id1` (`id1`,`id2`,`rel_id`),
  KEY `rol1_id` (`id`,`role1_id`),
  KEY `rol2_id` (`role2_id`,`id1`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

/*Table structure for table `mtm_contact_site` */

DROP TABLE IF EXISTS `mtm_contact_site`;

CREATE TABLE `mtm_contact_site` (
  `id` bigint(20) NOT NULL default '0',
  `role1_id` int(11) default '0',
  `role2_id` int(11) default '0',
  `id1` int(11) NOT NULL default '0',
  `id2` int(11) NOT NULL default '0',
  `rel_id` int(11) NOT NULL default '0',
  PRIMARY KEY  (`id`),
  UNIQUE KEY `id1` (`id1`,`id2`,`rel_id`),
  KEY `rol1_id` (`id`,`role1_id`),
  KEY `rol2_id` (`role2_id`,`id1`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

/*Table structure for table `mtm_dyn_1` */

DROP TABLE IF EXISTS `mtm_dyn_1`;

CREATE TABLE `mtm_dyn_1` (
  `id` bigint(20) NOT NULL default '0',
  `role1_id` int(11) default '0',
  `role2_id` int(11) default '0',
  `id1` int(11) NOT NULL,
  `id2` int(11) NOT NULL,
  `rel_id` int(11) NOT NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `id1` (`id1`,`id2`,`rel_id`),
  KEY `rol1_id` (`id`,`role1_id`),
  KEY `rol2_id` (`role2_id`,`id1`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

/*Table structure for table `mtm_empgroup_activity` */

DROP TABLE IF EXISTS `mtm_empgroup_activity`;

CREATE TABLE `mtm_empgroup_activity` (
  `id` bigint(20) NOT NULL default '0',
  `role1_id` int(11) default '0',
  `role2_id` int(11) default '0',
  `id1` int(11) NOT NULL default '0',
  `id2` int(11) NOT NULL default '0',
  `rel_id` int(11) NOT NULL default '0',
  PRIMARY KEY  (`id`),
  UNIQUE KEY `id1` (`id1`,`id2`,`rel_id`),
  KEY `rol1_id` (`id`,`role1_id`),
  KEY `rol2_id` (`role2_id`,`id1`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

/*Table structure for table `mtm_methods` */

DROP TABLE IF EXISTS `mtm_methods`;

CREATE TABLE `mtm_methods` (
  `id` bigint(20) NOT NULL default '0',
  `role1_id` int(11) default '0',
  `role2_id` int(11) default '0',
  `id1` int(11) NOT NULL default '0',
  `id2` int(11) NOT NULL default '0',
  `rel_id` int(11) NOT NULL default '0',
  PRIMARY KEY  (`id`),
  UNIQUE KEY `id1` (`id1`,`id2`,`rel_id`),
  KEY `rol1_id` (`id`,`role1_id`),
  KEY `rol2_id` (`role2_id`,`id1`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

/*Table structure for table `mtm_wfo_folder` */

DROP TABLE IF EXISTS `mtm_wfo_folder`;

CREATE TABLE `mtm_wfo_folder` (
  `id` bigint(20) NOT NULL default '0',
  `role1_id` int(11) default '0',
  `role2_id` int(11) default '0',
  `id1` bigint(20) NOT NULL default '0',
  `id2` bigint(20) NOT NULL default '0',
  `rel_id` int(11) NOT NULL default '0',
  PRIMARY KEY  (`id`),
  UNIQUE KEY `id1` (`id1`,`id2`,`rel_id`),
  KEY `rol1_id` (`id`,`role1_id`),
  KEY `rol2_id` (`role2_id`,`id1`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

/*Table structure for table `mtm_wfo_queue` */

DROP TABLE IF EXISTS `mtm_wfo_queue`;

CREATE TABLE `mtm_wfo_queue` (
  `id` bigint(20) NOT NULL default '0',
  `role1_id` int(11) default '0',
  `role2_id` int(11) default '0',
  `id1` bigint(20) NOT NULL default '0',
  `id2` bigint(20) NOT NULL default '0',
  `rel_id` int(11) NOT NULL default '0',
  PRIMARY KEY  (`id`),
  UNIQUE KEY `id1` (`id1`,`id2`,`rel_id`),
  KEY `rol1_id` (`id`,`role1_id`),
  KEY `rol2_id` (`role2_id`,`id1`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

