SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";

--
-- Table structure for table `historical_articles`
--

DROP TABLE IF EXISTS `historical_articles`;
CREATE TABLE IF NOT EXISTS `historical_articles` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `historical_offer_participant_delivery_id` int(11) NOT NULL,
  `title` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `content` text COLLATE utf8_unicode_ci,
  `article_status_id` int(11) NOT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `copyscape_count` int(11) DEFAULT '0',
  `copyscape_cost` float DEFAULT '0',
  `copyscape_cost_project` float DEFAULT '0',
  `has_copyspace_extra` tinyint(1) DEFAULT '0',
  `modify_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `historical_offer_participant_delivery_id` (`historical_offer_participant_delivery_id`),
  KEY `article_status_id` (`article_status_id`),
  KEY `historical_articles_id_idx` (`id`),
  KEY `historical_articles_create_at_idx` (`created_at`)
) ENGINE=InnoDB AUTO_INCREMENT=1610 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

--
-- Table structure for table `historical_article_comment_score`
--

DROP TABLE IF EXISTS `historical_article_comment_score`;
CREATE TABLE IF NOT EXISTS `historical_article_comment_score` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `historical_article_id` int(11) NOT NULL,
  `comment` text COLLATE utf8_unicode_ci NOT NULL,
  `score` int(11) NOT NULL,
  `score_type` int(11) NOT NULL,
  `created_at` date NOT NULL,
  `updated_at` date NOT NULL,
  `article_last_version` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `historical_article_comment_score_article_id` (`historical_article_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1225 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

--
-- Table structure for table `historical_article_notes`
--

DROP TABLE IF EXISTS `historical_article_notes`;
CREATE TABLE IF NOT EXISTS `historical_article_notes` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `note` text COLLATE utf8_unicode_ci NOT NULL,
  `historical_offer_participant_delivery_id` int(11) NOT NULL,
  `note_type` int(11) DEFAULT NULL,
  `user_type` int(11) DEFAULT NULL,
  `user_id` int(11) NOT NULL,
  `rating` int(11) NOT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `historical_offer_participant_delivery_id` (`historical_offer_participant_delivery_id`)
) ENGINE=InnoDB AUTO_INCREMENT=296 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

--
-- Table structure for table `historical_offer_deliveries`
--

DROP TABLE IF EXISTS `historical_offer_deliveries`;
CREATE TABLE IF NOT EXISTS `historical_offer_deliveries` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `historical_offer_id` int(11) NOT NULL,
  `quantity` int(11) NOT NULL,
  `end_date` date NOT NULL,
  PRIMARY KEY (`id`),
  KEY `historical_offer_id` (`historical_offer_id`)
) ENGINE=InnoDB AUTO_INCREMENT=604 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

--
-- Table structure for table `historical_offer_deliveries_offer_bills`
--

DROP TABLE IF EXISTS `historical_offer_deliveries_offer_bills`;
CREATE TABLE IF NOT EXISTS `historical_offer_deliveries_offer_bills` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `historical_offer_participant_deliveries_id` int(11) NOT NULL,
  `historical_offer_participant_bills_id` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `historical_offer_participant_deliveries_id` (`historical_offer_participant_deliveries_id`),
  KEY `historical_offer_participant_bills_id` (`historical_offer_participant_bills_id`)
) ENGINE=InnoDB AUTO_INCREMENT=457 DEFAULT CHARSET=utf8;

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

--
-- Table structure for table `historical_offer_participant_bills`
--

DROP TABLE IF EXISTS `historical_offer_participant_bills`;
CREATE TABLE IF NOT EXISTS `historical_offer_participant_bills` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `historical_offer_id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `user_notes` text COLLATE utf8_unicode_ci,
  `admin_notes` text COLLATE utf8_unicode_ci,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `status` int(11) DEFAULT NULL,
  `invoice_date` date DEFAULT NULL,
  `due_date` date DEFAULT NULL,
  `invoice_number` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `invoice_type` int(11) DEFAULT '1',
  `volume` int(11) DEFAULT '0',
  `price` decimal(15,2) DEFAULT '0.00',
  `estimated_payment_date` date DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `historical_offer_id` (`historical_offer_id`),
  KEY `user_id` (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=245 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

--
-- Table structure for table `historical_offer_participant_deliveries`
--

DROP TABLE IF EXISTS `historical_offer_participant_deliveries`;
CREATE TABLE IF NOT EXISTS `historical_offer_participant_deliveries` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `historical_offer_participant_id` int(11) NOT NULL,
  `author_id` int(11) NOT NULL,
  `end_date` date NOT NULL,
  `historical_project_id` int(11) NOT NULL,
  `historical_topic_id` int(11) DEFAULT NULL,
  `historical_offer_participant_editor_id` int(11) DEFAULT NULL,
  `editor_id` int(11) DEFAULT NULL,
  `historical_offer_participant_project_manager_id` int(11) DEFAULT NULL,
  `project_manager_id` int(11) DEFAULT NULL,
  `historical_offer_participant_reviser_id` int(11) DEFAULT NULL,
  `reviser_id` int(11) DEFAULT NULL,
  `has_invoice` tinyint(1) NOT NULL DEFAULT '0',
  `last_notification_expired` date DEFAULT NULL,
  `has_invoice_editor` tinyint(1) NOT NULL DEFAULT '0',
  `has_invoice_pm` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `historical_project_id` (`historical_project_id`),
  KEY `author_id` (`author_id`),
  KEY `historical_offer_participant_id` (`historical_offer_participant_id`),
  KEY `historical_topic_id` (`historical_topic_id`),
  KEY `historical_offer_participant_editor_id` (`historical_offer_participant_editor_id`),
  KEY `editor_id` (`editor_id`),
  KEY `historical_offer_participant_project_manager_id` (`historical_offer_participant_project_manager_id`),
  KEY `project_manager_id` (`project_manager_id`),
  KEY `historical_offer_participant_reviser_id` (`historical_offer_participant_reviser_id`),
  KEY `reviser_id` (`reviser_id`),
  KEY `historical_offer_participant_deliveries_id_idx` (`id`),
  KEY `historical_offer_participant_deliveries_end_date_idx` (`end_date`)
) ENGINE=InnoDB AUTO_INCREMENT=936 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

--
-- Table structure for table `historical_offer_participant_payments`
--

DROP TABLE IF EXISTS `historical_offer_participant_payments`;
CREATE TABLE IF NOT EXISTS `historical_offer_participant_payments` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `historical_offer_id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `project_amount` float DEFAULT '0',
  `copyscape_cost` float DEFAULT '0',
  `total_amount` float DEFAULT '0',
  `paypal_status` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `status` int(11) NOT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `paypal_payout_batch_id` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `payment_method` int(11) DEFAULT NULL,
  `transferwise_transaction_id` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`),
  KEY `historical_offer_id` (`historical_offer_id`)
) ENGINE=InnoDB AUTO_INCREMENT=44 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

--
-- Table structure for table `historcial_offer_partitipants`
--

DROP TABLE IF EXISTS `historcial_offer_partitipants`;
CREATE TABLE IF NOT EXISTS `historcial_offer_partitipants` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `historical_offer_id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `offer_status` int(11) DEFAULT NULL,
  `historical_counter_offer_id` int(11) DEFAULT NULL,
  `offer_received` date DEFAULT NULL,
  `offer_answered` date DEFAULT NULL,
  `offer_confirmed` date DEFAULT NULL,
  `project_status` int(11) DEFAULT '0',
  `copyscape_cost` float DEFAULT '0',
  `net_amount` float DEFAULT '0',
  `gross_amount` float DEFAULT '0',
  `participant_type` int(11) DEFAULT '1',
  `has_send_email` tinyint(1) DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `historical_offer_id` (`historical_offer_id`),
  KEY `user_id` (`user_id`),
  KEY `FK_historcial_offer_partitipants_counter_offer` (`historical_counter_offer_id`),
  KEY `historcial_offer_partitipants_offer_status_idx` (`offer_status`)
) ENGINE=InnoDB AUTO_INCREMENT=882 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

--
-- Table structure for table `historical_projects`
--

DROP TABLE IF EXISTS `historical_projects`;
CREATE TABLE IF NOT EXISTS `historical_projects` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `client_id` int(11) DEFAULT NULL,
  `start_date` date NOT NULL,
  `end_date` date NOT NULL,
  `total_amount` decimal(15,2) NOT NULL DEFAULT '0.00',
  `special_offer` text COLLATE utf8_unicode_ci,
  `special_invoice` text COLLATE utf8_unicode_ci,
  `discount` decimal(15,2) NOT NULL DEFAULT '0.00',
  `tax` decimal(15,2) NOT NULL DEFAULT '0.00',
  `invoice_number` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `invoice_date` date DEFAULT NULL,
  `due_date` date DEFAULT NULL,
  `notes_ht` text COLLATE utf8_unicode_ci,
  `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `paid` tinyint(1) DEFAULT '0',
  `paid_date` date DEFAULT NULL,
  `status` int(11) DEFAULT '0',
  `copyscape_enabled` tinyint(1) DEFAULT '1',
  `project_manager_price` decimal(15,2) DEFAULT NULL,
  `project_manager_gross_amount` decimal(15,2) DEFAULT NULL,
  `user_id` int(11) DEFAULT NULL,
  `type_project` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `invoice_number` (`invoice_number`),
  KEY `client_id` (`client_id`),
  KEY `user_id` (`user_id`),
  KEY `historical_projects_name_idx` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=397 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

--
-- Table structure for table `historical_project_additional_costs`
--

DROP TABLE IF EXISTS `historical_project_additional_costs`;
CREATE TABLE IF NOT EXISTS `historical_project_additional_costs` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `historical_project_id` int(11) NOT NULL,
  `concept` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `amount` float NOT NULL,
  `date` date NOT NULL,
  `created_at` date NOT NULL,
  `updated_at` date NOT NULL,
  PRIMARY KEY (`id`),
  KEY `historical_project_id` (`historical_project_id`)
) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

--
-- Table structure for table `historical_project_attachments`
--

DROP TABLE IF EXISTS `historical_project_attachments`;
CREATE TABLE IF NOT EXISTS `historical_project_attachments` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `historical_project_id` int(11) NOT NULL,
  `type` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
  `file_src` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `file_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`id`),
  KEY `historical_project_id` (`historical_project_id`)
) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

--
-- Table structure for table `historical_project_categories`
--

DROP TABLE IF EXISTS `historical_project_categories`;
CREATE TABLE IF NOT EXISTS `historical_project_categories` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `historical_project_id` int(11) DEFAULT NULL,
  `position` int(11) NOT NULL,
  `introduction` text COLLATE utf8_unicode_ci NOT NULL,
  `description` text COLLATE utf8_unicode_ci NOT NULL,
  `category_type_id` int(11) DEFAULT NULL,
  `volume` int(11) DEFAULT NULL,
  `price` decimal(15,2) NOT NULL DEFAULT '0.00',
  `gross_amount` decimal(15,2) NOT NULL DEFAULT '0.00',
  PRIMARY KEY (`id`),
  KEY `historical_project_id` (`historical_project_id`),
  KEY `category_type_id` (`category_type_id`)
) ENGINE=InnoDB AUTO_INCREMENT=414 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

--
-- Table structure for table `historical_project_counter_offers`
--

DROP TABLE IF EXISTS `historical_project_counter_offers`;
CREATE TABLE IF NOT EXISTS `historical_project_counter_offers` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) DEFAULT NULL,
  `volume` int(11) NOT NULL,
  `length` int(11) NOT NULL,
  `category_type_id` int(11) DEFAULT NULL,
  `price` decimal(15,2) NOT NULL DEFAULT '0.00',
  `gross_amount` decimal(15,2) NOT NULL DEFAULT '0.00',
  `notes` text COLLATE utf8_unicode_ci,
  `historical_offer_partitipant_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`),
  KEY `category_type_id` (`category_type_id`),
  KEY `historical_offer_partitipant_id` (`historical_offer_partitipant_id`)
) ENGINE=InnoDB AUTO_INCREMENT=108 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

--
-- Table structure for table `historical_project_financial_statements`
--

DROP TABLE IF EXISTS `historical_project_financial_statements`;
CREATE TABLE IF NOT EXISTS `historical_project_financial_statements` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `historical_project_id` int(11) NOT NULL,
  `contact_person` varchar(255) COLLATE utf8_unicode_ci DEFAULT '',
  `date` datetime NOT NULL,
  `customer_potential` varchar(255) COLLATE utf8_unicode_ci DEFAULT '',
  `text_type` varchar(255) COLLATE utf8_unicode_ci DEFAULT '',
  `language_id` int(11) NOT NULL,
  `end_date` datetime NOT NULL,
  `number_of_texts` int(11) DEFAULT '0',
  `words_per_text` int(11) DEFAULT '0',
  `price_per_word` float DEFAULT '0',
  `price_per_text` float DEFAULT '0',
  `other_features` float DEFAULT '0',
  `discount` float DEFAULT '0',
  `text_revenue` float DEFAULT '0',
  `net_revenue` float DEFAULT '0',
  `vat` float DEFAULT '0',
  `revenue_incl_tax` float DEFAULT '0',
  `price_per_word_per_author` float DEFAULT '0',
  `price_per_text_per_author` float DEFAULT '0',
  `price_per_word_per_editor` float DEFAULT '0',
  `price_per_text_per_editor` float DEFAULT '0',
  `price_per_text_copyscape` float DEFAULT '0',
  `price_per_text_overall` float DEFAULT '0',
  `total_costs` float DEFAULT '0',
  `margin_text` float DEFAULT '0',
  `margin_text_percent` float DEFAULT '0',
  `overall_margin` float DEFAULT '0',
  `pm_percent` float DEFAULT '0',
  `pm_costs_in_eur` float DEFAULT '0',
  `status` float DEFAULT '0',
  `sales_provisions` float DEFAULT '0',
  `overall_benefit_incl_costs` float DEFAULT '0',
  `overall_margin_incl_costs` float DEFAULT '0',
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `price_per_word_per_translator` float DEFAULT NULL,
  `price_per_text_per_translator` float DEFAULT NULL,
  `text_length` int(11) DEFAULT NULL,
  `historical_offer_partitipant_id` int(11) DEFAULT NULL,
  `client_id` int(11) DEFAULT NULL,
  `editor_id` int(11) DEFAULT NULL,
  `author_id` int(11) DEFAULT NULL,
  `error_message` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `validation_status` int(11) DEFAULT '0',
  `historical_offer_participant_delivery_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `historical_project_id` (`historical_project_id`),
  KEY `historical_offer_partitipant_id` (`historical_offer_partitipant_id`),
  KEY `client_id` (`client_id`),
  KEY `editor_id` (`editor_id`),
  KEY `author_id` (`author_id`),
  KEY `historical_offer_participant_delivery_id` (`historical_offer_participant_delivery_id`)
) ENGINE=InnoDB AUTO_INCREMENT=88 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

--
-- Table structure for table `historical_project_offers`
--

DROP TABLE IF EXISTS `historical_project_offers`;
CREATE TABLE IF NOT EXISTS `historical_project_offers` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `historical_project_id` int(11) NOT NULL,
  `position` int(11) NOT NULL,
  `offer_code` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
  `offer_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `role_id` int(11) NOT NULL,
  `volume` int(11) NOT NULL,
  `length` int(11) NOT NULL,
  `category_type_id` int(11) NOT NULL,
  `price` decimal(15,2) NOT NULL DEFAULT '0.00',
  `gross_amount` decimal(15,2) NOT NULL DEFAULT '0.00',
  `language_id` int(11) DEFAULT NULL,
  `description` text COLLATE utf8_unicode_ci,
  `documents_provided` text COLLATE utf8_unicode_ci,
  `html_check` smallint(6) NOT NULL DEFAULT '0',
  `seo_check` smallint(6) NOT NULL DEFAULT '0',
  `images_check` smallint(6) NOT NULL DEFAULT '0',
  `delivery_format` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `notes` text COLLATE utf8_unicode_ci,
  `message` text COLLATE utf8_unicode_ci,
  `project_manager_price` decimal(15,2) DEFAULT NULL,
  `project_manager_gross_amount` decimal(15,2) DEFAULT NULL,
  `editor_price` decimal(15,2) DEFAULT NULL,
  `editor_gross_amount` decimal(15,2) DEFAULT NULL,
  `reviser_price` decimal(15,2) DEFAULT NULL,
  `reviser_gross_amount` decimal(15,2) DEFAULT NULL,
  `revisers_message` text COLLATE utf8_unicode_ci,
  `editors_message` text COLLATE utf8_unicode_ci,
  `pms_message` text COLLATE utf8_unicode_ci,
  PRIMARY KEY (`id`),
  KEY `historical_project_id` (`historical_project_id`),
  KEY `role_id` (`role_id`),
  KEY `category_type_id` (`category_type_id`),
  KEY `language_id` (`language_id`)
) ENGINE=InnoDB AUTO_INCREMENT=384 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

--
-- Table structure for table `historical_topics`
--

DROP TABLE IF EXISTS `historical_topics`;
CREATE TABLE IF NOT EXISTS `historical_topics` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `url` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `comment` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `historical_project_id` int(11) DEFAULT NULL,
  `article_number` int(11) DEFAULT NULL,
  `article_code` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `topics` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `main_keywords` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `secondary_keywords` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `extra_info` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `author_id` int(11) DEFAULT NULL,
  `author_deadline` date DEFAULT NULL,
  `editor_id` int(11) DEFAULT NULL,
  `editor_deadline` date DEFAULT NULL,
  `pm_id` int(11) DEFAULT NULL,
  `pm_deadline` date DEFAULT NULL,
  `ready_to_assign` tinyint(1) DEFAULT '0',
  `historical_offer_participant_delivery_id` int(11) DEFAULT NULL,
  `confirmed` tinyint(1) DEFAULT '0',
  `notes` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `status` int(11) DEFAULT '0',
  `error_message` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `reviser_id` int(11) DEFAULT NULL,
  `reviser_deadline` date DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `historical_project_id` (`historical_project_id`),
  KEY `author_id` (`author_id`),
  KEY `editor_id` (`editor_id`),
  KEY `topcis_author_deadline_idx` (`author_deadline`),
  KEY `topcis_editor_deadline_idx` (`editor_deadline`),
  KEY `topcis_pm_deadline_idx` (`pm_deadline`),
  KEY `topcis_reviser_deadline_idx` (`reviser_deadline`),
  KEY `topcis_reviser_id_idx` (`reviser_id`),
  KEY `topcis_historical_topics_idx` (`topics`),
  KEY `topcis_article_number_idx` (`article_number`),
  KEY `topcis_article_code_idx` (`article_code`)
) ENGINE=InnoDB AUTO_INCREMENT=1667 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `historical_articles`
--
ALTER TABLE `historical_articles`
  ADD CONSTRAINT `FK_article_status` FOREIGN KEY (`article_status_id`) REFERENCES `article_statuses` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_historical_offer_participant_delivery` FOREIGN KEY (`historical_offer_participant_delivery_id`) REFERENCES `historical_offer_participant_deliveries` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `historical_article_comment_score`
--
ALTER TABLE `historical_article_comment_score`
  ADD CONSTRAINT `FK_historical_article_comment_score_article` FOREIGN KEY (`historical_article_id`) REFERENCES `historical_articles` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `historical_article_notes`
--
ALTER TABLE `historical_article_notes`
  ADD CONSTRAINT `FK_historical_offer_participant_delivery_id` FOREIGN KEY (`historical_offer_participant_delivery_id`) REFERENCES `historical_offer_participant_deliveries` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `historical_offer_deliveries`
--
ALTER TABLE `historical_offer_deliveries`
  ADD CONSTRAINT `FK_historical_offer_deliveries` FOREIGN KEY (`historical_offer_id`) REFERENCES `historical_project_offers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `historical_offer_deliveries_offer_bills`
--
ALTER TABLE `historical_offer_deliveries_offer_bills`
  ADD CONSTRAINT `FK_historical_offer_deliveries_offer_bills_participant_bills_id` FOREIGN KEY (`historical_offer_participant_bills_id`) REFERENCES `historical_offer_participant_bills` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_historical_offer_deliveries_offer_bills_participant_deliveries_id` FOREIGN KEY (`historical_offer_participant_deliveries_id`) REFERENCES `historical_offer_participant_deliveries` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `historical_offer_participant_bills`
--
ALTER TABLE `historical_offer_participant_bills`
  ADD CONSTRAINT `FK_historical_offer_participant_bill_offer_id` FOREIGN KEY (`historical_offer_id`) REFERENCES `historical_project_offers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_offer_participant_bill_user_id` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `historical_offer_participant_deliveries`
--
ALTER TABLE `historical_offer_participant_deliveries`
  ADD CONSTRAINT `FK_author` FOREIGN KEY (`author_id`) REFERENCES `authors` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_editor_id` FOREIGN KEY (`editor_id`) REFERENCES `editors` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_historical_offer_participant` FOREIGN KEY (`historical_offer_participant_id`) REFERENCES `historcial_offer_partitipants` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_historical_offer_participant_deliveries_topic_id` FOREIGN KEY (`historical_topic_id`) REFERENCES `historical_topics` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_offer_participant_editor_id` FOREIGN KEY (`historical_offer_participant_editor_id`) REFERENCES `historcial_offer_partitipants` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_offer_participant_project_manager_id` FOREIGN KEY (`historical_offer_participant_project_manager_id`) REFERENCES `historcial_offer_partitipants` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_offer_participant_reviser_id` FOREIGN KEY (`historical_offer_participant_reviser_id`) REFERENCES `historcial_offer_partitipants` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_project` FOREIGN KEY (`historical_project_id`) REFERENCES `historical_project_offers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_project_manager_id` FOREIGN KEY (`project_manager_id`) REFERENCES `editors` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_reviser_id` FOREIGN KEY (`reviser_id`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `historical_offer_participant_payments`
--
ALTER TABLE `historical_offer_participant_payments`
  ADD CONSTRAINT `FK_offer_participant_user_id` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `historcial_offer_partitipants`
--
ALTER TABLE `historcial_offer_partitipants`
  ADD CONSTRAINT `FK_historical_offer` FOREIGN KEY (`historical_offer_id`) REFERENCES `historical_project_offers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_historcial_offer_partitipants_counter_offer` FOREIGN KEY (`historical_counter_offer_id`) REFERENCES `historical_project_counter_offers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_user_offer` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `historical_projects`
--
ALTER TABLE `historical_projects`
  ADD CONSTRAINT `FK_project_client` FOREIGN KEY (`client_id`) REFERENCES `clients` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_user_id` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `historical_project_additional_costs`
--
ALTER TABLE `historical_project_additional_costs`
  ADD CONSTRAINT `FK_historical_project_additional_costs_project_id` FOREIGN KEY (`historical_project_id`) REFERENCES `historical_projects` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `historical_project_attachments`
--
ALTER TABLE `historical_project_attachments`
  ADD CONSTRAINT `FK_historical_project_attachment` FOREIGN KEY (`historical_project_id`) REFERENCES `historical_projects` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `historical_project_categories`
--
ALTER TABLE `historical_project_categories`
  ADD CONSTRAINT `FK_historical_category_project` FOREIGN KEY (`historical_project_id`) REFERENCES `historical_projects` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_category_type` FOREIGN KEY (`category_type_id`) REFERENCES `project_cat_types` (`id`) ON DELETE SET NULL ON UPDATE CASCADE;

--
-- Constraints for table `historical_project_counter_offers`
--
ALTER TABLE `historical_project_counter_offers`
  ADD CONSTRAINT `FK_counter_offer_category_types` FOREIGN KEY (`category_type_id`) REFERENCES `project_cat_types` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_historical_counter_offer_offer_partitipan` FOREIGN KEY (`historical_offer_partitipant_id`) REFERENCES `historcial_offer_partitipants` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_user` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE;

--
-- Constraints for table `historical_project_financial_statements`
--
ALTER TABLE `historical_project_financial_statements`
  ADD CONSTRAINT `FK_historical_offer_participant_deliveries_id` FOREIGN KEY (`historical_offer_participant_delivery_id`) REFERENCES `historical_offer_participant_deliveries` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_historical_projects_financial_statements_author_id` FOREIGN KEY (`author_id`) REFERENCES `authors` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_historical_projects_financial_statements_client_id` FOREIGN KEY (`client_id`) REFERENCES `clients` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_historical_projects_financial_statements_editor_id` FOREIGN KEY (`editor_id`) REFERENCES `editors` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_historical_projects_financial_statements_offer_partitipant_id` FOREIGN KEY (`historical_offer_partitipant_id`) REFERENCES `historcial_offer_partitipants` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_historical_projects_financial_statements_project_id` FOREIGN KEY (`historical_project_id`) REFERENCES `historical_projects` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `historical_project_offers`
--
ALTER TABLE `historical_project_offers`
  ADD CONSTRAINT `FK_offer_cat_type` FOREIGN KEY (`category_type_id`) REFERENCES `project_cat_types` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_offer_lang` FOREIGN KEY (`language_id`) REFERENCES `languages` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_offer_role` FOREIGN KEY (`role_id`) REFERENCES `offer_roles` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_historical_project_offer` FOREIGN KEY (`historical_project_id`) REFERENCES `historical_projects` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `historical_topics`
--
ALTER TABLE `historical_topics`
  ADD CONSTRAINT `FK_historical_topics_author_id` FOREIGN KEY (`author_id`) REFERENCES `authors` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_historical_topics_editor_id` FOREIGN KEY (`editor_id`) REFERENCES `editors` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_historical_topics_project_id` FOREIGN KEY (`historical_project_id`) REFERENCES `historical_projects` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
