/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `account_balances`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `account_balances` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `account_id` bigint unsigned NOT NULL,
  `currency_code` varchar(3) COLLATE utf8mb4_unicode_ci NOT NULL,
  `total_debit` decimal(18,4) NOT NULL DEFAULT '0.0000',
  `total_credit` decimal(18,4) NOT NULL DEFAULT '0.0000',
  `net` decimal(18,4) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `account_balances_account_id_currency_code_unique` (`account_id`,`currency_code`),
  KEY `account_balances_company_id_foreign` (`company_id`),
  KEY `account_balances_currency_code_foreign` (`currency_code`),
  CONSTRAINT `account_balances_account_id_foreign` FOREIGN KEY (`account_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `account_balances_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `account_balances_currency_code_foreign` FOREIGN KEY (`currency_code`) REFERENCES `currencies` (`code`) ON DELETE RESTRICT ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `account_statements`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `account_statements` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `contractor_id` bigint unsigned NOT NULL,
  `invoice_number` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `transaction_date` date NOT NULL,
  `debit` decimal(10,2) NOT NULL DEFAULT '0.00',
  `credit` decimal(10,2) NOT NULL DEFAULT '0.00',
  `balance` decimal(10,2) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `account_statements_contractor_id_foreign` (`contractor_id`),
  CONSTRAINT `account_statements_contractor_id_foreign` FOREIGN KEY (`contractor_id`) REFERENCES `contractors` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `accounting_transactions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `accounting_transactions` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `account_id` bigint unsigned NOT NULL,
  `old_debit` double NOT NULL,
  `old_credit` double NOT NULL,
  `debit` double NOT NULL,
  `credit` double NOT NULL,
  `net` double NOT NULL,
  `date` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `itemable_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `itemable_id` bigint unsigned NOT NULL,
  `cost_center_id` bigint unsigned DEFAULT NULL,
  `account_code` varchar(40) COLLATE utf8mb4_unicode_ci NOT NULL,
  `notes` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `item_debit` double NOT NULL DEFAULT '0',
  `item_credit` double NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'approved',
  `exchange_rate` decimal(10,4) NOT NULL DEFAULT '1.0000',
  `currency_code` varchar(3) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `current_step` json DEFAULT NULL,
  `approved_by` json DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `accounting_transactions_company_id_foreign` (`company_id`),
  KEY `accounting_transactions_account_id_foreign` (`account_id`),
  KEY `accounting_transactions_itemable_type_itemable_id_index` (`itemable_type`,`itemable_id`),
  KEY `accounting_transactions_cost_center_id_foreign` (`cost_center_id`),
  KEY `accounting_transactions_currency_code_foreign` (`currency_code`),
  CONSTRAINT `accounting_transactions_account_id_foreign` FOREIGN KEY (`account_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `accounting_transactions_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `accounting_transactions_cost_center_id_foreign` FOREIGN KEY (`cost_center_id`) REFERENCES `cost_centers` (`id`) ON DELETE SET NULL,
  CONSTRAINT `accounting_transactions_currency_code_foreign` FOREIGN KEY (`currency_code`) REFERENCES `currencies` (`code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `activity_log`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `activity_log` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `log_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `description` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `subject_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `event` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `subject_id` bigint unsigned DEFAULT NULL,
  `causer_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `causer_id` bigint unsigned DEFAULT NULL,
  `properties` json DEFAULT NULL,
  `batch_uuid` char(36) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `subject` (`subject_type`,`subject_id`),
  KEY `causer` (`causer_type`,`causer_id`),
  KEY `activity_log_log_name_index` (`log_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `ads`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `ads` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `title` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `ads_company_id_foreign` (`company_id`),
  CONSTRAINT `ads_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `advances`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `advances` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `reason` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `amount` decimal(10,2) NOT NULL,
  `expected_delivery_date` date NOT NULL,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `item_phase_id` bigint unsigned DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `user_id` bigint unsigned NOT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  `project_id` bigint unsigned DEFAULT NULL,
  `currency_code` varchar(3) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `exchange_rate` double NOT NULL,
  PRIMARY KEY (`id`),
  KEY `advances_item_phase_id_foreign` (`item_phase_id`),
  KEY `advances_user_id_foreign` (`user_id`),
  KEY `advances_company_id_foreign` (`company_id`),
  KEY `advances_project_id_foreign` (`project_id`),
  KEY `advances_currency_code_foreign` (`currency_code`),
  CONSTRAINT `advances_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `advances_currency_code_foreign` FOREIGN KEY (`currency_code`) REFERENCES `currencies` (`code`),
  CONSTRAINT `advances_item_phase_id_foreign` FOREIGN KEY (`item_phase_id`) REFERENCES `item_phases` (`id`) ON DELETE SET NULL,
  CONSTRAINT `advances_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `advances_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `alternative_client_order`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `alternative_client_order` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `order_id` bigint unsigned NOT NULL,
  `client_id` bigint unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `alternative_client_order_company_id_order_id_index` (`company_id`,`order_id`),
  KEY `alternative_client_order_company_id_client_id_index` (`company_id`,`client_id`),
  KEY `alternative_client_order_order_id_index` (`order_id`),
  KEY `alternative_client_order_client_id_index` (`client_id`),
  CONSTRAINT `alternative_client_order_client_id_foreign` FOREIGN KEY (`client_id`) REFERENCES `sales_clients` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `alternative_client_order_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `alternative_client_order_order_id_foreign` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `approval_settings`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `approval_settings` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `department` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `requires_approval` tinyint(1) NOT NULL DEFAULT '0',
  `approval_path` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `approvers` json NOT NULL,
  `max_response_time` int DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `response_time_unit` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'hours',
  `company_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `approval_settings_company_id_foreign` (`company_id`),
  CONSTRAINT `approval_settings_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `arrest_paper_purchase`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `arrest_paper_purchase` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `arrest_paper_id` bigint unsigned NOT NULL,
  `invoice_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `arrest_paper_purchase_arrest_paper_id_foreign` (`arrest_paper_id`),
  KEY `arrest_paper_purchase_invoice_id_foreign` (`invoice_id`),
  CONSTRAINT `arrest_paper_purchase_arrest_paper_id_foreign` FOREIGN KEY (`arrest_paper_id`) REFERENCES `arrest_papers` (`id`) ON DELETE CASCADE,
  CONSTRAINT `arrest_paper_purchase_invoice_id_foreign` FOREIGN KEY (`invoice_id`) REFERENCES `sales_invoices` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `arrest_papers`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `arrest_papers` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `account_id` bigint unsigned NOT NULL,
  `user_id` bigint unsigned NOT NULL,
  `by_user_id` bigint unsigned DEFAULT NULL,
  `date` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `due_date` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `amount` double NOT NULL,
  `description` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `currency_code` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `exchange_rate` double NOT NULL DEFAULT '1',
  `payable_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `payable_id` bigint unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `client_id` bigint unsigned DEFAULT NULL,
  `payment_method` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `arrest_papers_company_id_foreign` (`company_id`),
  KEY `arrest_papers_account_id_foreign` (`account_id`),
  KEY `arrest_papers_user_id_foreign` (`user_id`),
  KEY `arrest_papers_by_user_id_foreign` (`by_user_id`),
  KEY `arrest_papers_payable_type_payable_id_index` (`payable_type`,`payable_id`),
  KEY `arrest_papers_client_id_foreign` (`client_id`),
  CONSTRAINT `arrest_papers_account_id_foreign` FOREIGN KEY (`account_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `arrest_papers_by_user_id_foreign` FOREIGN KEY (`by_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `arrest_papers_client_id_foreign` FOREIGN KEY (`client_id`) REFERENCES `sales_clients` (`id`) ON DELETE SET NULL,
  CONSTRAINT `arrest_papers_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `arrest_papers_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `assets`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `assets` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `account_id` bigint unsigned NOT NULL,
  `cash_account_id` bigint unsigned NOT NULL,
  `journal_account_id` bigint unsigned NOT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `title` json NOT NULL,
  `purchasing_date` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `cost` double NOT NULL,
  `currency_code` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `salvage_value` double DEFAULT NULL,
  `service_date` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `place` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `useful_life` double DEFAULT NULL,
  `quantity` double DEFAULT NULL,
  `asset_user_id` bigint unsigned DEFAULT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `description` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `deprecation_method` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `deprecation_months` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `deprecation_month_cost` double DEFAULT NULL,
  `deprecation_end_date` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `assets_company_id_foreign` (`company_id`),
  KEY `assets_account_id_foreign` (`account_id`),
  KEY `assets_cash_account_id_foreign` (`cash_account_id`),
  KEY `assets_journal_account_id_foreign` (`journal_account_id`),
  KEY `assets_asset_user_id_foreign` (`asset_user_id`),
  KEY `assets_user_id_foreign` (`user_id`),
  CONSTRAINT `assets_account_id_foreign` FOREIGN KEY (`account_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `assets_asset_user_id_foreign` FOREIGN KEY (`asset_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `assets_cash_account_id_foreign` FOREIGN KEY (`cash_account_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `assets_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `assets_journal_account_id_foreign` FOREIGN KEY (`journal_account_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `assets_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `attendances`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `attendances` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint unsigned NOT NULL,
  `creator_id` bigint unsigned DEFAULT NULL,
  `date` date NOT NULL,
  `check_in` time DEFAULT NULL,
  `check_out` time DEFAULT NULL,
  `shift_id` bigint unsigned DEFAULT NULL,
  `reward_and_penalty_id` bigint unsigned DEFAULT NULL,
  `is_from_workplace` tinyint(1) NOT NULL DEFAULT '1',
  `latitude` decimal(10,6) DEFAULT NULL,
  `longitude` decimal(10,6) DEFAULT NULL,
  `expected_work_seconds` int unsigned NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `attendances_user_id_foreign` (`user_id`),
  KEY `attendances_creator_id_foreign` (`creator_id`),
  KEY `attendances_shift_id_foreign` (`shift_id`),
  KEY `attendances_reward_and_penalty_id_foreign` (`reward_and_penalty_id`),
  KEY `attendances_company_id_foreign` (`company_id`),
  CONSTRAINT `attendances_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `attendances_creator_id_foreign` FOREIGN KEY (`creator_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `attendances_reward_and_penalty_id_foreign` FOREIGN KEY (`reward_and_penalty_id`) REFERENCES `rewards_and_penalties` (`id`) ON DELETE SET NULL,
  CONSTRAINT `attendances_shift_id_foreign` FOREIGN KEY (`shift_id`) REFERENCES `shifts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `attendances_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `audit_checklist_items`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `audit_checklist_items` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `checklist_id` bigint unsigned NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `required` tinyint(1) NOT NULL DEFAULT '1',
  `verified` tinyint(1) NOT NULL DEFAULT '0',
  `note` text COLLATE utf8mb4_unicode_ci,
  `verified_by` bigint unsigned DEFAULT NULL,
  `verified_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `audit_checklist_items_checklist_id_foreign` (`checklist_id`),
  KEY `audit_checklist_items_verified_by_foreign` (`verified_by`),
  CONSTRAINT `audit_checklist_items_checklist_id_foreign` FOREIGN KEY (`checklist_id`) REFERENCES `audit_checklists` (`id`) ON DELETE CASCADE,
  CONSTRAINT `audit_checklist_items_verified_by_foreign` FOREIGN KEY (`verified_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `audit_checklists`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `audit_checklists` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `is_template` tinyint(1) NOT NULL DEFAULT '0',
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'active',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `entity_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `automation_rules`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `automation_rules` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `automatable_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `automatable_id` bigint unsigned DEFAULT NULL,
  `trigger_status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `conditions` json DEFAULT NULL,
  `actions` json NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `automation_rules_automatable_type_automatable_id_index` (`automatable_type`,`automatable_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `backups`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `backups` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned DEFAULT NULL,
  `file_path` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `file_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `backup_date` timestamp NOT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'completed',
  `notes` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `backups_company_id_foreign` (`company_id`),
  KEY `backups_user_id_foreign` (`user_id`),
  CONSTRAINT `backups_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `backups_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `bank_accounts`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `bank_accounts` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `bank_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `branch` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `account_number` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `iban` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `type` enum('current','saving') COLLATE utf8mb4_unicode_ci NOT NULL,
  `active` tinyint(1) NOT NULL DEFAULT '1',
  `company_id` bigint unsigned DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `account_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `balance` decimal(15,2) NOT NULL DEFAULT '0.00',
  `min_balance` decimal(15,2) NOT NULL DEFAULT '0.00',
  PRIMARY KEY (`id`),
  KEY `bank_accounts_account_id_foreign` (`account_id`),
  KEY `bank_accounts_bank_name_index` (`bank_name`),
  KEY `bank_accounts_account_number_index` (`account_number`),
  KEY `bank_accounts_company_id_index` (`company_id`),
  KEY `bank_accounts_active_index` (`active`),
  CONSTRAINT `bank_accounts_account_id_foreign` FOREIGN KEY (`account_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `bank_accounts_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `bank_cheques`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `bank_cheques` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `account_id` bigint unsigned NOT NULL,
  `user_id` bigint unsigned NOT NULL,
  `by_user_id` bigint unsigned DEFAULT NULL,
  `to_account_id` bigint unsigned DEFAULT NULL,
  `type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `date` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `due_date` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `amount` double NOT NULL,
  `currency_code` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `exchange_rate` double NOT NULL DEFAULT '1',
  `description` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `payable_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `payable_id` bigint unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `bank_account_id` bigint unsigned DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `reason` text COLLATE utf8mb4_unicode_ci,
  PRIMARY KEY (`id`),
  KEY `bank_cheques_payable_type_payable_id_index` (`payable_type`,`payable_id`),
  KEY `bank_cheques_company_id_index` (`company_id`),
  KEY `bank_cheques_account_id_index` (`account_id`),
  KEY `bank_cheques_user_id_index` (`user_id`),
  KEY `bank_cheques_by_user_id_index` (`by_user_id`),
  KEY `bank_cheques_to_account_id_index` (`to_account_id`),
  KEY `bank_cheques_type_index` (`type`),
  KEY `bank_cheques_number_index` (`number`),
  KEY `bank_cheques_date_index` (`date`),
  KEY `bank_cheques_due_date_index` (`due_date`),
  KEY `bank_cheques_currency_code_index` (`currency_code`),
  KEY `bank_cheques_amount_index` (`amount`),
  KEY `bank_cheques_company_id_date_index` (`company_id`,`date`),
  KEY `bank_cheques_account_id_date_index` (`account_id`,`date`),
  KEY `bank_cheques_company_id_type_date_index` (`company_id`,`type`,`date`),
  KEY `bank_cheques_payable_id_index` (`payable_id`),
  KEY `bank_cheques_payable_type_index` (`payable_type`),
  KEY `bank_cheques_bank_account_id_foreign` (`bank_account_id`),
  CONSTRAINT `bank_cheques_account_id_foreign` FOREIGN KEY (`account_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `bank_cheques_bank_account_id_foreign` FOREIGN KEY (`bank_account_id`) REFERENCES `bank_accounts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `bank_cheques_by_user_id_foreign` FOREIGN KEY (`by_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `bank_cheques_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `bank_cheques_to_account_id_foreign` FOREIGN KEY (`to_account_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `bank_cheques_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `break_times`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `break_times` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `shift_time_id` bigint unsigned DEFAULT NULL,
  `max_break_minutes` int DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `break_times_shift_time_id_foreign` (`shift_time_id`),
  CONSTRAINT `break_times_shift_time_id_foreign` FOREIGN KEY (`shift_time_id`) REFERENCES `shift_times` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `business_rules`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `business_rules` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `model_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `event` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `conditions` json NOT NULL,
  `actions` json NOT NULL,
  `company_id` bigint unsigned NOT NULL,
  `status` tinyint(1) NOT NULL DEFAULT '1',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `business_rules_company_id_foreign` (`company_id`),
  CONSTRAINT `business_rules_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `cache`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `cache` (
  `key` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `value` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL,
  `expiration` int NOT NULL,
  PRIMARY KEY (`key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `cache_locks`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `cache_locks` (
  `key` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `owner` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `expiration` int NOT NULL,
  PRIMARY KEY (`key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `cash_journal_transactions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `cash_journal_transactions` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `journal_id` bigint unsigned NOT NULL,
  `account_id` bigint unsigned DEFAULT NULL,
  `cost_center_id` bigint unsigned DEFAULT NULL,
  `debits` double NOT NULL,
  `credits` double NOT NULL,
  `notes` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `base_debits` double NOT NULL DEFAULT '0',
  `base_credits` double NOT NULL DEFAULT '0',
  `currency_code` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `display_currency_code` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `exchange_rate` double NOT NULL DEFAULT '1',
  PRIMARY KEY (`id`),
  KEY `cash_journal_transactions_account_id_index` (`account_id`),
  KEY `cash_journal_transactions_journal_id_index` (`journal_id`),
  KEY `cash_journal_transactions_cost_center_id_index` (`cost_center_id`),
  KEY `cash_journal_transactions_currency_code_index` (`currency_code`),
  KEY `cash_journal_transactions_display_currency_code_index` (`display_currency_code`),
  CONSTRAINT `cash_journal_transactions_account_id_foreign` FOREIGN KEY (`account_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `cash_journal_transactions_cost_center_id_foreign` FOREIGN KEY (`cost_center_id`) REFERENCES `cost_centers` (`id`) ON DELETE SET NULL,
  CONSTRAINT `cash_journal_transactions_journal_id_foreign` FOREIGN KEY (`journal_id`) REFERENCES `cash_journals` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `cash_journals`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `cash_journals` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `user_id` bigint unsigned NOT NULL,
  `cash_account_id` bigint unsigned NOT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `date` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `notes` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `credit` double NOT NULL DEFAULT '0',
  `debit` double NOT NULL DEFAULT '0',
  `net` double NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `cash_journals_company_id_index` (`company_id`),
  KEY `cash_journals_user_id_index` (`user_id`),
  KEY `cash_journals_cash_account_id_index` (`cash_account_id`),
  KEY `cash_journals_code_index` (`code`),
  KEY `cash_journals_date_index` (`date`),
  CONSTRAINT `cash_journals_cash_account_id_foreign` FOREIGN KEY (`cash_account_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `cash_journals_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `cash_journals_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `categories`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `categories` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `parent_category_id` bigint unsigned DEFAULT NULL,
  `title` json NOT NULL,
  `description` json DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `section` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT 'accounting',
  `product_guide_id` bigint unsigned DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `categories_company_id_foreign` (`company_id`),
  KEY `categories_user_id_foreign` (`user_id`),
  KEY `categories_parent_category_id_foreign` (`parent_category_id`),
  KEY `categories_product_guide_id_foreign` (`product_guide_id`),
  CONSTRAINT `categories_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `categories_parent_category_id_foreign` FOREIGN KEY (`parent_category_id`) REFERENCES `categories` (`id`) ON DELETE SET NULL,
  CONSTRAINT `categories_product_guide_id_foreign` FOREIGN KEY (`product_guide_id`) REFERENCES `product_guides` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
  CONSTRAINT `categories_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `category_plans`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `category_plans` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `project_id` bigint unsigned NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `category_plans_project_id_unique` (`project_id`),
  KEY `category_plans_company_id_foreign` (`company_id`),
  CONSTRAINT `category_plans_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `category_plans_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `main_projects` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `change_requests`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `change_requests` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `project_id` bigint unsigned NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `reason` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `project_phase_id` bigint unsigned DEFAULT NULL,
  `requesting_party` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `reviewers` json DEFAULT NULL,
  `change_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `creation_date` date DEFAULT NULL,
  `items` json DEFAULT NULL,
  `priority` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  `cost_impact` json DEFAULT NULL,
  `schedule_impact` json DEFAULT NULL,
  `execution_location` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `change_order_number` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `request_submission_date` date DEFAULT NULL,
  `request_reasons` text COLLATE utf8mb4_unicode_ci,
  `applicant_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `company_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `contact_phone` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `change_requests_project_id_foreign` (`project_id`),
  KEY `change_requests_project_phase_id_foreign` (`project_phase_id`),
  KEY `change_requests_company_id_foreign` (`company_id`),
  CONSTRAINT `change_requests_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `change_requests_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `change_requests_project_phase_id_foreign` FOREIGN KEY (`project_phase_id`) REFERENCES `project_phases` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `chart_of_accounts`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `chart_of_accounts` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `parent_account_id` bigint unsigned DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `title` json NOT NULL,
  `total_credit` double NOT NULL DEFAULT '0',
  `total_debit` double NOT NULL DEFAULT '0',
  `net` double NOT NULL DEFAULT '0',
  `account_type` tinyint(1) NOT NULL DEFAULT '0',
  `entity_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `model` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` tinyint(1) NOT NULL DEFAULT '1',
  `is_main_account` tinyint(1) NOT NULL DEFAULT '0',
  `level` int NOT NULL DEFAULT '1',
  `item_credit` double NOT NULL DEFAULT '0',
  `item_debit` double NOT NULL DEFAULT '0',
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `imported_code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `closing_account` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `chart_of_accounts_company_id_foreign` (`company_id`),
  KEY `chart_of_accounts_user_id_foreign` (`user_id`),
  KEY `chart_of_accounts_parent_account_id_foreign` (`parent_account_id`),
  CONSTRAINT `chart_of_accounts_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `chart_of_accounts_parent_account_id_foreign` FOREIGN KEY (`parent_account_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `chart_of_accounts_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `checklist_items`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `checklist_items` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `main_task_id` bigint unsigned NOT NULL,
  `title` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `stage` enum('TODO','Skipped','In Progress','Done') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'TODO',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `checklist_items_main_task_id_foreign` (`main_task_id`),
  CONSTRAINT `checklist_items_main_task_id_foreign` FOREIGN KEY (`main_task_id`) REFERENCES `main_tasks` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `client_companies`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `client_companies` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `contact_person` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `contact_phone` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `address` text COLLATE utf8mb4_unicode_ci,
  `client_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `client_companies_client_id_foreign` (`client_id`),
  KEY `client_companies_company_id_foreign` (`company_id`),
  CONSTRAINT `client_companies_client_id_foreign` FOREIGN KEY (`client_id`) REFERENCES `sales_clients` (`id`) ON DELETE SET NULL,
  CONSTRAINT `client_companies_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `client_contracts`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `client_contracts` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `client_id` bigint unsigned NOT NULL,
  `contract_number` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `contract_value` decimal(15,2) NOT NULL,
  `payment_method` enum('cash','installments','deferred') COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `guarantees` text COLLATE utf8mb4_unicode_ci,
  `penalty_terms` text COLLATE utf8mb4_unicode_ci,
  `insurance_details` text COLLATE utf8mb4_unicode_ci,
  `start_date` date NOT NULL,
  `end_date` date DEFAULT NULL,
  `execution_period` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` enum('draft','active','completed','cancelled') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'draft',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `client_contracts_contract_number_unique` (`contract_number`),
  KEY `client_contracts_client_id_foreign` (`client_id`),
  CONSTRAINT `client_contracts_client_id_foreign` FOREIGN KEY (`client_id`) REFERENCES `sales_clients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `client_price_logs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `client_price_logs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `client_id` bigint unsigned DEFAULT NULL,
  `product_id` bigint unsigned NOT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `price` double NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `old_price` double NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `client_price_logs_client_id_foreign` (`client_id`),
  KEY `client_price_logs_product_id_foreign` (`product_id`),
  KEY `client_price_logs_user_id_foreign` (`user_id`),
  KEY `client_price_logs_company_id_client_id_index` (`company_id`,`client_id`),
  KEY `client_price_logs_company_id_product_id_index` (`company_id`,`product_id`),
  CONSTRAINT `client_price_logs_client_id_foreign` FOREIGN KEY (`client_id`) REFERENCES `sales_clients` (`id`) ON DELETE SET NULL,
  CONSTRAINT `client_price_logs_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `client_price_logs_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `sales_products` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `client_price_logs_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `client_products`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `client_products` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `unit_id` bigint unsigned NOT NULL,
  `product_id` bigint unsigned NOT NULL,
  `client_id` bigint unsigned DEFAULT NULL,
  `price` double NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `client_products_unit_id_foreign` (`unit_id`),
  KEY `client_products_product_id_foreign` (`product_id`),
  KEY `client_products_client_id_foreign` (`client_id`),
  KEY `client_products_company_id_client_id_index` (`company_id`,`client_id`),
  KEY `client_products_company_id_product_id_index` (`company_id`,`product_id`),
  CONSTRAINT `client_products_client_id_foreign` FOREIGN KEY (`client_id`) REFERENCES `sales_clients` (`id`) ON DELETE SET NULL,
  CONSTRAINT `client_products_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `client_products_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `sales_products` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `client_products_unit_id_foreign` FOREIGN KEY (`unit_id`) REFERENCES `measurement_units` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `client_responsable`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `client_responsable` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `client_id` bigint unsigned NOT NULL,
  `first_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `last_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `phone` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
  `position` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `client_responsable_client_id_foreign` (`client_id`),
  CONSTRAINT `client_responsable_client_id_foreign` FOREIGN KEY (`client_id`) REFERENCES `sales_clients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `comments`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `comments` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint unsigned DEFAULT NULL,
  `main_task_id` bigint unsigned NOT NULL,
  `content` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `comments_user_id_foreign` (`user_id`),
  KEY `comments_main_task_id_foreign` (`main_task_id`),
  CONSTRAINT `comments_main_task_id_foreign` FOREIGN KEY (`main_task_id`) REFERENCES `main_tasks` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `comments_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `companies`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `companies` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `slug` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `address` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `phone` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `currency` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `decimal_places` int NOT NULL DEFAULT '2',
  `tax_id` bigint unsigned DEFAULT NULL,
  `active_tax` tinyint(1) NOT NULL DEFAULT '0',
  `visual_identity_color` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `phase` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'completed',
  PRIMARY KEY (`id`),
  UNIQUE KEY `companies_code_unique` (`code`),
  KEY `companies_name_index` (`name`),
  KEY `companies_slug_index` (`slug`),
  KEY `companies_code_index` (`code`),
  KEY `companies_email_index` (`email`),
  KEY `companies_phone_index` (`phone`),
  KEY `companies_name_code_index` (`name`,`code`),
  KEY `companies_tax_id_foreign` (`tax_id`),
  CONSTRAINT `companies_tax_id_foreign` FOREIGN KEY (`tax_id`) REFERENCES `taxes` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `company_currency_rates`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `company_currency_rates` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `currency_code` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `rate` decimal(15,6) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `company_currency_rates_company_id_currency_code_unique` (`company_id`,`currency_code`),
  KEY `company_currency_rates_currency_code_foreign` (`currency_code`),
  CONSTRAINT `company_currency_rates_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `company_currency_rates_currency_code_foreign` FOREIGN KEY (`currency_code`) REFERENCES `currencies` (`code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `company_settings`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `company_settings` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `additional_settings` json DEFAULT NULL,
  `company_id` bigint unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `company_settings_company_id_foreign` (`company_id`),
  CONSTRAINT `company_settings_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `completed_works`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `completed_works` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `daily_record_id` bigint unsigned NOT NULL,
  `item_phase_id` bigint unsigned NOT NULL,
  `quantity` decimal(10,2) NOT NULL,
  `details` text COLLATE utf8mb4_unicode_ci,
  `sub_tasks` json DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'draft',
  `approved_by` bigint unsigned DEFAULT NULL,
  `approval_date` timestamp NULL DEFAULT NULL,
  `unit_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `completed_works_daily_record_id_foreign` (`daily_record_id`),
  KEY `completed_works_item_phase_id_foreign` (`item_phase_id`),
  KEY `completed_works_approved_by_foreign` (`approved_by`),
  KEY `completed_works_unit_id_foreign` (`unit_id`),
  CONSTRAINT `completed_works_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
  CONSTRAINT `completed_works_daily_record_id_foreign` FOREIGN KEY (`daily_record_id`) REFERENCES `daily_records` (`id`) ON DELETE CASCADE,
  CONSTRAINT `completed_works_item_phase_id_foreign` FOREIGN KEY (`item_phase_id`) REFERENCES `item_phases` (`id`) ON DELETE CASCADE,
  CONSTRAINT `completed_works_unit_id_foreign` FOREIGN KEY (`unit_id`) REFERENCES `measurement_units` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `consultant_notes`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `consultant_notes` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `daily_record_id` bigint unsigned NOT NULL,
  `consultant_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `text` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `date` date NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'draft',
  `approved_by` bigint unsigned DEFAULT NULL,
  `approval_date` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `consultant_notes_daily_record_id_foreign` (`daily_record_id`),
  KEY `consultant_notes_approved_by_foreign` (`approved_by`),
  CONSTRAINT `consultant_notes_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
  CONSTRAINT `consultant_notes_daily_record_id_foreign` FOREIGN KEY (`daily_record_id`) REFERENCES `daily_records` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `contacts`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `contacts` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `first_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `second_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `phone` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `company_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `city` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `region` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `street_address` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `importance` enum('High','Medium','Low') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Medium',
  `job_title` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `last_outcome` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `next_step` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` tinyint(1) NOT NULL DEFAULT '0',
  `user_id` bigint unsigned DEFAULT NULL,
  `customer_rating_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `phone_status` enum('empty','not_reached','off','answered','pending','wrong_number','changed_mind','interested') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'empty',
  `section_state_id` bigint unsigned DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `product_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `contacts_customer_rating_id_foreign` (`customer_rating_id`),
  KEY `contacts_email_index` (`email`),
  KEY `contacts_phone_index` (`phone`),
  KEY `contacts_company_name_index` (`company_name`),
  KEY `contacts_importance_status_index` (`importance`,`status`),
  KEY `contacts_user_id_index` (`user_id`),
  KEY `contacts_section_state_id_foreign` (`section_state_id`),
  KEY `contacts_company_id_foreign` (`company_id`),
  KEY `contacts_product_id_foreign` (`product_id`),
  CONSTRAINT `contacts_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `contacts_customer_rating_id_foreign` FOREIGN KEY (`customer_rating_id`) REFERENCES `customer_ratings` (`id`) ON DELETE RESTRICT,
  CONSTRAINT `contacts_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `sales_products` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `contacts_section_state_id_foreign` FOREIGN KEY (`section_state_id`) REFERENCES `section_states` (`id`) ON DELETE RESTRICT,
  CONSTRAINT `contacts_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `contract_parties`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `contract_parties` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `partyable_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `partyable_id` bigint unsigned NOT NULL,
  `full_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `identity_number` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `role` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `email` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `whatsapp_number` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `party_position` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `pin` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `contract_parties_pin_unique` (`pin`),
  KEY `contract_parties_partyable_type_partyable_id_index` (`partyable_type`,`partyable_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `contract_payment_terms`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `contract_payment_terms` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `contract_id` bigint unsigned NOT NULL,
  `term_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `percentage` double NOT NULL,
  `due_date` date NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `contract_payment_terms_contract_id_foreign` (`contract_id`),
  CONSTRAINT `contract_payment_terms_contract_id_foreign` FOREIGN KEY (`contract_id`) REFERENCES `contracts` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `contract_work_items`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `contract_work_items` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `contract_id` bigint unsigned NOT NULL,
  `item_phases_id` bigint unsigned DEFAULT NULL,
  `unit` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `unit_price` double DEFAULT NULL,
  `quantity` int DEFAULT NULL,
  `total_value` double DEFAULT NULL,
  `expected_days` int DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `tax_percentage` decimal(5,2) DEFAULT NULL,
  `discount_percentage` decimal(5,2) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `contract_work_items_contract_id_foreign` (`contract_id`),
  KEY `contract_work_items_item_phases_id_foreign` (`item_phases_id`),
  CONSTRAINT `contract_work_items_contract_id_foreign` FOREIGN KEY (`contract_id`) REFERENCES `contracts` (`id`) ON DELETE CASCADE,
  CONSTRAINT `contract_work_items_item_phases_id_foreign` FOREIGN KEY (`item_phases_id`) REFERENCES `item_phases` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `contractor_types`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `contractor_types` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `title` json NOT NULL,
  `status` tinyint(1) NOT NULL DEFAULT '1',
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `contractors`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `contractors` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `contractor_type_id` bigint unsigned DEFAULT NULL,
  `field_id` bigint unsigned DEFAULT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `phone` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `address` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `responsible_person` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `contract_start_date` date DEFAULT NULL,
  `number_of_employees` int DEFAULT NULL,
  `agreed_costs` double DEFAULT NULL,
  `expected_implementation_duration` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `payment_terms` json DEFAULT NULL,
  `status` tinyint(1) NOT NULL DEFAULT '1',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `account_id` bigint unsigned DEFAULT NULL,
  `entity_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `trade_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `balance` double NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `contractors_field_id_foreign` (`field_id`),
  KEY `contractors_name_index` (`name`),
  KEY `contractors_phone_index` (`phone`),
  KEY `contractors_email_index` (`email`),
  KEY `contractors_status_index` (`status`),
  KEY `contractors_contractor_type_id_field_id_index` (`contractor_type_id`,`field_id`),
  KEY `contractors_company_id_foreign` (`company_id`),
  KEY `contractors_user_id_foreign` (`user_id`),
  KEY `contractors_account_id_foreign` (`account_id`),
  CONSTRAINT `contractors_account_id_foreign` FOREIGN KEY (`account_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `contractors_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `contractors_contractor_type_id_foreign` FOREIGN KEY (`contractor_type_id`) REFERENCES `contractor_types` (`id`) ON DELETE SET NULL,
  CONSTRAINT `contractors_field_id_foreign` FOREIGN KEY (`field_id`) REFERENCES `fields` (`id`) ON DELETE SET NULL,
  CONSTRAINT `contractors_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `contracts`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `contracts` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `client_id` bigint unsigned DEFAULT NULL,
  `contractor_id` bigint unsigned DEFAULT NULL,
  `contract_number` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `contract_value` double NOT NULL,
  `contract_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `contract_payment_terms` json DEFAULT NULL,
  `warranty_percentage` double DEFAULT NULL,
  `vat_percentage` double DEFAULT NULL,
  `penalty_per_day` double DEFAULT NULL,
  `start_date` date NOT NULL,
  `end_date` date DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'draft',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `project_id` bigint unsigned DEFAULT NULL,
  `payment_due_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'immediate',
  `payment_schedule` json DEFAULT NULL,
  `signing_date` date DEFAULT NULL,
  `preamble` text COLLATE utf8mb4_unicode_ci,
  `terms_and_conditions` text COLLATE utf8mb4_unicode_ci,
  `payment_due_days` int DEFAULT NULL,
  `max_penalty` decimal(15,2) DEFAULT NULL,
  `warranty_period` int DEFAULT NULL,
  `warranty_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `change_request_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `contracts_contract_number_unique` (`contract_number`),
  KEY `contracts_client_id_foreign` (`client_id`),
  KEY `contracts_contractor_id_foreign` (`contractor_id`),
  KEY `contracts_project_id_foreign` (`project_id`),
  KEY `contracts_change_request_id_foreign` (`change_request_id`),
  CONSTRAINT `contracts_change_request_id_foreign` FOREIGN KEY (`change_request_id`) REFERENCES `change_requests` (`id`) ON DELETE CASCADE,
  CONSTRAINT `contracts_client_id_foreign` FOREIGN KEY (`client_id`) REFERENCES `sales_clients` (`id`) ON DELETE SET NULL,
  CONSTRAINT `contracts_contractor_id_foreign` FOREIGN KEY (`contractor_id`) REFERENCES `contractors` (`id`) ON DELETE CASCADE,
  CONSTRAINT `contracts_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `cost_centers`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `cost_centers` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `user_id` bigint unsigned NOT NULL,
  `parent_id` bigint unsigned DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `title` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `is_main` tinyint(1) NOT NULL DEFAULT '0',
  `status` tinyint(1) NOT NULL DEFAULT '0',
  `notes` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `account_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `cost_centers_company_id_foreign` (`company_id`),
  KEY `cost_centers_user_id_foreign` (`user_id`),
  KEY `cost_centers_parent_id_foreign` (`parent_id`),
  KEY `cost_centers_account_id_foreign` (`account_id`),
  CONSTRAINT `cost_centers_account_id_foreign` FOREIGN KEY (`account_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `cost_centers_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `cost_centers_parent_id_foreign` FOREIGN KEY (`parent_id`) REFERENCES `cost_centers` (`id`) ON DELETE SET NULL,
  CONSTRAINT `cost_centers_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `cost_estimates`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `cost_estimates` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `project_id` bigint unsigned DEFAULT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `creation_date` date DEFAULT NULL,
  `pricing_structure` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `estimate_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'architectural',
  `total_cost` double DEFAULT NULL,
  `tax_total` double DEFAULT NULL,
  `profit_total` double DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `currency_code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `exchange_rate` double NOT NULL DEFAULT '1',
  PRIMARY KEY (`id`),
  KEY `cost_estimates_project_id_foreign` (`project_id`),
  KEY `cost_estimates_company_id_foreign` (`company_id`),
  CONSTRAINT `cost_estimates_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE,
  CONSTRAINT `cost_estimates_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `cost_pools`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `cost_pools` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `project_id` bigint unsigned DEFAULT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `budget` decimal(15,2) NOT NULL,
  `cost_center_id` bigint unsigned DEFAULT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `cost_pools_project_id_foreign` (`project_id`),
  KEY `cost_pools_cost_center_id_foreign` (`cost_center_id`),
  CONSTRAINT `cost_pools_cost_center_id_foreign` FOREIGN KEY (`cost_center_id`) REFERENCES `cost_centers` (`id`) ON DELETE SET NULL,
  CONSTRAINT `cost_pools_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `currencies`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `currencies` (
  `code` varchar(3) COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `rate` decimal(15,4) NOT NULL,
  PRIMARY KEY (`code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `customer_ratings`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `customer_ratings` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `title` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `color` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `customer_ratings_company_id_foreign` (`company_id`),
  CONSTRAINT `customer_ratings_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `daily_records`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `daily_records` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint unsigned DEFAULT NULL,
  `record_date` date NOT NULL DEFAULT '2025-06-30',
  `description` text COLLATE utf8mb4_unicode_ci,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'draft',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `project_id` bigint unsigned DEFAULT NULL,
  `report_date` date DEFAULT NULL,
  `location` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `approved_by` bigint unsigned DEFAULT NULL,
  `approval_date` date DEFAULT NULL,
  `esignature_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `daily_records_user_id_foreign` (`user_id`),
  KEY `daily_records_project_id_foreign` (`project_id`),
  KEY `daily_records_created_by_foreign` (`created_by`),
  KEY `daily_records_approved_by_foreign` (`approved_by`),
  KEY `daily_records_esignature_id_foreign` (`esignature_id`),
  CONSTRAINT `daily_records_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `daily_records_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `daily_records_esignature_id_foreign` FOREIGN KEY (`esignature_id`) REFERENCES `e_signatures` (`id`) ON DELETE SET NULL,
  CONSTRAINT `daily_records_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE,
  CONSTRAINT `daily_records_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `delays`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `delays` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `daily_record_id` bigint unsigned NOT NULL,
  `item_phase_id` bigint unsigned NOT NULL,
  `duration` double NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `date` date DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'draft',
  `approved_by` bigint unsigned DEFAULT NULL,
  `approval_date` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `delays_daily_record_id_foreign` (`daily_record_id`),
  KEY `delays_item_phase_id_foreign` (`item_phase_id`),
  KEY `delays_approved_by_foreign` (`approved_by`),
  CONSTRAINT `delays_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
  CONSTRAINT `delays_daily_record_id_foreign` FOREIGN KEY (`daily_record_id`) REFERENCES `daily_records` (`id`) ON DELETE CASCADE,
  CONSTRAINT `delays_item_phase_id_foreign` FOREIGN KEY (`item_phase_id`) REFERENCES `item_phases` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `depreciation_pools`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `depreciation_pools` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `fixed_asset_id` bigint unsigned DEFAULT NULL,
  `account_id` bigint unsigned DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `currency_code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `exchange_rate` double NOT NULL DEFAULT '1',
  `fixed_asset_account_ids` json DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `depreciation_pools_fixed_asset_id_foreign` (`fixed_asset_id`),
  KEY `depreciation_pools_company_id_foreign` (`company_id`),
  KEY `depreciation_pools_account_id_index` (`account_id`),
  CONSTRAINT `depreciation_pools_account_id_foreign` FOREIGN KEY (`account_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `depreciation_pools_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `depreciation_pools_fixed_asset_id_foreign` FOREIGN KEY (`fixed_asset_id`) REFERENCES `fixed_assets` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `document_templates`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `document_templates` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `items` json DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `created_by` bigint unsigned DEFAULT NULL,
  `date_created` date DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `document_templates_company_id_foreign` (`company_id`),
  KEY `document_templates_created_by_foreign` (`created_by`),
  CONSTRAINT `document_templates_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `document_templates_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `driver_supplier`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `driver_supplier` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `driver_id` bigint unsigned NOT NULL,
  `supplier_id` bigint unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `driver_supplier_driver_id_supplier_id_unique` (`driver_id`,`supplier_id`),
  KEY `driver_supplier_supplier_id_foreign` (`supplier_id`),
  CONSTRAINT `driver_supplier_driver_id_foreign` FOREIGN KEY (`driver_id`) REFERENCES `drivers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `driver_supplier_supplier_id_foreign` FOREIGN KEY (`supplier_id`) REFERENCES `sales_suppliers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `drivers`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `drivers` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `account_id` bigint unsigned DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `slug` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `phone` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `password` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `vehicle_number` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `vehicle_size` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` tinyint(1) NOT NULL DEFAULT '1',
  `main_driver_id` bigint unsigned DEFAULT NULL,
  `address` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `type` enum('has_group','main') COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `device_token` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `drivers_phone_unique` (`phone`),
  UNIQUE KEY `drivers_email_unique` (`email`),
  KEY `drivers_user_id_foreign` (`user_id`),
  KEY `drivers_account_id_foreign` (`account_id`),
  KEY `drivers_main_driver_id_foreign` (`main_driver_id`),
  KEY `drivers_company_id_created_at_index` (`company_id`,`created_at`),
  KEY `drivers_company_id_status_index` (`company_id`,`status`),
  KEY `drivers_company_id_type_index` (`company_id`,`type`),
  KEY `drivers_company_id_name_index` (`company_id`,`name`),
  KEY `drivers_company_id_vehicle_number_index` (`company_id`,`vehicle_number`),
  KEY `drivers_created_at_index` (`created_at`),
  KEY `drivers_company_id_code_index` (`company_id`,`code`),
  KEY `drivers_company_id_index` (`company_id`),
  KEY `drivers_company_id_deleted_at_index` (`company_id`,`deleted_at`),
  CONSTRAINT `drivers_account_id_foreign` FOREIGN KEY (`account_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `drivers_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `drivers_main_driver_id_foreign` FOREIGN KEY (`main_driver_id`) REFERENCES `drivers` (`id`) ON DELETE SET NULL,
  CONSTRAINT `drivers_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `e_signature_models`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `e_signature_models` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `e_signature_id` bigint unsigned NOT NULL,
  `signable_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `signable_id` bigint unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `e_signature_model_unique` (`e_signature_id`,`signable_id`,`signable_type`),
  KEY `e_signature_models_signable_type_signable_id_index` (`signable_type`,`signable_id`),
  CONSTRAINT `e_signature_models_e_signature_id_foreign` FOREIGN KEY (`e_signature_id`) REFERENCES `e_signatures` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `e_signatures`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `e_signatures` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `location` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `department` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `reason` text COLLATE utf8mb4_unicode_ci,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `signed_at` timestamp NULL DEFAULT NULL,
  `signer_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `e_signatures_signer_id_foreign` (`signer_id`),
  KEY `e_signatures_company_id_foreign` (`company_id`),
  CONSTRAINT `e_signatures_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `e_signatures_signer_id_foreign` FOREIGN KEY (`signer_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `employee_breaks`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `employee_breaks` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint unsigned NOT NULL,
  `creator_id` bigint unsigned DEFAULT NULL,
  `attendance_id` bigint unsigned NOT NULL,
  `start_time` time NOT NULL,
  `end_time` time DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `employee_breaks_user_id_foreign` (`user_id`),
  KEY `employee_breaks_creator_id_foreign` (`creator_id`),
  KEY `employee_breaks_attendance_id_foreign` (`attendance_id`),
  KEY `employee_breaks_company_id_foreign` (`company_id`),
  CONSTRAINT `employee_breaks_attendance_id_foreign` FOREIGN KEY (`attendance_id`) REFERENCES `attendances` (`id`) ON DELETE CASCADE,
  CONSTRAINT `employee_breaks_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `employee_breaks_creator_id_foreign` FOREIGN KEY (`creator_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `employee_breaks_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `equipment`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `equipment` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `title` json NOT NULL,
  `description` json NOT NULL,
  `equipment_type_id` bigint unsigned DEFAULT NULL,
  `available_quantity` int NOT NULL DEFAULT '1',
  `rental_price` double DEFAULT NULL,
  `duration_of_use` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `latest_maintenance` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `productivity_rate` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `store_id` bigint unsigned DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  `equipment_asset` enum('fixed','supplier') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'fixed',
  `equipment_status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'available',
  `type` enum('purchase','rent') COLLATE utf8mb4_unicode_ci NOT NULL,
  `measurement_unit_id` bigint unsigned DEFAULT NULL,
  `currency_code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `exchange_rate` double NOT NULL DEFAULT '1',
  `fixed_asset_account_id` bigint unsigned DEFAULT NULL,
  `asset_tag` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `fuel_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `maintenance_schedule` json DEFAULT NULL,
  `purchase_date` date DEFAULT NULL,
  `purchase_cost` decimal(15,2) DEFAULT NULL,
  `depreciation_method` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `productive_life` int DEFAULT NULL,
  `annual_depreciation` decimal(15,2) DEFAULT NULL,
  `current_book_value` decimal(15,2) DEFAULT NULL,
  `rental_rate` decimal(15,2) DEFAULT NULL,
  `rental_period_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `rental_contract_duration` int DEFAULT NULL,
  `rental_start_date` date DEFAULT NULL,
  `rental_end_date` date DEFAULT NULL,
  `renewal_status` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `last_maintenance_date` date DEFAULT NULL,
  `next_maintenance_date` date DEFAULT NULL,
  `brand` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `model` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `manufacturing_details` text COLLATE utf8mb4_unicode_ci,
  `license_plate_number` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `serial_number` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `usage_date` date DEFAULT NULL,
  `material_category_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `equipment_equipment_type_id_index` (`equipment_type_id`),
  KEY `equipment_available_quantity_index` (`available_quantity`),
  KEY `equipment_store_id_foreign` (`store_id`),
  KEY `equipment_company_id_foreign` (`company_id`),
  KEY `equipment_measurement_unit_id_foreign` (`measurement_unit_id`),
  KEY `equipment_fixed_asset_account_id_foreign` (`fixed_asset_account_id`),
  KEY `equipment_material_category_id_foreign` (`material_category_id`),
  CONSTRAINT `equipment_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `equipment_equipment_type_id_foreign` FOREIGN KEY (`equipment_type_id`) REFERENCES `equipment_types` (`id`) ON DELETE SET NULL,
  CONSTRAINT `equipment_fixed_asset_account_id_foreign` FOREIGN KEY (`fixed_asset_account_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE CASCADE,
  CONSTRAINT `equipment_material_category_id_foreign` FOREIGN KEY (`material_category_id`) REFERENCES `material_categories` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `equipment_measurement_unit_id_foreign` FOREIGN KEY (`measurement_unit_id`) REFERENCES `measurement_units` (`id`) ON DELETE CASCADE,
  CONSTRAINT `equipment_store_id_foreign` FOREIGN KEY (`store_id`) REFERENCES `main_inventories` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `equipment_project_usage`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `equipment_project_usage` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `equipment_id` bigint unsigned DEFAULT NULL,
  `project_id` bigint unsigned DEFAULT NULL,
  `usage_days` int DEFAULT NULL,
  `total_cost` double DEFAULT NULL,
  `start_date` date DEFAULT NULL,
  `end_date` date DEFAULT NULL,
  `rental_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `supplier_id` bigint unsigned DEFAULT NULL,
  `item_phase_id` bigint unsigned DEFAULT NULL,
  `hours` int DEFAULT NULL,
  `rental_rate` decimal(15,2) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `equipment_project_usage_equipment_id_foreign` (`equipment_id`),
  KEY `equipment_project_usage_project_id_foreign` (`project_id`),
  KEY `equipment_project_usage_supplier_id_foreign` (`supplier_id`),
  KEY `equipment_project_usage_item_phase_id_foreign` (`item_phase_id`),
  CONSTRAINT `equipment_project_usage_equipment_id_foreign` FOREIGN KEY (`equipment_id`) REFERENCES `equipment` (`id`) ON DELETE CASCADE,
  CONSTRAINT `equipment_project_usage_item_phase_id_foreign` FOREIGN KEY (`item_phase_id`) REFERENCES `item_phases` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `equipment_project_usage_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE,
  CONSTRAINT `equipment_project_usage_supplier_id_foreign` FOREIGN KEY (`supplier_id`) REFERENCES `suppliers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `equipment_supplier`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `equipment_supplier` (
  `equipment_id` bigint unsigned NOT NULL,
  `supplier_id` bigint unsigned NOT NULL,
  KEY `equipment_supplier_equipment_id_foreign` (`equipment_id`),
  KEY `equipment_supplier_supplier_id_foreign` (`supplier_id`),
  CONSTRAINT `equipment_supplier_equipment_id_foreign` FOREIGN KEY (`equipment_id`) REFERENCES `equipment` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `equipment_supplier_supplier_id_foreign` FOREIGN KEY (`supplier_id`) REFERENCES `suppliers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `equipment_types`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `equipment_types` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `title` json NOT NULL,
  `status` tinyint(1) NOT NULL DEFAULT '1',
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `equipment_usage`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `equipment_usage` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `daily_record_id` bigint unsigned NOT NULL,
  `equipment_id` bigint unsigned NOT NULL,
  `completed_quantity` decimal(10,2) NOT NULL,
  `operating_hours` decimal(10,2) NOT NULL,
  `cost` decimal(12,2) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'draft',
  `approved_by` bigint unsigned DEFAULT NULL,
  `approval_date` timestamp NULL DEFAULT NULL,
  `item_phase_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `equipment_usage_daily_record_id_foreign` (`daily_record_id`),
  KEY `equipment_usage_equipment_id_foreign` (`equipment_id`),
  KEY `equipment_usage_approved_by_foreign` (`approved_by`),
  KEY `equipment_usage_item_phase_id_foreign` (`item_phase_id`),
  CONSTRAINT `equipment_usage_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
  CONSTRAINT `equipment_usage_daily_record_id_foreign` FOREIGN KEY (`daily_record_id`) REFERENCES `daily_records` (`id`) ON DELETE CASCADE,
  CONSTRAINT `equipment_usage_equipment_id_foreign` FOREIGN KEY (`equipment_id`) REFERENCES `equipment` (`id`) ON DELETE CASCADE,
  CONSTRAINT `equipment_usage_item_phase_id_foreign` FOREIGN KEY (`item_phase_id`) REFERENCES `item_phases` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `error_log_exceptions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `error_log_exceptions` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `model_id` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `model_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `url` longtext COLLATE utf8mb4_unicode_ci,
  `url_request` longtext COLLATE utf8mb4_unicode_ci,
  `exception_message` longtext COLLATE utf8mb4_unicode_ci,
  `exception_file` longtext COLLATE utf8mb4_unicode_ci,
  `exception_code` longtext COLLATE utf8mb4_unicode_ci,
  `exception_line` longtext COLLATE utf8mb4_unicode_ci,
  `exception_trace` longtext COLLATE utf8mb4_unicode_ci,
  `exception_previous` longtext COLLATE utf8mb4_unicode_ci,
  `exception_trace_as_string` longtext COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `events`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `events` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `main_event_id` bigint NOT NULL,
  `user_id` bigint DEFAULT NULL,
  `platform` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `date` datetime NOT NULL,
  `duration` int NOT NULL,
  `time_zone` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `event_link` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `meeting` json DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `events_company_id_foreign` (`company_id`),
  CONSTRAINT `events_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `expenses`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `expenses` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `contractor_id` bigint unsigned DEFAULT NULL,
  `project_id` bigint unsigned DEFAULT NULL,
  `task_phase_id` bigint unsigned DEFAULT NULL,
  `expense_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `category` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `total_amount` decimal(10,2) NOT NULL,
  `expense_date` date NOT NULL,
  `supplier_id` bigint unsigned DEFAULT NULL,
  `payment_method` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `unit_price` decimal(10,2) DEFAULT NULL,
  `quantity` int DEFAULT NULL,
  `currency_code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `exchange_rate` double NOT NULL DEFAULT '1',
  `company_id` bigint unsigned DEFAULT NULL,
  `project_phase_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `expenses_task_phase_id_foreign` (`task_phase_id`),
  KEY `expenses_supplier_id_foreign` (`supplier_id`),
  KEY `expenses_expense_type_index` (`expense_type`),
  KEY `expenses_category_index` (`category`),
  KEY `expenses_expense_date_index` (`expense_date`),
  KEY `expenses_project_id_expense_date_index` (`project_id`,`expense_date`),
  KEY `expenses_contractor_id_project_id_index` (`contractor_id`,`project_id`),
  KEY `expenses_company_id_foreign` (`company_id`),
  KEY `expenses_project_phase_id_foreign` (`project_phase_id`),
  CONSTRAINT `expenses_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `expenses_contractor_id_foreign` FOREIGN KEY (`contractor_id`) REFERENCES `contractors` (`id`) ON DELETE SET NULL,
  CONSTRAINT `expenses_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE,
  CONSTRAINT `expenses_project_phase_id_foreign` FOREIGN KEY (`project_phase_id`) REFERENCES `project_phases` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `expenses_supplier_id_foreign` FOREIGN KEY (`supplier_id`) REFERENCES `suppliers` (`id`) ON DELETE SET NULL,
  CONSTRAINT `expenses_task_phase_id_foreign` FOREIGN KEY (`task_phase_id`) REFERENCES `task_phases` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `external_labor_contracts`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `external_labor_contracts` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `external_labor_id` bigint unsigned NOT NULL,
  `project_id` bigint unsigned DEFAULT NULL,
  `start_date` date NOT NULL,
  `expected_end_date` date DEFAULT NULL,
  `work_description` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `payment_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `hourly_rate` decimal(10,2) DEFAULT NULL,
  `daily_rate` decimal(10,2) DEFAULT NULL,
  `items` json DEFAULT NULL,
  `total_cost` decimal(10,2) DEFAULT NULL,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'active',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `external_labor_contracts_external_labor_id_foreign` (`external_labor_id`),
  KEY `external_labor_contracts_project_id_foreign` (`project_id`),
  CONSTRAINT `external_labor_contracts_external_labor_id_foreign` FOREIGN KEY (`external_labor_id`) REFERENCES `external_labors` (`id`) ON DELETE CASCADE,
  CONSTRAINT `external_labor_contracts_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `external_labor_item_phases`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `external_labor_item_phases` (
  `external_labor_id` bigint unsigned NOT NULL,
  `item_phase_id` bigint unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`external_labor_id`,`item_phase_id`),
  KEY `external_labor_item_phases_item_phase_id_foreign` (`item_phase_id`),
  CONSTRAINT `external_labor_item_phases_external_labor_id_foreign` FOREIGN KEY (`external_labor_id`) REFERENCES `external_labors` (`id`) ON DELETE CASCADE,
  CONSTRAINT `external_labor_item_phases_item_phase_id_foreign` FOREIGN KEY (`item_phase_id`) REFERENCES `item_phases` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `external_labors`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `external_labors` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `nationality` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `identity_number` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `full_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `phone_number` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `job_title` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `project_id` bigint unsigned DEFAULT NULL,
  `items` json DEFAULT NULL,
  `payment_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `payment_amount` decimal(10,2) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `worked_days` int DEFAULT NULL,
  `bonus_amount` decimal(10,2) DEFAULT NULL,
  `deduction_amount` decimal(10,2) DEFAULT NULL,
  `final_salary` decimal(10,2) DEFAULT NULL,
  `is_paid` tinyint(1) NOT NULL DEFAULT '0',
  `exchange_rate` decimal(10,4) NOT NULL DEFAULT '1.0000',
  `currency_code` varchar(3) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  `transfer_fee` decimal(10,2) NOT NULL DEFAULT '0.00',
  `notes` text COLLATE utf8mb4_unicode_ci,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `external_labors_identity_number_unique` (`identity_number`),
  UNIQUE KEY `external_labors_phone_number_unique` (`phone_number`),
  KEY `external_labors_project_id_foreign` (`project_id`),
  KEY `external_labors_currency_code_foreign` (`currency_code`),
  KEY `external_labors_company_id_foreign` (`company_id`),
  CONSTRAINT `external_labors_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `external_labors_currency_code_foreign` FOREIGN KEY (`currency_code`) REFERENCES `currencies` (`code`),
  CONSTRAINT `external_labors_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `failed_jobs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `failed_jobs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `uuid` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `connection` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `queue` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `payload` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
  `exception` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
  `failed_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `failed_jobs_uuid_unique` (`uuid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `fields`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `fields` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `title` json NOT NULL,
  `status` tinyint(1) NOT NULL DEFAULT '1',
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `finance_categories`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `finance_categories` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `type` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `status` tinyint(1) NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `finance_categories_company_id_foreign` (`company_id`),
  KEY `finance_categories_user_id_foreign` (`user_id`),
  CONSTRAINT `finance_categories_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `finance_categories_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `finance_expenses`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `finance_expenses` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `user_id` bigint unsigned NOT NULL,
  `type` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Expense',
  `code` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `amount` double NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `date` date DEFAULT NULL,
  `treasury_id` bigint unsigned NOT NULL,
  `supplier_id` bigint unsigned DEFAULT NULL,
  `seller_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `currency_code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `exchange_rate` double NOT NULL DEFAULT '1',
  `category_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `finance_expenses_category_id_foreign` (`category_id`),
  CONSTRAINT `finance_expenses_category_id_foreign` FOREIGN KEY (`category_id`) REFERENCES `finance_categories` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `finance_expenses_transactions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `finance_expenses_transactions` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `expense_id` bigint unsigned NOT NULL,
  `account_id` bigint unsigned NOT NULL,
  `cost_center_id` bigint unsigned DEFAULT NULL,
  `amount` decimal(8,2) NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `tax` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0',
  `tax_value` decimal(8,2) NOT NULL DEFAULT '0.00',
  `user_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `finance_expenses_transactions_expense_id_foreign` (`expense_id`),
  KEY `finance_expenses_transactions_account_id_foreign` (`account_id`),
  KEY `finance_expenses_transactions_cost_center_id_foreign` (`cost_center_id`),
  KEY `finance_expenses_transactions_user_id_foreign` (`user_id`),
  CONSTRAINT `finance_expenses_transactions_account_id_foreign` FOREIGN KEY (`account_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE CASCADE,
  CONSTRAINT `finance_expenses_transactions_cost_center_id_foreign` FOREIGN KEY (`cost_center_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `finance_expenses_transactions_expense_id_foreign` FOREIGN KEY (`expense_id`) REFERENCES `finance_expenses` (`id`) ON DELETE CASCADE,
  CONSTRAINT `finance_expenses_transactions_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `financial_years`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `financial_years` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `user_id` bigint unsigned NOT NULL,
  `name` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `start_at` date NOT NULL,
  `end_at` date NOT NULL,
  `is_closed` tinyint(1) NOT NULL,
  `total_profits` double DEFAULT NULL,
  `total_losses` double DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `financial_years_company_id_foreign` (`company_id`),
  KEY `financial_years_user_id_foreign` (`user_id`),
  CONSTRAINT `financial_years_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `financial_years_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `fixed_assets`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `fixed_assets` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `serial_number` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `purchase_date` date NOT NULL,
  `usage_date` date NOT NULL,
  `total_cost` decimal(15,2) NOT NULL,
  `payment_method` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `productive_life` int NOT NULL,
  `salvage_value` decimal(15,2) NOT NULL,
  `depreciation_method` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `annual_depreciation` decimal(15,2) DEFAULT NULL,
  `account_id` bigint unsigned DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `currency_code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `exchange_rate` double NOT NULL DEFAULT '1',
  `fixed_asset_account_id` bigint unsigned DEFAULT NULL,
  `equipment_id` bigint unsigned DEFAULT NULL,
  `supplier_id` bigint unsigned DEFAULT NULL,
  `depreciation_schedule` json DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `fixed_assets_serial_number_unique` (`serial_number`),
  KEY `fixed_assets_account_id_foreign` (`account_id`),
  KEY `fixed_assets_company_id_foreign` (`company_id`),
  KEY `fixed_assets_fixed_asset_account_id_foreign` (`fixed_asset_account_id`),
  KEY `fixed_assets_equipment_id_foreign` (`equipment_id`),
  KEY `fixed_assets_supplier_id_foreign` (`supplier_id`),
  CONSTRAINT `fixed_assets_account_id_foreign` FOREIGN KEY (`account_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `fixed_assets_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fixed_assets_equipment_id_foreign` FOREIGN KEY (`equipment_id`) REFERENCES `equipment` (`id`) ON DELETE CASCADE,
  CONSTRAINT `fixed_assets_fixed_asset_account_id_foreign` FOREIGN KEY (`fixed_asset_account_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE CASCADE,
  CONSTRAINT `fixed_assets_supplier_id_foreign` FOREIGN KEY (`supplier_id`) REFERENCES `sales_suppliers` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `general_notes`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `general_notes` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `daily_record_id` bigint unsigned NOT NULL,
  `type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `text` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `date` date NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'draft',
  `approved_by` bigint unsigned DEFAULT NULL,
  `approval_date` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `general_notes_daily_record_id_foreign` (`daily_record_id`),
  KEY `general_notes_approved_by_foreign` (`approved_by`),
  CONSTRAINT `general_notes_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
  CONSTRAINT `general_notes_daily_record_id_foreign` FOREIGN KEY (`daily_record_id`) REFERENCES `daily_records` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `history_logs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `history_logs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `supplier_id` bigint unsigned DEFAULT NULL,
  `client_id` bigint unsigned DEFAULT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `description` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `operation_date` datetime NOT NULL,
  `selling_price` decimal(10,2) DEFAULT NULL,
  `supply_price` decimal(10,2) DEFAULT NULL,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `history_logs_supplier_id_foreign` (`supplier_id`),
  KEY `history_logs_client_id_foreign` (`client_id`),
  KEY `history_logs_user_id_foreign` (`user_id`),
  KEY `history_logs_company_id_supplier_id_index` (`company_id`,`supplier_id`),
  KEY `history_logs_company_id_client_id_index` (`company_id`,`client_id`),
  KEY `history_logs_company_id_user_id_index` (`company_id`,`user_id`),
  KEY `history_logs_company_id_type_index` (`company_id`,`type`),
  KEY `history_logs_company_id_index` (`company_id`),
  CONSTRAINT `history_logs_client_id_foreign` FOREIGN KEY (`client_id`) REFERENCES `sales_clients` (`id`) ON DELETE SET NULL,
  CONSTRAINT `history_logs_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `history_logs_supplier_id_foreign` FOREIGN KEY (`supplier_id`) REFERENCES `sales_suppliers` (`id`) ON DELETE SET NULL,
  CONSTRAINT `history_logs_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `holidays`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `holidays` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `start_date` date DEFAULT NULL,
  `end_date` date DEFAULT NULL,
  `type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `information`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `information` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint unsigned DEFAULT NULL,
  `country` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `nationality` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `identity_number` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `marital_status` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `degree_level` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `study_field` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `job_title` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `birthday` date DEFAULT NULL,
  `phones` json DEFAULT NULL,
  `address` text COLLATE utf8mb4_unicode_ci,
  `start_work_at` date DEFAULT NULL,
  `end_work_at` date DEFAULT NULL,
  `family_info` json DEFAULT NULL,
  `bank_accounts` json DEFAULT NULL,
  `salary` decimal(8,2) DEFAULT NULL,
  `currency` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `information_user_id_foreign` (`user_id`),
  CONSTRAINT `information_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `interaction_stages`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `interaction_stages` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `section` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `order` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `interaction_stages_company_id_foreign` (`company_id`),
  CONSTRAINT `interaction_stages_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `interaction_types`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `interaction_types` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `title` json NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `interaction_types_company_id_foreign` (`company_id`),
  CONSTRAINT `interaction_types_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `interactions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `interactions` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `interactionable_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `interactionable_id` bigint unsigned NOT NULL,
  `interaction_type_id` bigint unsigned NOT NULL,
  `interaction_stage_id` bigint unsigned NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `is_recurring` tinyint(1) NOT NULL DEFAULT '0',
  `recurrence_frequency` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `location` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `importance` enum('Low','Medium','High') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Medium',
  `reminder_date` datetime NOT NULL,
  `interaction_date` datetime NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `interactions_interactionable_type_interactionable_id_index` (`interactionable_type`,`interactionable_id`),
  KEY `interactions_interaction_type_id_foreign` (`interaction_type_id`),
  KEY `interactions_interaction_stage_id_foreign` (`interaction_stage_id`),
  KEY `interactions_company_id_foreign` (`company_id`),
  CONSTRAINT `interactions_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `interactions_interaction_stage_id_foreign` FOREIGN KEY (`interaction_stage_id`) REFERENCES `interaction_stages` (`id`) ON DELETE RESTRICT,
  CONSTRAINT `interactions_interaction_type_id_foreign` FOREIGN KEY (`interaction_type_id`) REFERENCES `interaction_types` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `invoice_details`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `invoice_details` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `invoice_id` bigint unsigned NOT NULL,
  `entity_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `project_number` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `contract_value` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `advance_payment` decimal(10,2) DEFAULT NULL,
  `ongoing_invoices` decimal(10,2) DEFAULT NULL,
  `final_invoices` decimal(10,2) DEFAULT NULL,
  `Discounts` decimal(10,2) DEFAULT NULL,
  `total_due` decimal(10,2) DEFAULT NULL,
  `paid_amount` decimal(10,2) DEFAULT NULL,
  `net_amount` decimal(10,2) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `entity_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `invoice_details_invoice_id_foreign` (`invoice_id`),
  CONSTRAINT `invoice_details_invoice_id_foreign` FOREIGN KEY (`invoice_id`) REFERENCES `invoices` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `invoice_items`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `invoice_items` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `invoice_id` bigint unsigned NOT NULL,
  `item_id` bigint unsigned NOT NULL,
  `completed_quantity` decimal(10,2) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `invoice_managements`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `invoice_managements` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `itemable_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `itemable_id` bigint unsigned NOT NULL,
  `invoice_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `amount` decimal(10,2) NOT NULL,
  `due_date` date DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `client_id` bigint unsigned DEFAULT NULL,
  `supplier_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `work_days` int DEFAULT NULL,
  `payed_amount` decimal(10,2) NOT NULL,
  `currency_code` varchar(3) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `company_id` bigint unsigned NOT NULL DEFAULT '1',
  `account_id` bigint unsigned DEFAULT NULL,
  `itemable_code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `invoice_managements_itemable_type_itemable_id_index` (`itemable_type`,`itemable_id`),
  KEY `invoice_managements_client_id_foreign` (`client_id`),
  KEY `invoice_managements_supplier_id_foreign` (`supplier_id`),
  KEY `invoice_managements_currency_code_foreign` (`currency_code`),
  KEY `invoice_managements_company_id_foreign` (`company_id`),
  KEY `invoice_managements_account_id_foreign` (`account_id`),
  CONSTRAINT `invoice_managements_account_id_foreign` FOREIGN KEY (`account_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `invoice_managements_client_id_foreign` FOREIGN KEY (`client_id`) REFERENCES `sales_clients` (`id`) ON DELETE CASCADE,
  CONSTRAINT `invoice_managements_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `invoice_managements_currency_code_foreign` FOREIGN KEY (`currency_code`) REFERENCES `currencies` (`code`),
  CONSTRAINT `invoice_managements_supplier_id_foreign` FOREIGN KEY (`supplier_id`) REFERENCES `sales_suppliers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `invoice_templates`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `invoice_templates` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `columns` json NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `user_id` bigint unsigned NOT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `invoice_templates_user_id_foreign` (`user_id`),
  KEY `invoice_templates_company_id_foreign` (`company_id`),
  CONSTRAINT `invoice_templates_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `invoice_templates_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `invoices`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `invoices` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `contractor_id` bigint unsigned DEFAULT NULL,
  `invoice_number` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `invoice_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `contract_number` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `site_delivery_date` date NOT NULL,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `total_cost` decimal(10,2) NOT NULL,
  `tax_value` decimal(8,2) NOT NULL,
  `total_with_tax` decimal(10,2) NOT NULL,
  `previous_payments` decimal(10,2) DEFAULT NULL,
  `warranty_amount` decimal(10,2) DEFAULT NULL,
  `amount_due` decimal(10,2) NOT NULL,
  `payment_terms` json DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `client_id` bigint unsigned DEFAULT NULL,
  `project_id` bigint unsigned DEFAULT NULL,
  `advance_payment` decimal(10,2) DEFAULT NULL,
  `contract_value` decimal(10,2) DEFAULT NULL,
  `start_date` date DEFAULT NULL,
  `end_date` date DEFAULT NULL,
  `discounts` json DEFAULT NULL,
  `account_id` bigint unsigned DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `currency_code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `exchange_rate` double NOT NULL DEFAULT '1',
  `company_id` bigint unsigned DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `e_signature_id` bigint unsigned DEFAULT NULL,
  `payment_schedule` json DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `invoices_company_id_index` (`company_id`),
  KEY `invoices_contractor_id_index` (`contractor_id`),
  KEY `invoices_client_id_index` (`client_id`),
  KEY `invoices_project_id_index` (`project_id`),
  KEY `invoices_account_id_index` (`account_id`),
  KEY `invoices_e_signature_id_foreign` (`e_signature_id`),
  CONSTRAINT `invoices_account_id_foreign` FOREIGN KEY (`account_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `invoices_client_id_foreign` FOREIGN KEY (`client_id`) REFERENCES `sales_clients` (`id`) ON DELETE CASCADE,
  CONSTRAINT `invoices_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `invoices_contractor_id_foreign` FOREIGN KEY (`contractor_id`) REFERENCES `contractors` (`id`) ON DELETE CASCADE,
  CONSTRAINT `invoices_e_signature_id_foreign` FOREIGN KEY (`e_signature_id`) REFERENCES `e_signatures` (`id`) ON DELETE SET NULL,
  CONSTRAINT `invoices_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `item_phases`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `item_phases` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `quantity` decimal(10,2) NOT NULL,
  `materials` json DEFAULT NULL,
  `equipment` json DEFAULT NULL,
  `workers` json DEFAULT NULL,
  `labor_cost` decimal(10,2) DEFAULT NULL,
  `equipment_cost` decimal(10,2) DEFAULT NULL,
  `material_cost` decimal(10,2) DEFAULT NULL,
  `indirect_cost` decimal(10,2) DEFAULT NULL,
  `indirect_costs` json DEFAULT NULL,
  `profit_margin` decimal(5,2) DEFAULT NULL,
  `total_cost` decimal(10,2) DEFAULT NULL,
  `start_date` date DEFAULT NULL,
  `planned_start_date` date DEFAULT NULL,
  `end_date` date DEFAULT NULL,
  `planned_end_date` date DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `material_unit_price` decimal(10,2) DEFAULT NULL,
  `equipment_unit_cost` decimal(10,2) DEFAULT NULL,
  `worker_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `worker_count` int DEFAULT NULL,
  `cost_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `error_margin` decimal(5,2) DEFAULT NULL,
  `profit_margin_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `error_margin_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `unit_price` decimal(8,2) DEFAULT NULL,
  `tax_value` decimal(5,2) DEFAULT NULL,
  `contractor_id` bigint unsigned DEFAULT NULL,
  `remaining_quantity` decimal(10,2) DEFAULT '0.00',
  `status` enum('in_progress','pending','completed') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'in_progress',
  `completed_quantity` decimal(10,2) DEFAULT NULL,
  `unit_id` bigint unsigned DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `project_phase_id` bigint unsigned DEFAULT NULL,
  `project_id` bigint unsigned DEFAULT NULL,
  `pricing_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `cost_pool_id` bigint unsigned DEFAULT NULL,
  `external_labors` json DEFAULT NULL,
  `external_labors_cost` decimal(10,2) DEFAULT NULL,
  `estimated_days` int DEFAULT NULL,
  `external_expenses` json DEFAULT NULL,
  `users` json DEFAULT NULL,
  `users_cost` decimal(10,2) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `item_phases_unit_id_foreign` (`unit_id`),
  KEY `item_phases_company_id_foreign` (`company_id`),
  KEY `item_phases_contractor_id_index` (`contractor_id`),
  KEY `item_phases_total_cost_index` (`total_cost`),
  KEY `item_phases_project_phase_id_foreign` (`project_phase_id`),
  KEY `item_phases_project_id_foreign` (`project_id`),
  KEY `item_phases_cost_pool_id_foreign` (`cost_pool_id`),
  CONSTRAINT `item_phases_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `item_phases_contractor_id_foreign` FOREIGN KEY (`contractor_id`) REFERENCES `contractors` (`id`) ON DELETE CASCADE,
  CONSTRAINT `item_phases_cost_pool_id_foreign` FOREIGN KEY (`cost_pool_id`) REFERENCES `cost_pools` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `item_phases_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `item_phases_project_phase_id_foreign` FOREIGN KEY (`project_phase_id`) REFERENCES `project_phases` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `item_phases_unit_id_foreign` FOREIGN KEY (`unit_id`) REFERENCES `measurement_units` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `item_relations`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `item_relations` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `relation_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `lag_days` int DEFAULT NULL,
  `item_id` bigint unsigned NOT NULL,
  `related_item_id` bigint unsigned NOT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `item_relations_related_item_id_foreign` (`related_item_id`),
  KEY `item_relations_company_id_foreign` (`company_id`),
  KEY `item_relations_item_id_related_item_id_index` (`item_id`,`related_item_id`),
  CONSTRAINT `item_relations_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `item_relations_item_id_foreign` FOREIGN KEY (`item_id`) REFERENCES `item_phases` (`id`) ON DELETE CASCADE,
  CONSTRAINT `item_relations_related_item_id_foreign` FOREIGN KEY (`related_item_id`) REFERENCES `item_phases` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `items`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `items` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `job_batches`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `job_batches` (
  `id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `total_jobs` int NOT NULL,
  `pending_jobs` int NOT NULL,
  `failed_jobs` int NOT NULL,
  `failed_job_ids` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
  `options` mediumtext COLLATE utf8mb4_unicode_ci,
  `cancelled_at` int DEFAULT NULL,
  `created_at` int NOT NULL,
  `finished_at` int DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `jobs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `jobs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `queue` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `payload` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
  `attempts` tinyint unsigned NOT NULL,
  `reserved_at` int unsigned DEFAULT NULL,
  `available_at` int unsigned NOT NULL,
  `created_at` int unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `jobs_queue_index` (`queue`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `journal_transactions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `journal_transactions` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `journal_id` bigint unsigned NOT NULL,
  `account_id` bigint unsigned NOT NULL,
  `cost_center_id` bigint unsigned DEFAULT NULL,
  `debits` double NOT NULL,
  `credits` double NOT NULL,
  `notes` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `base_debits` double NOT NULL DEFAULT '0',
  `base_credits` double NOT NULL DEFAULT '0',
  `currency_code` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `exchange_rate` double NOT NULL DEFAULT '1',
  `display_currency_code` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  PRIMARY KEY (`id`),
  KEY `journal_transactions_company_id_foreign` (`company_id`),
  KEY `journal_transactions_journal_id_foreign` (`journal_id`),
  KEY `journal_transactions_account_id_foreign` (`account_id`),
  KEY `journal_transactions_cost_center_id_foreign` (`cost_center_id`),
  KEY `journal_transactions_currency_code_index` (`currency_code`),
  KEY `journal_transactions_display_currency_code_index` (`display_currency_code`),
  CONSTRAINT `journal_transactions_account_id_foreign` FOREIGN KEY (`account_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `journal_transactions_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `journal_transactions_cost_center_id_foreign` FOREIGN KEY (`cost_center_id`) REFERENCES `cost_centers` (`id`) ON DELETE SET NULL,
  CONSTRAINT `journal_transactions_journal_id_foreign` FOREIGN KEY (`journal_id`) REFERENCES `journals` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `journals`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `journals` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `date` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `notes` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `journals_company_id_index` (`company_id`),
  KEY `journals_code_index` (`code`),
  KEY `journals_date_index` (`date`),
  CONSTRAINT `journals_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `lab_tests`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `lab_tests` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `daily_record_id` bigint unsigned NOT NULL,
  `test_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `results` text COLLATE utf8mb4_unicode_ci,
  `date` date NOT NULL,
  `laboratory` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `standards` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'draft',
  `approved_by` bigint unsigned DEFAULT NULL,
  `approval_date` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `lab_tests_daily_record_id_foreign` (`daily_record_id`),
  KEY `lab_tests_approved_by_foreign` (`approved_by`),
  CONSTRAINT `lab_tests_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
  CONSTRAINT `lab_tests_daily_record_id_foreign` FOREIGN KEY (`daily_record_id`) REFERENCES `daily_records` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `labor_categories`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `labor_categories` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `title` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `section` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT 'accounting',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `languages`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `languages` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `language` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `leave_balances`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `leave_balances` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint unsigned NOT NULL,
  `leave_category` enum('annual_paid','annual_unpaid','sick_paid','sick_unpaid') COLLATE utf8mb4_unicode_ci NOT NULL,
  `leave_type` enum('Leave','Permission') COLLATE utf8mb4_unicode_ci NOT NULL,
  `balance` int NOT NULL DEFAULT '0',
  `allowed_leaves` int NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_user_category_type` (`user_id`,`leave_category`,`leave_type`),
  CONSTRAINT `leave_balances_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `leaves`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `leaves` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint unsigned NOT NULL,
  `start_date` date NOT NULL,
  `end_date` date NOT NULL,
  `leave_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Pending',
  `reason` text COLLATE utf8mb4_unicode_ci,
  `approved_by_user_id` bigint unsigned DEFAULT NULL,
  `penalty_id` bigint unsigned DEFAULT NULL,
  `amount` decimal(8,2) DEFAULT '0.00',
  `leave_category` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `start_time` datetime DEFAULT NULL,
  `end_time` datetime DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `rejection_reason` text COLLATE utf8mb4_unicode_ci,
  PRIMARY KEY (`id`),
  KEY `leaves_user_id_foreign` (`user_id`),
  KEY `leaves_approved_by_user_id_foreign` (`approved_by_user_id`),
  KEY `leaves_penalty_id_foreign` (`penalty_id`),
  KEY `leaves_company_id_foreign` (`company_id`),
  CONSTRAINT `leaves_approved_by_user_id_foreign` FOREIGN KEY (`approved_by_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `leaves_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `leaves_penalty_id_foreign` FOREIGN KEY (`penalty_id`) REFERENCES `rewards_and_penalties` (`id`) ON DELETE SET NULL,
  CONSTRAINT `leaves_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `main_contractors`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `main_contractors` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'main_contractor',
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `phone` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `address` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `responsible_persons` longtext COLLATE utf8mb4_unicode_ci,
  `contract_status` tinyint(1) NOT NULL DEFAULT '1',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `main_event_schedules`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `main_event_schedules` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `main_event_id` bigint unsigned NOT NULL,
  `day` enum('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday') COLLATE utf8mb4_unicode_ci NOT NULL,
  `start_time` time NOT NULL,
  `end_time` time NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `main_event_schedules_main_event_id_foreign` (`main_event_id`),
  CONSTRAINT `main_event_schedules_main_event_id_foreign` FOREIGN KEY (`main_event_id`) REFERENCES `main_events` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `main_events`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `main_events` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `slug` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `title` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `platform` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `event_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `active` tinyint(1) NOT NULL,
  `duration` int NOT NULL,
  `start_at` date DEFAULT NULL,
  `end_at` date DEFAULT NULL,
  `color` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `form_fields` json DEFAULT NULL,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `invitees` json DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `main_events_slug_unique` (`slug`),
  KEY `main_events_company_id_foreign` (`company_id`),
  CONSTRAINT `main_events_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `main_inventories`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `main_inventories` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `title` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `for_product` tinyint(1) NOT NULL DEFAULT '0',
  `for_material` tinyint(1) NOT NULL DEFAULT '0',
  `for_equipment` tinyint(1) NOT NULL DEFAULT '0',
  `store_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `project_id` bigint unsigned DEFAULT NULL,
  `inventory_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` tinyint(1) NOT NULL DEFAULT '1',
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `main_inventories_company_id_index` (`company_id`),
  KEY `main_inventories_store_id_index` (`store_id`),
  KEY `main_inventories_for_product_for_material_for_equipment_index` (`for_product`,`for_material`,`for_equipment`),
  KEY `main_inventories_project_id_foreign` (`project_id`),
  CONSTRAINT `main_inventories_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE,
  CONSTRAINT `main_inventories_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE,
  CONSTRAINT `main_inventories_store_id_foreign` FOREIGN KEY (`store_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `main_phases`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `main_phases` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `main_project_user`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `main_project_user` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `main_project_id` bigint unsigned NOT NULL,
  `user_id` bigint unsigned NOT NULL,
  `is_favorite` tinyint(1) NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `main_project_user_main_project_id_user_id_unique` (`main_project_id`,`user_id`),
  KEY `main_project_user_user_id_foreign` (`user_id`),
  CONSTRAINT `main_project_user_main_project_id_foreign` FOREIGN KEY (`main_project_id`) REFERENCES `main_projects` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `main_project_user_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `main_projects`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `main_projects` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `color` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `main_task_links`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `main_task_links` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `main_task_id` bigint unsigned NOT NULL,
  `related_main_task_id` bigint unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `main_task_links_main_task_id_related_main_task_id_unique` (`main_task_id`,`related_main_task_id`),
  KEY `main_task_links_related_main_task_id_foreign` (`related_main_task_id`),
  CONSTRAINT `main_task_links_main_task_id_foreign` FOREIGN KEY (`main_task_id`) REFERENCES `main_tasks` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `main_task_links_related_main_task_id_foreign` FOREIGN KEY (`related_main_task_id`) REFERENCES `main_tasks` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `main_task_tag`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `main_task_tag` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `main_task_id` bigint unsigned NOT NULL,
  `task_tag_id` bigint unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `main_task_tag_main_task_id_task_tag_id_unique` (`main_task_id`,`task_tag_id`),
  KEY `main_task_tag_task_tag_id_foreign` (`task_tag_id`),
  CONSTRAINT `main_task_tag_main_task_id_foreign` FOREIGN KEY (`main_task_id`) REFERENCES `main_tasks` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `main_task_tag_task_tag_id_foreign` FOREIGN KEY (`task_tag_id`) REFERENCES `task_tags` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `main_tasks`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `main_tasks` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint unsigned DEFAULT NULL,
  `task_category_id` bigint unsigned DEFAULT NULL,
  `main_project_id` bigint unsigned NOT NULL,
  `workflow_stage_id` bigint unsigned NOT NULL,
  `order` int DEFAULT NULL,
  `title` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `start_date` timestamp NULL DEFAULT NULL,
  `end_date` timestamp NULL DEFAULT NULL,
  `priority` enum('Lowest','Low','Medium','High','Highest') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Medium',
  `parent_id` bigint unsigned DEFAULT NULL,
  `due_date` date DEFAULT NULL,
  `number` int NOT NULL,
  `formatted_number` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `taskable_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `taskable_id` bigint unsigned DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `main_tasks_user_id_foreign` (`user_id`),
  KEY `main_tasks_task_category_id_foreign` (`task_category_id`),
  KEY `main_tasks_main_project_id_foreign` (`main_project_id`),
  KEY `main_tasks_workflow_stage_id_foreign` (`workflow_stage_id`),
  KEY `main_tasks_parent_id_foreign` (`parent_id`),
  KEY `main_tasks_taskable_type_taskable_id_index` (`taskable_type`,`taskable_id`),
  KEY `main_tasks_title_index` (`title`),
  KEY `main_tasks_number_index` (`number`),
  KEY `main_tasks_formatted_number_index` (`formatted_number`),
  KEY `main_tasks_company_user_index` (`company_id`,`user_id`),
  KEY `main_tasks_company_category_index` (`company_id`,`task_category_id`),
  KEY `main_tasks_company_project_index` (`company_id`,`main_project_id`),
  KEY `main_tasks_company_workflow_index` (`company_id`,`workflow_stage_id`),
  KEY `main_tasks_company_priority_index` (`company_id`,`priority`),
  KEY `main_tasks_company_parent_index` (`company_id`,`parent_id`),
  KEY `main_tasks_company_start_date_index` (`company_id`,`start_date`),
  KEY `main_tasks_company_end_date_index` (`company_id`,`end_date`),
  KEY `main_tasks_company_due_date_index` (`company_id`,`due_date`),
  KEY `main_tasks_company_order_index` (`company_id`,`order`),
  KEY `main_tasks_priority_due_date_index` (`company_id`,`priority`,`due_date`),
  CONSTRAINT `main_tasks_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `main_tasks_main_project_id_foreign` FOREIGN KEY (`main_project_id`) REFERENCES `main_projects` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `main_tasks_parent_id_foreign` FOREIGN KEY (`parent_id`) REFERENCES `main_tasks` (`id`) ON DELETE CASCADE,
  CONSTRAINT `main_tasks_task_category_id_foreign` FOREIGN KEY (`task_category_id`) REFERENCES `task_categories` (`id`) ON DELETE SET NULL,
  CONSTRAINT `main_tasks_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `main_tasks_workflow_stage_id_foreign` FOREIGN KEY (`workflow_stage_id`) REFERENCES `workflow_stages` (`id`) ON DELETE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `maintenance_contract_assets`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `maintenance_contract_assets` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `maintenance_contracts_id` bigint unsigned NOT NULL,
  `asset_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `asset_code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `asset_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `installation_address` text COLLATE utf8mb4_unicode_ci,
  `serial_number` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `condition_at_signing` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `fixed_asset_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `maintenance_contract_assets_maintenance_contracts_id_foreign` (`maintenance_contracts_id`),
  KEY `maintenance_contract_assets_fixed_asset_id_foreign` (`fixed_asset_id`),
  CONSTRAINT `maintenance_contract_assets_fixed_asset_id_foreign` FOREIGN KEY (`fixed_asset_id`) REFERENCES `fixed_assets` (`id`) ON DELETE CASCADE,
  CONSTRAINT `maintenance_contract_assets_maintenance_contracts_id_foreign` FOREIGN KEY (`maintenance_contracts_id`) REFERENCES `maintenance_contracts` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `maintenance_contracts`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `maintenance_contracts` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `client_id` bigint unsigned DEFAULT NULL,
  `contract_number` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `sign_date` date DEFAULT NULL,
  `start_date` date DEFAULT NULL,
  `end_date` date DEFAULT NULL,
  `type` enum('monthly','yearly','on_call','hourly','full_coverage') COLLATE utf8mb4_unicode_ci NOT NULL,
  `scope_of_work` text COLLATE utf8mb4_unicode_ci,
  `cost_details` json DEFAULT NULL,
  `maintenance_plan` json DEFAULT NULL,
  `terms` json DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'draft',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `old_versions` json DEFAULT NULL,
  `preamble` text COLLATE utf8mb4_unicode_ci,
  `signature_status` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `contract_title` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `contract_introduction` text COLLATE utf8mb4_unicode_ci,
  `contract_subject` text COLLATE utf8mb4_unicode_ci,
  `is_renewable` tinyint(1) NOT NULL DEFAULT '0',
  `rights_and_obligations` text COLLATE utf8mb4_unicode_ci,
  PRIMARY KEY (`id`),
  UNIQUE KEY `maintenance_contracts_contract_number_unique` (`contract_number`),
  KEY `maintenance_contracts_client_id_status_index` (`client_id`,`status`),
  CONSTRAINT `maintenance_contracts_client_id_foreign` FOREIGN KEY (`client_id`) REFERENCES `sales_clients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `management_categories`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `management_categories` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `phase_id` bigint unsigned NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `management_categories_phase_id_foreign` (`phase_id`),
  KEY `management_categories_company_id_foreign` (`company_id`),
  CONSTRAINT `management_categories_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `management_categories_phase_id_foreign` FOREIGN KEY (`phase_id`) REFERENCES `management_phases` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `management_phases`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `management_phases` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `project_id` bigint unsigned NOT NULL,
  `main_phases_id` bigint unsigned NOT NULL,
  `start_date` date DEFAULT NULL,
  `end_date` date DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `management_phases_project_id_unique` (`project_id`),
  KEY `management_phases_main_phases_id_foreign` (`main_phases_id`),
  KEY `management_phases_company_id_foreign` (`company_id`),
  CONSTRAINT `management_phases_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `management_phases_main_phases_id_foreign` FOREIGN KEY (`main_phases_id`) REFERENCES `main_phases` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `management_phases_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `main_projects` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `management_project_files`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `management_project_files` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `management_projects_id` bigint unsigned NOT NULL,
  `folder_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `management_project_files_management_projects_id_unique` (`management_projects_id`),
  KEY `management_project_files_company_id_foreign` (`company_id`),
  CONSTRAINT `management_project_files_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `management_project_files_management_projects_id_foreign` FOREIGN KEY (`management_projects_id`) REFERENCES `management_projects` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `management_projects`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `management_projects` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `project_id` bigint unsigned NOT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `client_id` bigint unsigned DEFAULT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `budget` decimal(15,2) DEFAULT NULL,
  `start_date` date DEFAULT NULL,
  `end_date` date DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `company_id` bigint unsigned NOT NULL,
  `for_company` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `management_projects_project_id_unique` (`project_id`),
  KEY `management_projects_user_id_foreign` (`user_id`),
  KEY `management_projects_client_id_foreign` (`client_id`),
  KEY `management_projects_project_id_index` (`project_id`),
  KEY `management_projects_project_id_client_id_index` (`project_id`,`client_id`),
  KEY `management_projects_project_id_user_id_index` (`project_id`,`user_id`),
  KEY `management_projects_company_id_foreign` (`company_id`),
  CONSTRAINT `management_projects_client_id_foreign` FOREIGN KEY (`client_id`) REFERENCES `sales_clients` (`id`) ON DELETE SET NULL,
  CONSTRAINT `management_projects_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `management_projects_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `main_projects` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `management_projects_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `management_task_categories`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `management_task_categories` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `management_tasks`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `management_tasks` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `main_task_id` bigint unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `management_tasks_company_id_foreign` (`company_id`),
  KEY `management_tasks_main_task_id_index` (`main_task_id`),
  CONSTRAINT `management_tasks_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `management_tasks_main_task_id_foreign` FOREIGN KEY (`main_task_id`) REFERENCES `main_tasks` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `manual_store_transactions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `manual_store_transactions` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `product_id` bigint unsigned DEFAULT NULL,
  `store_id` bigint unsigned DEFAULT NULL,
  `amount` double NOT NULL,
  `itemable_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `itemable_id` bigint unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `manual_store_transactions_company_id_foreign` (`company_id`),
  KEY `manual_store_transactions_product_id_foreign` (`product_id`),
  KEY `manual_store_transactions_store_id_foreign` (`store_id`),
  KEY `manual_store_transactions_itemable_type_itemable_id_index` (`itemable_type`,`itemable_id`),
  CONSTRAINT `manual_store_transactions_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `manual_store_transactions_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `sales_products` (`id`) ON DELETE SET NULL,
  CONSTRAINT `manual_store_transactions_store_id_foreign` FOREIGN KEY (`store_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `material_categories`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `material_categories` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `material_requests`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `material_requests` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `project_id` bigint unsigned DEFAULT NULL,
  `project_phase_id` bigint unsigned DEFAULT NULL,
  `item_phase_id` bigint unsigned DEFAULT NULL,
  `items` json NOT NULL,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `store_id` bigint unsigned DEFAULT NULL,
  `request_number` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `request_date` date DEFAULT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `request_reviews` json DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `material_requests_project_id_foreign` (`project_id`),
  KEY `material_requests_project_phase_id_foreign` (`project_phase_id`),
  KEY `material_requests_item_phase_id_foreign` (`item_phase_id`),
  CONSTRAINT `material_requests_item_phase_id_foreign` FOREIGN KEY (`item_phase_id`) REFERENCES `item_phases` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `material_requests_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE,
  CONSTRAINT `material_requests_project_phase_id_foreign` FOREIGN KEY (`project_phase_id`) REFERENCES `project_phases` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `material_supplier`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `material_supplier` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `material_id` bigint unsigned NOT NULL,
  `supplier_id` bigint unsigned NOT NULL,
  `delivery_time` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `material_supplier_material_id_foreign` (`material_id`),
  KEY `material_supplier_supplier_id_foreign` (`supplier_id`),
  CONSTRAINT `material_supplier_material_id_foreign` FOREIGN KEY (`material_id`) REFERENCES `materials` (`id`) ON DELETE CASCADE,
  CONSTRAINT `material_supplier_supplier_id_foreign` FOREIGN KEY (`supplier_id`) REFERENCES `suppliers` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `materials`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `materials` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `length` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `width` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `height` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `manufacture_material` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `total_price` int NOT NULL DEFAULT '1',
  `current_stock` int DEFAULT NULL,
  `unit_price` double NOT NULL,
  `profit_margin_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'fixed',
  `profit_margin` double NOT NULL,
  `final_cost` double NOT NULL,
  `status` tinyint(1) NOT NULL DEFAULT '1',
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `store_id` bigint unsigned DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  `currency_code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `exchange_rate` double NOT NULL DEFAULT '1',
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `selling_price` decimal(15,2) DEFAULT NULL,
  `tax_rate` decimal(5,2) DEFAULT NULL,
  `reorder_level` int DEFAULT NULL,
  `max_stock` int DEFAULT NULL,
  `lead_time` int DEFAULT NULL,
  `time_unit` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `primary_supplier_id` bigint unsigned DEFAULT NULL,
  `weight` decimal(10,2) DEFAULT NULL,
  `expiration_date` date DEFAULT NULL,
  `custom_fields` json DEFAULT NULL,
  `unit_id` bigint unsigned DEFAULT NULL,
  `material_category_id` bigint unsigned DEFAULT NULL,
  `qr_code_value` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `materials_qr_code_value_unique` (`qr_code_value`),
  KEY `materials_name_index` (`name`),
  KEY `materials_manufacture_material_index` (`manufacture_material`),
  KEY `materials_status_index` (`status`),
  KEY `materials_store_id_foreign` (`store_id`),
  KEY `materials_company_id_foreign` (`company_id`),
  KEY `materials_primary_supplier_id_foreign` (`primary_supplier_id`),
  KEY `materials_unit_id_foreign` (`unit_id`),
  KEY `materials_material_category_id_foreign` (`material_category_id`),
  CONSTRAINT `materials_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `materials_material_category_id_foreign` FOREIGN KEY (`material_category_id`) REFERENCES `material_categories` (`id`) ON DELETE CASCADE,
  CONSTRAINT `materials_primary_supplier_id_foreign` FOREIGN KEY (`primary_supplier_id`) REFERENCES `sales_suppliers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `materials_store_id_foreign` FOREIGN KEY (`store_id`) REFERENCES `main_inventories` (`id`) ON DELETE SET NULL,
  CONSTRAINT `materials_unit_id_foreign` FOREIGN KEY (`unit_id`) REFERENCES `measurement_units` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `materials_consumed`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `materials_consumed` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `daily_record_id` bigint unsigned NOT NULL,
  `material_id` bigint unsigned NOT NULL,
  `quantity` decimal(10,2) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'draft',
  `approved_by` bigint unsigned DEFAULT NULL,
  `approval_date` timestamp NULL DEFAULT NULL,
  `item_phase_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `materials_consumed_daily_record_id_foreign` (`daily_record_id`),
  KEY `materials_consumed_material_id_foreign` (`material_id`),
  KEY `materials_consumed_approved_by_foreign` (`approved_by`),
  KEY `materials_consumed_item_phase_id_foreign` (`item_phase_id`),
  CONSTRAINT `materials_consumed_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
  CONSTRAINT `materials_consumed_daily_record_id_foreign` FOREIGN KEY (`daily_record_id`) REFERENCES `daily_records` (`id`) ON DELETE CASCADE,
  CONSTRAINT `materials_consumed_item_phase_id_foreign` FOREIGN KEY (`item_phase_id`) REFERENCES `item_phases` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `materials_consumed_material_id_foreign` FOREIGN KEY (`material_id`) REFERENCES `materials` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `materials_received`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `materials_received` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `daily_record_id` bigint unsigned NOT NULL,
  `material_id` bigint unsigned NOT NULL,
  `quantity` decimal(10,2) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'draft',
  `approved_by` bigint unsigned DEFAULT NULL,
  `approval_date` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `materials_received_daily_record_id_foreign` (`daily_record_id`),
  KEY `materials_received_material_id_foreign` (`material_id`),
  KEY `materials_received_approved_by_foreign` (`approved_by`),
  CONSTRAINT `materials_received_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
  CONSTRAINT `materials_received_daily_record_id_foreign` FOREIGN KEY (`daily_record_id`) REFERENCES `daily_records` (`id`) ON DELETE CASCADE,
  CONSTRAINT `materials_received_material_id_foreign` FOREIGN KEY (`material_id`) REFERENCES `materials` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `measurement_units`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `measurement_units` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `symbol` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `is_base` tinyint(1) NOT NULL DEFAULT '0',
  `active` tinyint(1) NOT NULL DEFAULT '1',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `title` json DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `for_procurement` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `measurement_units_is_base_index` (`is_base`),
  KEY `measurement_units_active_index` (`active`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `media`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `media` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `model_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `model_id` bigint unsigned NOT NULL,
  `uuid` char(36) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `collection_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `directory` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `file_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `mime_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `disk` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `conversions_disk` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `size` bigint unsigned NOT NULL,
  `manipulations` json NOT NULL,
  `custom_properties` json NOT NULL,
  `generated_conversions` json NOT NULL,
  `responsive_images` json NOT NULL,
  `order_column` int unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `media_uuid_unique` (`uuid`),
  KEY `media_model_type_model_id_index` (`model_type`,`model_id`),
  KEY `media_order_column_index` (`order_column`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `migrations`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `migrations` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `migration` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `batch` int NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `model_has_permissions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `model_has_permissions` (
  `permission_id` bigint unsigned NOT NULL,
  `model_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `model_id` bigint unsigned NOT NULL,
  PRIMARY KEY (`permission_id`,`model_id`,`model_type`),
  KEY `model_has_permissions_model_id_model_type_index` (`model_id`,`model_type`),
  CONSTRAINT `model_has_permissions_permission_id_foreign` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `model_has_roles`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `model_has_roles` (
  `role_id` bigint unsigned NOT NULL,
  `model_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `model_id` bigint unsigned NOT NULL,
  PRIMARY KEY (`role_id`,`model_id`,`model_type`),
  KEY `model_has_roles_model_id_model_type_index` (`model_id`,`model_type`),
  CONSTRAINT `model_has_roles_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `month_salaries`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `month_salaries` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint unsigned NOT NULL,
  `admin_id` bigint unsigned DEFAULT NULL,
  `base_salary` decimal(10,2) NOT NULL,
  `currency` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `total_penalties` decimal(10,2) NOT NULL DEFAULT '0.00',
  `total_rewards` decimal(10,2) NOT NULL DEFAULT '0.00',
  `net_salary` decimal(10,2) NOT NULL DEFAULT '0.00',
  `payroll_datetime` timestamp NULL DEFAULT NULL,
  `month` tinyint NOT NULL,
  `year` smallint NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `exchange_rate` double NOT NULL DEFAULT '1',
  `company_id` bigint unsigned DEFAULT NULL,
  `transfer_fee` decimal(10,2) NOT NULL DEFAULT '0.00',
  PRIMARY KEY (`id`),
  KEY `month_salaries_user_id_index` (`user_id`),
  KEY `month_salaries_admin_id_index` (`admin_id`),
  KEY `month_salaries_month_year_index` (`month`,`year`),
  KEY `month_salaries_payroll_datetime_index` (`payroll_datetime`),
  KEY `month_salaries_company_id_foreign` (`company_id`),
  CONSTRAINT `month_salaries_admin_id_foreign` FOREIGN KEY (`admin_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `month_salaries_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `month_salaries_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `notes`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `notes` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `note` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `noteable_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `noteable_id` bigint unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `notes_noteable_type_noteable_id_index` (`noteable_type`,`noteable_id`),
  KEY `notes_company_id_foreign` (`company_id`),
  CONSTRAINT `notes_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `notifications`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `notifications` (
  `id` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `notifiable_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `notifiable_id` bigint unsigned NOT NULL,
  `data` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `read_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `notifications_notifiable_type_notifiable_id_index` (`notifiable_type`,`notifiable_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `opening_entries`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `opening_entries` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `date` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `notes` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `credit` double NOT NULL DEFAULT '0',
  `debit` double NOT NULL DEFAULT '0',
  `net` double NOT NULL DEFAULT '0',
  `currency_code` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `exchange_rate` double NOT NULL DEFAULT '1',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `opening_entries_company_id_index` (`company_id`),
  KEY `opening_entries_user_id_index` (`user_id`),
  KEY `opening_entries_date_index` (`date`),
  KEY `opening_entries_currency_code_index` (`currency_code`),
  CONSTRAINT `opening_entries_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `opening_entries_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `opening_entries_transactions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `opening_entries_transactions` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `journal_id` bigint unsigned NOT NULL,
  `account_id` bigint unsigned NOT NULL,
  `debits` double NOT NULL,
  `credits` double NOT NULL,
  `notes` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `opening_entries_transactions_journal_id_index` (`journal_id`),
  KEY `opening_entries_transactions_account_id_index` (`account_id`),
  CONSTRAINT `opening_entries_transactions_account_id_foreign` FOREIGN KEY (`account_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `opening_entries_transactions_journal_id_foreign` FOREIGN KEY (`journal_id`) REFERENCES `opening_entries` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `order_drivers`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `order_drivers` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `order_id` bigint unsigned NOT NULL,
  `supplier_id` bigint unsigned DEFAULT NULL,
  `driver_id` bigint unsigned DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `order_drivers_order_id_foreign` (`order_id`),
  KEY `order_drivers_supplier_id_foreign` (`supplier_id`),
  KEY `order_drivers_driver_id_foreign` (`driver_id`),
  KEY `order_drivers_company_id_order_id_index` (`company_id`,`order_id`),
  KEY `order_drivers_company_id_status_index` (`company_id`,`status`),
  KEY `order_drivers_company_id_supplier_id_index` (`company_id`,`supplier_id`),
  KEY `order_drivers_company_id_driver_id_index` (`company_id`,`driver_id`),
  KEY `order_drivers_company_id_index` (`company_id`),
  CONSTRAINT `order_drivers_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `order_drivers_driver_id_foreign` FOREIGN KEY (`driver_id`) REFERENCES `drivers` (`id`) ON DELETE SET NULL,
  CONSTRAINT `order_drivers_order_id_foreign` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `order_drivers_supplier_id_foreign` FOREIGN KEY (`supplier_id`) REFERENCES `sales_suppliers` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `order_suppliers`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `order_suppliers` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `order_id` bigint unsigned NOT NULL,
  `supplier_id` bigint unsigned DEFAULT NULL,
  `unit_id` bigint unsigned NOT NULL,
  `loads_count` int NOT NULL,
  `accepted_loads_count` int DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'new',
  `type` enum('supplier only','supplier and carrier') COLLATE utf8mb4_unicode_ci NOT NULL,
  `price` decimal(8,2) DEFAULT NULL,
  `transporter_price` decimal(8,2) DEFAULT NULL,
  `action_at` datetime DEFAULT NULL,
  `delivered_count` int NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `reminder_sent_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `order_suppliers_order_id_foreign` (`order_id`),
  KEY `order_suppliers_supplier_id_foreign` (`supplier_id`),
  KEY `order_suppliers_unit_id_foreign` (`unit_id`),
  KEY `order_suppliers_company_id_order_id_index` (`company_id`,`order_id`),
  KEY `order_suppliers_company_id_supplier_id_index` (`company_id`,`supplier_id`),
  KEY `order_suppliers_company_id_status_index` (`company_id`,`status`),
  KEY `order_suppliers_company_id_type_index` (`company_id`,`type`),
  KEY `order_suppliers_company_id_index` (`company_id`),
  CONSTRAINT `order_suppliers_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `order_suppliers_order_id_foreign` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `order_suppliers_supplier_id_foreign` FOREIGN KEY (`supplier_id`) REFERENCES `sales_suppliers` (`id`) ON DELETE SET NULL,
  CONSTRAINT `order_suppliers_unit_id_foreign` FOREIGN KEY (`unit_id`) REFERENCES `measurement_units` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `order_vehicles`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `order_vehicles` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `order_id` bigint unsigned NOT NULL,
  `supplier_id` bigint unsigned DEFAULT NULL,
  `driver_id` bigint unsigned DEFAULT NULL,
  `unit_id` bigint unsigned NOT NULL,
  `weight` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `driver_data` json DEFAULT NULL,
  `upload_at` datetime DEFAULT NULL,
  `handed` tinyint(1) NOT NULL DEFAULT '0',
  `buy_price` decimal(8,2) DEFAULT NULL,
  `transporter_price` decimal(8,2) DEFAULT NULL,
  `price` decimal(8,2) DEFAULT NULL,
  `loaded_at` datetime DEFAULT NULL,
  `client_is_delivered` tinyint(1) NOT NULL DEFAULT '0',
  `cut_weight` int DEFAULT '0',
  `cancel_reason` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `additional_data` json DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `reminder_sent_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `order_vehicles_order_id_foreign` (`order_id`),
  KEY `order_vehicles_supplier_id_foreign` (`supplier_id`),
  KEY `order_vehicles_driver_id_foreign` (`driver_id`),
  KEY `order_vehicles_unit_id_foreign` (`unit_id`),
  KEY `order_vehicles_company_id_order_id_index` (`company_id`,`order_id`),
  KEY `order_vehicles_company_id_supplier_id_index` (`company_id`,`supplier_id`),
  KEY `order_vehicles_company_id_driver_id_index` (`company_id`,`driver_id`),
  KEY `order_vehicles_company_id_status_index` (`company_id`,`status`),
  KEY `order_vehicles_company_id_index` (`company_id`),
  CONSTRAINT `order_vehicles_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `order_vehicles_driver_id_foreign` FOREIGN KEY (`driver_id`) REFERENCES `drivers` (`id`) ON DELETE SET NULL,
  CONSTRAINT `order_vehicles_order_id_foreign` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `order_vehicles_supplier_id_foreign` FOREIGN KEY (`supplier_id`) REFERENCES `sales_suppliers` (`id`) ON DELETE SET NULL,
  CONSTRAINT `order_vehicles_unit_id_foreign` FOREIGN KEY (`unit_id`) REFERENCES `measurement_units` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `orders`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `orders` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `unit_id` bigint unsigned NOT NULL,
  `product_id` bigint unsigned NOT NULL,
  `client_id` bigint unsigned DEFAULT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `order_number` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `date` date NOT NULL,
  `address` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `product_qty` int NOT NULL,
  `product_qty_ton` int DEFAULT NULL,
  `total` decimal(10,8) DEFAULT NULL,
  `is_recurring` tinyint(1) NOT NULL DEFAULT '0',
  `recurring_interval` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `in_accounting` tinyint(1) NOT NULL DEFAULT '0',
  `price` decimal(8,2) DEFAULT NULL,
  `persons` json DEFAULT NULL,
  `for_project` tinyint(1) NOT NULL DEFAULT '0',
  `for_diesel` tinyint(1) NOT NULL DEFAULT '0',
  `created_date` date DEFAULT NULL,
  `unit_amount` decimal(8,1) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `exchange_rate` decimal(10,4) NOT NULL DEFAULT '1.0000',
  `currency_code` varchar(3) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `orders_unit_id_foreign` (`unit_id`),
  KEY `orders_product_id_foreign` (`product_id`),
  KEY `orders_client_id_foreign` (`client_id`),
  KEY `orders_user_id_foreign` (`user_id`),
  KEY `orders_company_id_created_at_index` (`company_id`,`created_at`),
  KEY `orders_company_id_status_created_at_index` (`company_id`,`status`,`created_at`),
  KEY `orders_company_id_date_index` (`company_id`,`date`),
  KEY `orders_company_id_client_id_index` (`company_id`,`client_id`),
  KEY `orders_company_id_product_id_index` (`company_id`,`product_id`),
  KEY `orders_order_number_company_id_index` (`order_number`,`company_id`),
  KEY `orders_company_id_is_recurring_index` (`company_id`,`is_recurring`),
  KEY `orders_company_id_for_project_index` (`company_id`,`for_project`),
  KEY `orders_company_id_for_diesel_index` (`company_id`,`for_diesel`),
  KEY `orders_currency_code_index` (`currency_code`),
  CONSTRAINT `orders_client_id_foreign` FOREIGN KEY (`client_id`) REFERENCES `sales_clients` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `orders_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `orders_currency_code_foreign` FOREIGN KEY (`currency_code`) REFERENCES `currencies` (`code`),
  CONSTRAINT `orders_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `sales_products` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `orders_unit_id_foreign` FOREIGN KEY (`unit_id`) REFERENCES `measurement_units` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `orders_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `overtimes`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `overtimes` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint unsigned NOT NULL,
  `date` date NOT NULL,
  `start_time` time NOT NULL,
  `end_time` time DEFAULT NULL,
  `hours` decimal(5,2) NOT NULL DEFAULT '0.00',
  `reason` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `rejection_reason` text COLLATE utf8mb4_unicode_ci,
  `creator_id` bigint unsigned DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `overtimes_user_id_foreign` (`user_id`),
  KEY `overtimes_creator_id_foreign` (`creator_id`),
  KEY `overtimes_company_id_foreign` (`company_id`),
  CONSTRAINT `overtimes_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `overtimes_creator_id_foreign` FOREIGN KEY (`creator_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `overtimes_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `password_reset_tokens`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `password_reset_tokens` (
  `email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `token` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `payment_paper_invoice`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `payment_paper_invoice` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `payment_paper_id` bigint unsigned NOT NULL,
  `purchase_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `payment_paper_invoice_payment_paper_id_foreign` (`payment_paper_id`),
  KEY `payment_paper_invoice_purchase_id_foreign` (`purchase_id`),
  CONSTRAINT `payment_paper_invoice_payment_paper_id_foreign` FOREIGN KEY (`payment_paper_id`) REFERENCES `payments_papers` (`id`) ON DELETE CASCADE,
  CONSTRAINT `payment_paper_invoice_purchase_id_foreign` FOREIGN KEY (`purchase_id`) REFERENCES `purchases` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `payments_papers`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `payments_papers` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `account_id` bigint unsigned NOT NULL,
  `user_id` bigint unsigned NOT NULL,
  `by_user_id` bigint unsigned DEFAULT NULL,
  `date` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `due_date` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `amount` double NOT NULL,
  `currency_code` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `exchange_rate` double NOT NULL DEFAULT '1',
  `payable_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `payable_id` bigint unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `supplier_id` bigint unsigned DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `payment_method` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `reason` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `payments_papers_company_id_foreign` (`company_id`),
  KEY `payments_papers_account_id_foreign` (`account_id`),
  KEY `payments_papers_user_id_foreign` (`user_id`),
  KEY `payments_papers_by_user_id_foreign` (`by_user_id`),
  KEY `payments_papers_payable_type_payable_id_index` (`payable_type`,`payable_id`),
  KEY `payments_papers_supplier_id_foreign` (`supplier_id`),
  CONSTRAINT `payments_papers_account_id_foreign` FOREIGN KEY (`account_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `payments_papers_by_user_id_foreign` FOREIGN KEY (`by_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `payments_papers_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `payments_papers_supplier_id_foreign` FOREIGN KEY (`supplier_id`) REFERENCES `sales_suppliers` (`id`) ON DELETE SET NULL,
  CONSTRAINT `payments_papers_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `permissions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `permissions` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `title` json NOT NULL,
  `group_title` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `category` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `guard_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `permissions_name_guard_name_unique` (`name`,`guard_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `personal_access_tokens`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `personal_access_tokens` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `tokenable_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `tokenable_id` bigint unsigned NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `token` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
  `abilities` text COLLATE utf8mb4_unicode_ci,
  `last_used_at` timestamp NULL DEFAULT NULL,
  `expires_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `personal_access_tokens_token_unique` (`token`),
  KEY `personal_access_tokens_tokenable_type_tokenable_id_index` (`tokenable_type`,`tokenable_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `phase_relations`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `phase_relations` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `relation_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `lag_days` int DEFAULT NULL,
  `phase_id` bigint unsigned NOT NULL,
  `related_phase_id` bigint unsigned NOT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `phase_relations_related_phase_id_foreign` (`related_phase_id`),
  KEY `phase_relations_company_id_foreign` (`company_id`),
  KEY `phase_relations_phase_id_related_phase_id_index` (`phase_id`,`related_phase_id`),
  CONSTRAINT `phase_relations_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `phase_relations_phase_id_foreign` FOREIGN KEY (`phase_id`) REFERENCES `project_phases` (`id`) ON DELETE CASCADE,
  CONSTRAINT `phase_relations_related_phase_id_foreign` FOREIGN KEY (`related_phase_id`) REFERENCES `project_phases` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `price_approvals`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `price_approvals` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `product_id` bigint unsigned NOT NULL,
  `requested_price` decimal(10,2) NOT NULL,
  `requested_quantity` int NOT NULL,
  `status` enum('pending','approved','rejected') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `admin_note` text COLLATE utf8mb4_unicode_ci,
  `requested_by` bigint unsigned NOT NULL,
  `approved_by` bigint unsigned DEFAULT NULL,
  `transaction_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `price_approvals_product_id_foreign` (`product_id`),
  KEY `price_approvals_requested_by_foreign` (`requested_by`),
  KEY `price_approvals_approved_by_foreign` (`approved_by`),
  CONSTRAINT `price_approvals_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  CONSTRAINT `price_approvals_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `sales_products` (`id`) ON DELETE CASCADE,
  CONSTRAINT `price_approvals_requested_by_foreign` FOREIGN KEY (`requested_by`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `price_segment`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `price_segment` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `price_id` bigint unsigned NOT NULL,
  `segment` enum('wholesale','retail','vip') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'wholesale',
  `company_id` bigint unsigned DEFAULT NULL,
  `is_main_price` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `price_segment_segment_index` (`segment`),
  KEY `price_segment_company_id_index` (`company_id`),
  KEY `price_segment_price_id_index` (`price_id`),
  KEY `price_segment_segment_is_main_price_index` (`segment`,`is_main_price`),
  CONSTRAINT `price_segment_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `price_segment_price_id_foreign` FOREIGN KEY (`price_id`) REFERENCES `sales_product_prices` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `procurement_purchase_orders`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `procurement_purchase_orders` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `slug` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  `order_number` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `valley_id` bigint unsigned DEFAULT NULL,
  `order_type` tinyint(1) NOT NULL DEFAULT '0',
  `product_id` bigint unsigned DEFAULT NULL,
  `load_price` decimal(8,2) NOT NULL,
  `transport_price` decimal(8,2) NOT NULL DEFAULT '0.00',
  `date` date NOT NULL,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `product_amount` double NOT NULL,
  `in_accounting` tinyint(1) NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `currency_code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `exchange_rate` double NOT NULL DEFAULT '1',
  PRIMARY KEY (`id`),
  KEY `procurement_purchase_orders_company_id_foreign` (`company_id`),
  KEY `procurement_purchase_orders_user_id_foreign` (`user_id`),
  KEY `procurement_purchase_orders_valley_id_foreign` (`valley_id`),
  KEY `procurement_purchase_orders_product_id_foreign` (`product_id`),
  CONSTRAINT `procurement_purchase_orders_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `procurement_purchase_orders_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `sales_products` (`id`) ON DELETE SET NULL,
  CONSTRAINT `procurement_purchase_orders_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `procurement_purchase_orders_valley_id_foreign` FOREIGN KEY (`valley_id`) REFERENCES `valleys` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `product_guides`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `product_guides` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `product_guides_company_id_foreign` (`company_id`),
  CONSTRAINT `product_guides_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `product_price_histories`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `product_price_histories` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `product_id` bigint unsigned NOT NULL,
  `unit_id` bigint unsigned DEFAULT NULL,
  `old_selling_price` decimal(15,2) DEFAULT NULL,
  `new_selling_price` decimal(15,2) NOT NULL,
  `old_purchasing_price` decimal(15,2) DEFAULT NULL,
  `new_purchasing_price` decimal(15,2) NOT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `product_price_histories_product_id_foreign` (`product_id`),
  KEY `product_price_histories_unit_id_foreign` (`unit_id`),
  KEY `product_price_histories_user_id_foreign` (`user_id`),
  CONSTRAINT `product_price_histories_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `sales_products` (`id`) ON DELETE CASCADE,
  CONSTRAINT `product_price_histories_unit_id_foreign` FOREIGN KEY (`unit_id`) REFERENCES `measurement_units` (`id`),
  CONSTRAINT `product_price_histories_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `product_stores`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `product_stores` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `store_id` bigint unsigned DEFAULT NULL,
  `amount` double NOT NULL,
  `price` double NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT 'product',
  `product_id` int NOT NULL,
  PRIMARY KEY (`id`),
  KEY `store_id_index_fk` (`store_id`),
  KEY `company_store_index` (`company_id`,`store_id`),
  KEY `product_stores_company_id_type_index` (`company_id`,`type`),
  KEY `product_stores_company_id_product_id_index` (`company_id`,`product_id`),
  KEY `product_stores_product_id_index` (`product_id`),
  CONSTRAINT `company_id_index_fk` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `store_id_index_fk` FOREIGN KEY (`store_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `project_clause_equipment`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `project_clause_equipment` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `project_id` bigint unsigned NOT NULL,
  `project_phase_id` bigint unsigned NOT NULL,
  `project_clause_id` bigint unsigned NOT NULL,
  `equipment_id` bigint unsigned NOT NULL,
  `duration_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `duration` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `rent_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `unit_price` double DEFAULT NULL,
  `qty` double DEFAULT NULL,
  `total` double NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `project_clause_equipment_project_id_foreign` (`project_id`),
  KEY `project_clause_equipment_project_phase_id_foreign` (`project_phase_id`),
  KEY `project_clause_equipment_project_clause_id_foreign` (`project_clause_id`),
  KEY `project_clause_equipment_equipment_id_foreign` (`equipment_id`),
  CONSTRAINT `project_clause_equipment_equipment_id_foreign` FOREIGN KEY (`equipment_id`) REFERENCES `equipment` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `project_clause_equipment_project_clause_id_foreign` FOREIGN KEY (`project_clause_id`) REFERENCES `project_clauses` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `project_clause_equipment_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE,
  CONSTRAINT `project_clause_equipment_project_phase_id_foreign` FOREIGN KEY (`project_phase_id`) REFERENCES `project_phases` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `project_clause_materials`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `project_clause_materials` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `project_id` bigint unsigned NOT NULL,
  `project_phase_id` bigint unsigned NOT NULL,
  `project_clause_id` bigint unsigned NOT NULL,
  `material_id` bigint unsigned NOT NULL,
  `price` double NOT NULL,
  `qty` int NOT NULL,
  `total` double NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `project_clause_materials_project_id_foreign` (`project_id`),
  KEY `project_clause_materials_project_phase_id_foreign` (`project_phase_id`),
  KEY `project_clause_materials_project_clause_id_foreign` (`project_clause_id`),
  KEY `project_clause_materials_material_id_foreign` (`material_id`),
  CONSTRAINT `project_clause_materials_material_id_foreign` FOREIGN KEY (`material_id`) REFERENCES `materials` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `project_clause_materials_project_clause_id_foreign` FOREIGN KEY (`project_clause_id`) REFERENCES `project_clauses` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `project_clause_materials_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE,
  CONSTRAINT `project_clause_materials_project_phase_id_foreign` FOREIGN KEY (`project_phase_id`) REFERENCES `project_phases` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `project_clause_workers`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `project_clause_workers` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `project_id` bigint unsigned NOT NULL,
  `project_phase_id` bigint unsigned NOT NULL,
  `project_clause_id` bigint unsigned NOT NULL,
  `worker_id` bigint unsigned NOT NULL,
  `worker_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `qty` int NOT NULL,
  `fixed_salary` double DEFAULT NULL,
  `per_day_salary` double DEFAULT NULL,
  `duration_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `duration` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `total` double NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `project_clause_workers_project_id_foreign` (`project_id`),
  KEY `project_clause_workers_project_phase_id_foreign` (`project_phase_id`),
  KEY `project_clause_workers_project_clause_id_foreign` (`project_clause_id`),
  KEY `project_clause_workers_worker_id_foreign` (`worker_id`),
  CONSTRAINT `project_clause_workers_project_clause_id_foreign` FOREIGN KEY (`project_clause_id`) REFERENCES `project_clauses` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `project_clause_workers_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE,
  CONSTRAINT `project_clause_workers_project_phase_id_foreign` FOREIGN KEY (`project_phase_id`) REFERENCES `project_phases` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `project_clause_workers_worker_id_foreign` FOREIGN KEY (`worker_id`) REFERENCES `workers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `project_clauses`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `project_clauses` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `project_id` bigint unsigned NOT NULL,
  `project_phase_id` bigint unsigned NOT NULL,
  `clauses_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `project_clauses_project_id_foreign` (`project_id`),
  KEY `project_clauses_project_phase_id_foreign` (`project_phase_id`),
  CONSTRAINT `project_clauses_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE,
  CONSTRAINT `project_clauses_project_phase_id_foreign` FOREIGN KEY (`project_phase_id`) REFERENCES `project_phases` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `project_entities`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `project_entities` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `color` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `project_entity_user`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `project_entity_user` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `project_entity_id` bigint unsigned NOT NULL,
  `user_id` bigint unsigned NOT NULL,
  `is_favorite` tinyint(1) NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `project_entity_user_project_entity_id_user_id_unique` (`project_entity_id`,`user_id`),
  KEY `project_entity_user_user_id_foreign` (`user_id`),
  CONSTRAINT `project_entity_user_project_entity_id_foreign` FOREIGN KEY (`project_entity_id`) REFERENCES `project_entities` (`id`) ON DELETE CASCADE,
  CONSTRAINT `project_entity_user_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `project_files`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `project_files` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `project_id` bigint unsigned NOT NULL,
  `project_folder_id` bigint unsigned NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `project_files_project_id_foreign` (`project_id`),
  KEY `project_files_project_folder_id_foreign` (`project_folder_id`),
  CONSTRAINT `project_files_project_folder_id_foreign` FOREIGN KEY (`project_folder_id`) REFERENCES `project_folders` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `project_files_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `project_folders`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `project_folders` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `project_id` bigint unsigned NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `project_folders_project_id_foreign` (`project_id`),
  CONSTRAINT `project_folders_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `project_phases`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `project_phases` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `total_cost` decimal(15,2) DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  `project_id` bigint unsigned DEFAULT NULL,
  `start_at` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `end_at` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `total_vat` decimal(10,2) DEFAULT NULL,
  `total_profit` decimal(10,2) DEFAULT NULL,
  `total_error` decimal(10,2) DEFAULT NULL,
  `template_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `project_phases_company_id_foreign` (`company_id`),
  KEY `project_phases_project_id_foreign` (`project_id`),
  KEY `project_phases_template_id_foreign` (`template_id`),
  CONSTRAINT `project_phases_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `project_phases_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `project_phases_template_id_foreign` FOREIGN KEY (`template_id`) REFERENCES `templates` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `project_types`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `project_types` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `title` json DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `project_user`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `project_user` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `project_id` bigint unsigned NOT NULL,
  `user_id` bigint unsigned NOT NULL,
  `role` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `project_user_project_id_foreign` (`project_id`),
  KEY `project_user_user_id_foreign` (`user_id`),
  CONSTRAINT `project_user_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `project_user_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `projects`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `projects` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `project_number` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `project_status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `start_date` date NOT NULL,
  `end_date` date NOT NULL,
  `address` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `main_contractor_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `main_project_id` bigint unsigned DEFAULT NULL,
  `contract_file` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `contract_duration` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `contract_value` decimal(10,2) DEFAULT NULL,
  `contract_conditions` text COLLATE utf8mb4_unicode_ci,
  `contract_start_date` date DEFAULT NULL,
  `contract_end_date` date DEFAULT NULL,
  `has_study` tinyint(1) NOT NULL DEFAULT '0',
  `project_type_id` bigint unsigned DEFAULT NULL,
  `client_id` bigint unsigned DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `account_id` bigint unsigned DEFAULT NULL,
  `currency_code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `exchange_rate` double NOT NULL DEFAULT '1',
  `contract_number` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `contract_description` text COLLATE utf8mb4_unicode_ci,
  `estimated_duration` int DEFAULT NULL,
  `time_unit` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `total_budget` decimal(15,2) DEFAULT NULL,
  `checklists` json DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `projects_main_project_id_unique` (`main_project_id`),
  KEY `projects_company_id_foreign` (`company_id`),
  KEY `projects_main_contractor_id_foreign` (`main_contractor_id`),
  KEY `projects_project_type_id_foreign` (`project_type_id`),
  KEY `projects_client_id_foreign` (`client_id`),
  KEY `projects_account_id_foreign` (`account_id`),
  KEY `projects_project_status_index` (`project_status`),
  KEY `projects_start_date_end_date_index` (`start_date`,`end_date`),
  CONSTRAINT `projects_account_id_foreign` FOREIGN KEY (`account_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `projects_client_id_foreign` FOREIGN KEY (`client_id`) REFERENCES `sales_clients` (`id`) ON DELETE CASCADE,
  CONSTRAINT `projects_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `projects_main_contractor_id_foreign` FOREIGN KEY (`main_contractor_id`) REFERENCES `main_contractors` (`id`) ON DELETE SET NULL,
  CONSTRAINT `projects_main_project_id_foreign` FOREIGN KEY (`main_project_id`) REFERENCES `main_projects` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `projects_project_type_id_foreign` FOREIGN KEY (`project_type_id`) REFERENCES `project_types` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `proposal_comments`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `proposal_comments` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned DEFAULT NULL,
  `proposal_id` bigint unsigned DEFAULT NULL,
  `content` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `proposal_comments_company_id_foreign` (`company_id`),
  KEY `proposal_comments_proposal_id_foreign` (`proposal_id`),
  CONSTRAINT `proposal_comments_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `proposal_comments_proposal_id_foreign` FOREIGN KEY (`proposal_id`) REFERENCES `proposals` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `proposals`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `proposals` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `client_id` bigint unsigned DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `issue_date` date DEFAULT NULL,
  `expiry_date` date DEFAULT NULL,
  `products` json NOT NULL,
  `sub_total` double NOT NULL,
  `discount_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `discount_value` double DEFAULT NULL,
  `discount` double NOT NULL DEFAULT '0',
  `total` double NOT NULL,
  `currency` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `exchange_rate` double NOT NULL,
  `tax_id` bigint unsigned DEFAULT NULL,
  `tax_value` double NOT NULL,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `status` enum('draft','sent','approved','rejected','expired') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'draft',
  `template_config` json DEFAULT NULL,
  `additional_fields` json DEFAULT NULL,
  `bank_account_id` bigint unsigned DEFAULT NULL,
  `encrypted_link` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `pin_code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `rejected_reason` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `proposals_company_id_foreign` (`company_id`),
  KEY `proposals_client_id_foreign` (`client_id`),
  KEY `proposals_tax_id_foreign` (`tax_id`),
  KEY `proposals_bank_account_id_foreign` (`bank_account_id`),
  CONSTRAINT `proposals_bank_account_id_foreign` FOREIGN KEY (`bank_account_id`) REFERENCES `bank_accounts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `proposals_client_id_foreign` FOREIGN KEY (`client_id`) REFERENCES `sales_clients` (`id`) ON DELETE SET NULL,
  CONSTRAINT `proposals_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `proposals_tax_id_foreign` FOREIGN KEY (`tax_id`) REFERENCES `taxes` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `purchase_order_contracts`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `purchase_order_contracts` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `title` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `reference_number` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `purchase_order_id` bigint unsigned NOT NULL,
  `supplier_id` bigint unsigned NOT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  `content` json NOT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'draft',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `purchase_order_supplier_id` bigint unsigned DEFAULT NULL,
  `old_versions` json DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `purchase_order_contracts_purchase_order_id_foreign` (`purchase_order_id`),
  KEY `purchase_order_contracts_supplier_id_foreign` (`supplier_id`),
  KEY `purchase_order_contracts_company_id_foreign` (`company_id`),
  KEY `purchase_order_contracts_purchase_order_supplier_id_foreign` (`purchase_order_supplier_id`),
  CONSTRAINT `purchase_order_contracts_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `purchase_order_contracts_purchase_order_id_foreign` FOREIGN KEY (`purchase_order_id`) REFERENCES `purchase_orders` (`id`) ON DELETE CASCADE,
  CONSTRAINT `purchase_order_contracts_purchase_order_supplier_id_foreign` FOREIGN KEY (`purchase_order_supplier_id`) REFERENCES `purchase_order_supplier` (`id`) ON DELETE CASCADE,
  CONSTRAINT `purchase_order_contracts_supplier_id_foreign` FOREIGN KEY (`supplier_id`) REFERENCES `sales_suppliers` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `purchase_order_drivers`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `purchase_order_drivers` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned DEFAULT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `purchase_order_id` bigint unsigned DEFAULT NULL,
  `load_count` double NOT NULL,
  `accepted_loads_count` double DEFAULT NULL,
  `driver_id` bigint unsigned DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'new',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `purchase_order_drivers_company_id_foreign` (`company_id`),
  KEY `purchase_order_drivers_user_id_foreign` (`user_id`),
  KEY `purchase_order_drivers_purchase_order_id_foreign` (`purchase_order_id`),
  KEY `purchase_order_drivers_driver_id_foreign` (`driver_id`),
  CONSTRAINT `purchase_order_drivers_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `purchase_order_drivers_driver_id_foreign` FOREIGN KEY (`driver_id`) REFERENCES `drivers` (`id`) ON DELETE SET NULL,
  CONSTRAINT `purchase_order_drivers_purchase_order_id_foreign` FOREIGN KEY (`purchase_order_id`) REFERENCES `procurement_purchase_orders` (`id`) ON DELETE SET NULL,
  CONSTRAINT `purchase_order_drivers_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `purchase_order_supplier`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `purchase_order_supplier` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `purchase_order_id` bigint unsigned NOT NULL,
  `supplier_id` bigint unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `can_deliver_on_time` tinyint(1) NOT NULL DEFAULT '0',
  `total_cost` double NOT NULL DEFAULT '0',
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `status_reason` text COLLATE utf8mb4_unicode_ci,
  `company_id` bigint unsigned DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `purchase_order_supplier_purchase_order_id_foreign` (`purchase_order_id`),
  KEY `purchase_order_supplier_supplier_id_foreign` (`supplier_id`),
  KEY `purchase_order_supplier_company_id_foreign` (`company_id`),
  CONSTRAINT `purchase_order_supplier_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `purchase_order_supplier_purchase_order_id_foreign` FOREIGN KEY (`purchase_order_id`) REFERENCES `purchase_orders` (`id`) ON DELETE CASCADE,
  CONSTRAINT `purchase_order_supplier_supplier_id_foreign` FOREIGN KEY (`supplier_id`) REFERENCES `sales_suppliers` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `purchase_order_vehicles`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `purchase_order_vehicles` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned DEFAULT NULL,
  `purchase_order_id` bigint unsigned DEFAULT NULL,
  `driver_id` bigint unsigned DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `weight` double DEFAULT NULL,
  `image` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `upload_at` datetime DEFAULT NULL,
  `payed` decimal(8,2) NOT NULL DEFAULT '0.00',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `confirmed` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `purchase_order_vehicles_company_id_foreign` (`company_id`),
  KEY `purchase_order_vehicles_purchase_order_id_foreign` (`purchase_order_id`),
  KEY `purchase_order_vehicles_driver_id_foreign` (`driver_id`),
  CONSTRAINT `purchase_order_vehicles_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `purchase_order_vehicles_driver_id_foreign` FOREIGN KEY (`driver_id`) REFERENCES `drivers` (`id`) ON DELETE SET NULL,
  CONSTRAINT `purchase_order_vehicles_purchase_order_id_foreign` FOREIGN KEY (`purchase_order_id`) REFERENCES `procurement_purchase_orders` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `purchase_orders`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `purchase_orders` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `project_id` bigint unsigned DEFAULT NULL,
  `department` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `product_id` int NOT NULL,
  `quantity` double NOT NULL,
  `description` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `purpose` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `delivery_date` date DEFAULT NULL,
  `company_id` bigint unsigned NOT NULL,
  `project_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `project_phase_id` bigint unsigned DEFAULT NULL,
  `item_phase_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `unit_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `purchase_orders_project_id_foreign` (`project_id`),
  KEY `purchase_orders_company_id_foreign` (`company_id`),
  KEY `purchase_orders_project_phase_id_foreign` (`project_phase_id`),
  KEY `purchase_orders_item_phase_id_foreign` (`item_phase_id`),
  KEY `purchase_orders_product_id_index` (`product_id`),
  KEY `purchase_orders_unit_id_foreign` (`unit_id`),
  CONSTRAINT `purchase_orders_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `purchase_orders_item_phase_id_foreign` FOREIGN KEY (`item_phase_id`) REFERENCES `item_phases` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `purchase_orders_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `purchase_orders_project_phase_id_foreign` FOREIGN KEY (`project_phase_id`) REFERENCES `project_phases` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `purchase_orders_unit_id_foreign` FOREIGN KEY (`unit_id`) REFERENCES `measurement_units` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `purchase_products`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `purchase_products` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `purchase_id` bigint unsigned NOT NULL,
  `user_id` bigint unsigned NOT NULL,
  `store_id` bigint unsigned DEFAULT NULL,
  `product_store_id` bigint unsigned DEFAULT NULL,
  `quantity` double NOT NULL,
  `unit_price` double NOT NULL,
  `price` double NOT NULL,
  `discount_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `discount_value` double DEFAULT NULL,
  `discount` double NOT NULL DEFAULT '0',
  `total` double NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `tax_id` bigint unsigned DEFAULT NULL,
  `tax_value` double NOT NULL DEFAULT '0',
  `tax_rate` double NOT NULL DEFAULT '0',
  `unit_id` bigint unsigned DEFAULT NULL,
  `category` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `product_id` int NOT NULL,
  `is_product_unit` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `purchase_products_purchase_id_foreign` (`purchase_id`),
  KEY `purchase_products_user_id_foreign` (`user_id`),
  KEY `purchase_products_store_id_foreign` (`store_id`),
  KEY `purchase_products_product_store_id_foreign` (`product_store_id`),
  KEY `purchase_products_tax_id_foreign` (`tax_id`),
  KEY `purchase_products_unit_id_foreign` (`unit_id`),
  KEY `purchase_products_product_id_index` (`product_id`),
  CONSTRAINT `purchase_products_product_store_id_foreign` FOREIGN KEY (`product_store_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `purchase_products_purchase_id_foreign` FOREIGN KEY (`purchase_id`) REFERENCES `purchases` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `purchase_products_store_id_foreign` FOREIGN KEY (`store_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `purchase_products_tax_id_foreign` FOREIGN KEY (`tax_id`) REFERENCES `taxes` (`id`) ON DELETE SET NULL,
  CONSTRAINT `purchase_products_unit_id_foreign` FOREIGN KEY (`unit_id`) REFERENCES `measurement_units` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `purchase_products_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `purchase_taxes`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `purchase_taxes` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `purchase_id` bigint unsigned NOT NULL,
  `tax_id` bigint unsigned NOT NULL,
  `rate` double NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `purchase_taxes_purchase_id_foreign` (`purchase_id`),
  KEY `purchase_taxes_tax_id_foreign` (`tax_id`),
  CONSTRAINT `purchase_taxes_purchase_id_foreign` FOREIGN KEY (`purchase_id`) REFERENCES `purchases` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `purchase_taxes_tax_id_foreign` FOREIGN KEY (`tax_id`) REFERENCES `taxes` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `purchases`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `purchases` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `user_id` bigint unsigned NOT NULL,
  `supplier_id` bigint unsigned DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `date` date NOT NULL,
  `due_after` date DEFAULT NULL,
  `received_date` datetime DEFAULT NULL,
  `custom_field_header` json DEFAULT NULL,
  `store_id` bigint unsigned DEFAULT NULL,
  `currency` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `exchange_rate` double NOT NULL,
  `sub_total` double NOT NULL,
  `discount_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `discount_value` double DEFAULT NULL,
  `discount` double NOT NULL DEFAULT '0',
  `total` double NOT NULL,
  `payed` double NOT NULL DEFAULT '0',
  `shipping_amount` double NOT NULL,
  `tags` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Purchase',
  `cost_center_id` bigint unsigned DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `tax_id` bigint unsigned DEFAULT NULL,
  `payment_method` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `transfer_number` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `transfer_date` date DEFAULT NULL,
  `account_number` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `transfer_amount` decimal(18,2) DEFAULT NULL,
  `cash_account` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `transfer_account` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `purchase_order_contract_id` bigint unsigned DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `purchase_order_supplier_id` bigint unsigned DEFAULT NULL,
  `e_signature_id` bigint unsigned DEFAULT NULL,
  `checklists` json DEFAULT NULL,
  `custom_template` json DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `purchases_company_id_index` (`company_id`),
  KEY `purchases_user_id_index` (`user_id`),
  KEY `purchases_supplier_id_index` (`supplier_id`),
  KEY `purchases_store_id_index` (`store_id`),
  KEY `purchases_cost_center_id_index` (`cost_center_id`),
  KEY `purchases_code_index` (`code`),
  KEY `purchases_date_index` (`date`),
  KEY `purchases_due_after_index` (`due_after`),
  KEY `purchases_received_date_index` (`received_date`),
  KEY `purchases_type_index` (`type`),
  KEY `purchases_currency_index` (`currency`),
  KEY `purchases_total_index` (`total`),
  KEY `purchases_payed_index` (`payed`),
  KEY `purchases_discount_index` (`discount`),
  KEY `purchases_company_id_date_index` (`company_id`,`date`),
  KEY `purchases_supplier_id_date_index` (`supplier_id`,`date`),
  KEY `purchases_type_date_index` (`type`,`date`),
  KEY `purchases_company_id_type_date_index` (`company_id`,`type`,`date`),
  KEY `purchases_deleted_at_index` (`deleted_at`),
  KEY `purchases_tax_id_foreign` (`tax_id`),
  KEY `purchases_purchase_order_contract_id_foreign` (`purchase_order_contract_id`),
  KEY `purchases_purchase_order_supplier_id_foreign` (`purchase_order_supplier_id`),
  KEY `purchases_e_signature_id_foreign` (`e_signature_id`),
  CONSTRAINT `purchases_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `purchases_cost_center_id_foreign` FOREIGN KEY (`cost_center_id`) REFERENCES `cost_centers` (`id`) ON DELETE SET NULL,
  CONSTRAINT `purchases_e_signature_id_foreign` FOREIGN KEY (`e_signature_id`) REFERENCES `e_signatures` (`id`) ON DELETE SET NULL,
  CONSTRAINT `purchases_purchase_order_contract_id_foreign` FOREIGN KEY (`purchase_order_contract_id`) REFERENCES `purchase_order_contracts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `purchases_purchase_order_supplier_id_foreign` FOREIGN KEY (`purchase_order_supplier_id`) REFERENCES `purchase_order_supplier` (`id`) ON DELETE CASCADE,
  CONSTRAINT `purchases_store_id_foreign` FOREIGN KEY (`store_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE CASCADE,
  CONSTRAINT `purchases_supplier_id_foreign` FOREIGN KEY (`supplier_id`) REFERENCES `sales_suppliers` (`id`) ON DELETE SET NULL,
  CONSTRAINT `purchases_tax_id_foreign` FOREIGN KEY (`tax_id`) REFERENCES `taxes` (`id`) ON DELETE SET NULL,
  CONSTRAINT `purchases_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `quotations`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `quotations` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `project_id` bigint unsigned NOT NULL,
  `supplier_id` bigint unsigned NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `item_type` enum('material','equipment') COLLATE utf8mb4_unicode_ci NOT NULL,
  `material_id` bigint unsigned DEFAULT NULL,
  `equipment_id` bigint unsigned DEFAULT NULL,
  `quotation_duration` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `expiry_date` date DEFAULT NULL,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending' COMMENT 'pending, approved, rejected',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `unit` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `items` json DEFAULT NULL,
  `currency_code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `exchange_rate` double NOT NULL DEFAULT '1',
  `company_id` bigint unsigned DEFAULT NULL,
  `e_signature_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `quotations_material_id_foreign` (`material_id`),
  KEY `quotations_equipment_id_foreign` (`equipment_id`),
  KEY `quotations_project_id_index` (`project_id`),
  KEY `quotations_supplier_id_index` (`supplier_id`),
  KEY `quotations_item_type_index` (`item_type`),
  KEY `quotations_status_index` (`status`),
  KEY `quotations_company_id_foreign` (`company_id`),
  KEY `quotations_e_signature_id_foreign` (`e_signature_id`),
  CONSTRAINT `quotations_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `quotations_e_signature_id_foreign` FOREIGN KEY (`e_signature_id`) REFERENCES `e_signatures` (`id`) ON DELETE SET NULL,
  CONSTRAINT `quotations_equipment_id_foreign` FOREIGN KEY (`equipment_id`) REFERENCES `equipment` (`id`) ON DELETE CASCADE,
  CONSTRAINT `quotations_material_id_foreign` FOREIGN KEY (`material_id`) REFERENCES `materials` (`id`) ON DELETE CASCADE,
  CONSTRAINT `quotations_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE,
  CONSTRAINT `quotations_supplier_id_foreign` FOREIGN KEY (`supplier_id`) REFERENCES `sales_suppliers` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `receive_purchase_orders`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `receive_purchase_orders` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned DEFAULT NULL,
  `purchase_order_id` bigint unsigned NOT NULL,
  `purchase_id` bigint unsigned NOT NULL,
  `receive_date` date NOT NULL,
  `quantity` int NOT NULL,
  `status` enum('pending','approved','rejected') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `receive_purchase_orders_company_id_foreign` (`company_id`),
  KEY `receive_purchase_orders_purchase_order_id_foreign` (`purchase_order_id`),
  KEY `receive_purchase_orders_purchase_id_foreign` (`purchase_id`),
  CONSTRAINT `receive_purchase_orders_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `receive_purchase_orders_purchase_id_foreign` FOREIGN KEY (`purchase_id`) REFERENCES `purchases` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `receive_purchase_orders_purchase_order_id_foreign` FOREIGN KEY (`purchase_order_id`) REFERENCES `purchase_orders` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `reminders`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `reminders` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `remindable_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `remindable_id` bigint unsigned NOT NULL,
  `message` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `channel` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'active',
  `user_id` bigint unsigned DEFAULT NULL,
  `due_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `reminders_remindable_type_remindable_id_index` (`remindable_type`,`remindable_id`),
  KEY `reminders_user_id_foreign` (`user_id`),
  CONSTRAINT `reminders_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `rental_contract_types`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `rental_contract_types` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `rental_contract_types_name_unique` (`name`),
  KEY `rental_contract_types_company_id_foreign` (`company_id`),
  CONSTRAINT `rental_contract_types_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `rental_contracts`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `rental_contracts` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `project_id` bigint unsigned DEFAULT NULL,
  `supplier_id` bigint unsigned DEFAULT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `start_date` date DEFAULT NULL,
  `end_date` date DEFAULT NULL,
  `payment_method` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `custom_terms` json DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT 'active',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `internal_contract_number` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `deposit_amount` decimal(10,2) DEFAULT NULL,
  `deposit_refundable` tinyint(1) DEFAULT NULL,
  `deposit_refund_due_date` date DEFAULT NULL,
  `insurance_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `insurance_company` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `insurance_policy_number` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `insurance_coverage_start_date` date DEFAULT NULL,
  `insurance_coverage_end_date` date DEFAULT NULL,
  `insurance_coverage_details` text COLLATE utf8mb4_unicode_ci,
  `insurance_coverage_level` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `liability_responsibility` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `maintenance_responsibility` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `damage_procedure` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `rental_contract_type_id` bigint unsigned DEFAULT NULL,
  `contract_title` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `contract_introduction` text COLLATE utf8mb4_unicode_ci,
  `contract_subject` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `is_renewable` tinyint(1) NOT NULL DEFAULT '0',
  `rights_and_obligations` text COLLATE utf8mb4_unicode_ci,
  PRIMARY KEY (`id`),
  KEY `rental_contracts_project_id_foreign` (`project_id`),
  KEY `rental_contracts_supplier_id_foreign` (`supplier_id`),
  KEY `rental_contracts_status_index` (`status`),
  KEY `rental_contracts_start_date_index` (`start_date`),
  KEY `rental_contracts_end_date_index` (`end_date`),
  KEY `rental_contracts_rental_contract_type_id_foreign` (`rental_contract_type_id`),
  CONSTRAINT `rental_contracts_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE,
  CONSTRAINT `rental_contracts_rental_contract_type_id_foreign` FOREIGN KEY (`rental_contract_type_id`) REFERENCES `rental_contract_types` (`id`) ON DELETE SET NULL,
  CONSTRAINT `rental_contracts_supplier_id_foreign` FOREIGN KEY (`supplier_id`) REFERENCES `sales_suppliers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `rental_items`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `rental_items` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `rental_contract_id` bigint unsigned NOT NULL,
  `item_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `quantity` int DEFAULT NULL,
  `unit_price` decimal(10,2) DEFAULT NULL,
  `rental_unit` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `item_start_date` date DEFAULT NULL,
  `item_end_date` date DEFAULT NULL,
  `equipment_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `rental_items_rental_contract_id_foreign` (`rental_contract_id`),
  KEY `rental_items_equipment_id_foreign` (`equipment_id`),
  CONSTRAINT `rental_items_equipment_id_foreign` FOREIGN KEY (`equipment_id`) REFERENCES `equipment` (`id`) ON DELETE CASCADE,
  CONSTRAINT `rental_items_rental_contract_id_foreign` FOREIGN KEY (`rental_contract_id`) REFERENCES `rental_contracts` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `rental_payments`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `rental_payments` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `rental_contract_id` bigint unsigned NOT NULL,
  `amount` decimal(10,2) NOT NULL,
  `due_date` date NOT NULL,
  `paid_date` date DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `rental_payments_rental_contract_id_foreign` (`rental_contract_id`),
  CONSTRAINT `rental_payments_rental_contract_id_foreign` FOREIGN KEY (`rental_contract_id`) REFERENCES `rental_contracts` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `revenues`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `revenues` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `project_id` bigint unsigned NOT NULL,
  `item_phase_id` bigint unsigned DEFAULT NULL,
  `revenue_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `amount` decimal(10,2) NOT NULL,
  `received_date` date DEFAULT NULL,
  `payment_method` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` enum('pending','received') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  `project_phase_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `revenues_item_phase_id_foreign` (`item_phase_id`),
  KEY `revenues_revenue_type_index` (`revenue_type`),
  KEY `revenues_status_index` (`status`),
  KEY `revenues_received_date_index` (`received_date`),
  KEY `revenues_project_id_status_index` (`project_id`,`status`),
  KEY `revenues_company_id_foreign` (`company_id`),
  KEY `revenues_project_phase_id_foreign` (`project_phase_id`),
  CONSTRAINT `revenues_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `revenues_item_phase_id_foreign` FOREIGN KEY (`item_phase_id`) REFERENCES `item_phases` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `revenues_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE,
  CONSTRAINT `revenues_project_phase_id_foreign` FOREIGN KEY (`project_phase_id`) REFERENCES `project_phases` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `rewards_and_penalties`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `rewards_and_penalties` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `rewardable_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `rewardable_id` bigint unsigned DEFAULT NULL,
  `creator_id` bigint unsigned DEFAULT NULL,
  `related_user_id` bigint unsigned DEFAULT NULL,
  `type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `reason` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `amount` decimal(8,2) NOT NULL DEFAULT '0.00',
  `date` date NOT NULL,
  `is_collected` tinyint(1) NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `month_salary_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `rewards_and_penalties_rewardable_type_rewardable_id_index` (`rewardable_type`,`rewardable_id`),
  KEY `rewards_and_penalties_related_user_id_foreign` (`related_user_id`),
  KEY `rewards_and_penalties_type_index` (`type`),
  KEY `rewards_and_penalties_date_index` (`date`),
  KEY `rewards_and_penalties_is_collected_index` (`is_collected`),
  KEY `rewards_and_penalties_creator_id_related_user_id_index` (`creator_id`,`related_user_id`),
  KEY `rewards_and_penalties_company_id_foreign` (`company_id`),
  KEY `rewards_and_penalties_month_salary_id_foreign` (`month_salary_id`),
  CONSTRAINT `rewards_and_penalties_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `rewards_and_penalties_creator_id_foreign` FOREIGN KEY (`creator_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `rewards_and_penalties_month_salary_id_foreign` FOREIGN KEY (`month_salary_id`) REFERENCES `month_salaries` (`id`) ON DELETE CASCADE,
  CONSTRAINT `rewards_and_penalties_related_user_id_foreign` FOREIGN KEY (`related_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `role_has_permissions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `role_has_permissions` (
  `permission_id` bigint unsigned NOT NULL,
  `role_id` bigint unsigned NOT NULL,
  PRIMARY KEY (`permission_id`,`role_id`),
  KEY `role_has_permissions_role_id_foreign` (`role_id`),
  CONSTRAINT `role_has_permissions_permission_id_foreign` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE CASCADE,
  CONSTRAINT `role_has_permissions_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `roles`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `roles` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `guard_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `title` json NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `section` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'accounting',
  PRIMARY KEY (`id`),
  UNIQUE KEY `roles_name_guard_name_unique` (`name`,`guard_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `safety_incidents`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `safety_incidents` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `daily_record_id` bigint unsigned NOT NULL,
  `type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `details` text COLLATE utf8mb4_unicode_ci,
  `actions_taken` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'draft',
  `approved_by` bigint unsigned DEFAULT NULL,
  `approval_date` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `safety_incidents_daily_record_id_foreign` (`daily_record_id`),
  KEY `safety_incidents_approved_by_foreign` (`approved_by`),
  CONSTRAINT `safety_incidents_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
  CONSTRAINT `safety_incidents_daily_record_id_foreign` FOREIGN KEY (`daily_record_id`) REFERENCES `daily_records` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `sales_clients`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `sales_clients` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `account_id` bigint unsigned DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `trade_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `currency_code` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `balance` double NOT NULL DEFAULT '0',
  `status` tinyint(1) NOT NULL DEFAULT '0',
  `first_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `second_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `phone` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `street_address` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `city` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `region` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `postal_code` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `country` varchar(40) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `vat_number` varchar(40) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `national_number` varchar(40) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `website` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `location` json DEFAULT NULL,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `locale` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `section_state_id` bigint unsigned DEFAULT NULL,
  `type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'main_contractor',
  `contract_status` enum('pending','active','completed','cancelled') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `main_client_id` bigint unsigned DEFAULT NULL,
  `section` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `device_token` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `slug` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `password` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `default_lang` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'en',
  `credit_limit` decimal(15,2) NOT NULL DEFAULT '0.00',
  `importance` enum('Medium','Low','High') COLLATE utf8mb4_unicode_ci DEFAULT 'Medium',
  `clients_account_id` bigint unsigned DEFAULT NULL,
  `segment` enum('wholesale','retail','vip') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'wholesale',
  `allow_deferred_sale` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `sales_clients_company_id_index` (`company_id`),
  KEY `sales_clients_user_id_index` (`user_id`),
  KEY `sales_clients_account_id_index` (`account_id`),
  KEY `sales_clients_code_index` (`code`),
  KEY `sales_clients_trade_name_index` (`trade_name`),
  KEY `sales_clients_currency_code_index` (`currency_code`),
  KEY `sales_clients_status_index` (`status`),
  KEY `sales_clients_email_index` (`email`),
  KEY `sales_clients_phone_index` (`phone`),
  KEY `sales_clients_deleted_at_index` (`deleted_at`),
  KEY `sales_clients_section_state_id_index` (`section_state_id`),
  KEY `sales_clients_type_index` (`type`),
  KEY `sales_clients_contract_status_index` (`contract_status`),
  KEY `sales_clients_main_client_id_index` (`main_client_id`),
  KEY `sales_clients_section_index` (`section`),
  KEY `sales_clients_device_token_index` (`device_token`),
  KEY `sales_clients_clients_account_id_foreign` (`clients_account_id`),
  CONSTRAINT `sales_clients_account_id_foreign` FOREIGN KEY (`account_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
  CONSTRAINT `sales_clients_clients_account_id_foreign` FOREIGN KEY (`clients_account_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `sales_clients_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `sales_clients_main_client_id_foreign` FOREIGN KEY (`main_client_id`) REFERENCES `sales_clients` (`id`) ON DELETE SET NULL,
  CONSTRAINT `sales_clients_section_state_id_foreign` FOREIGN KEY (`section_state_id`) REFERENCES `section_states` (`id`) ON DELETE RESTRICT,
  CONSTRAINT `sales_clients_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `sales_clients_contacts`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `sales_clients_contacts` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `client_id` bigint unsigned DEFAULT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `first_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `second_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `phone` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `sales_clients_contacts_client_id_foreign` (`client_id`),
  KEY `sales_clients_contacts_user_id_foreign` (`user_id`),
  CONSTRAINT `sales_clients_contacts_client_id_foreign` FOREIGN KEY (`client_id`) REFERENCES `sales_clients` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `sales_clients_contacts_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `sales_contracts`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `sales_contracts` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `preamble` text COLLATE utf8mb4_unicode_ci,
  `client_id` bigint unsigned NOT NULL,
  `project_id` bigint unsigned DEFAULT NULL,
  `contract_number` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `sign_date` date NOT NULL,
  `start_date` date NOT NULL,
  `end_date` date DEFAULT NULL,
  `type` enum('one_time_sale','recurring_supply','service') COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `items` json DEFAULT NULL,
  `payment_terms` json DEFAULT NULL,
  `warranty` json DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'draft',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `e_signature_id` bigint unsigned DEFAULT NULL,
  `product_items` json DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `old_versions` json DEFAULT NULL,
  `signature_status` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `pin` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `contract_title` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `contract_introduction` text COLLATE utf8mb4_unicode_ci,
  `contract_subject` text COLLATE utf8mb4_unicode_ci,
  `is_renewable` tinyint(1) NOT NULL DEFAULT '0',
  `rights_and_obligations` text COLLATE utf8mb4_unicode_ci,
  PRIMARY KEY (`id`),
  UNIQUE KEY `sales_contracts_contract_number_unique` (`contract_number`),
  UNIQUE KEY `sales_contracts_pin_unique` (`pin`),
  KEY `sales_contracts_client_id_foreign` (`client_id`),
  KEY `sales_contracts_project_id_foreign` (`project_id`),
  KEY `sales_contracts_e_signature_id_foreign` (`e_signature_id`),
  CONSTRAINT `sales_contracts_client_id_foreign` FOREIGN KEY (`client_id`) REFERENCES `sales_clients` (`id`) ON DELETE CASCADE,
  CONSTRAINT `sales_contracts_e_signature_id_foreign` FOREIGN KEY (`e_signature_id`) REFERENCES `e_signatures` (`id`) ON DELETE SET NULL,
  CONSTRAINT `sales_contracts_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `sales_invoice_products`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `sales_invoice_products` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `product_id` bigint unsigned DEFAULT NULL,
  `sale_invoice_id` bigint unsigned NOT NULL,
  `user_id` bigint unsigned NOT NULL,
  `store_id` bigint unsigned DEFAULT NULL,
  `product_store_id` bigint unsigned DEFAULT NULL,
  `unit_id` bigint unsigned NOT NULL,
  `quantity` double NOT NULL,
  `unit_price` double NOT NULL,
  `price` double NOT NULL,
  `discount_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `discount_value` double DEFAULT NULL,
  `discount` double NOT NULL DEFAULT '0',
  `total` double NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `tax_id` bigint unsigned DEFAULT NULL,
  `tax_value` double NOT NULL DEFAULT '0',
  `tax_rate` double NOT NULL DEFAULT '0',
  `purchasing_price` double NOT NULL DEFAULT '0',
  `selling_price` double NOT NULL DEFAULT '0',
  `profit_price` double NOT NULL DEFAULT '0',
  `company_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `sales_invoice_products_product_id_foreign` (`product_id`),
  KEY `sales_invoice_products_sale_invoice_id_foreign` (`sale_invoice_id`),
  KEY `sales_invoice_products_user_id_foreign` (`user_id`),
  KEY `sales_invoice_products_store_id_foreign` (`store_id`),
  KEY `sales_invoice_products_product_store_id_foreign` (`product_store_id`),
  KEY `sales_invoice_products_unit_id_foreign` (`unit_id`),
  KEY `sales_invoice_products_tax_id_foreign` (`tax_id`),
  KEY `sales_invoice_products_company_id_foreign` (`company_id`),
  CONSTRAINT `sales_invoice_products_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `sales_invoice_products_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `sales_products` (`id`) ON DELETE SET NULL,
  CONSTRAINT `sales_invoice_products_product_store_id_foreign` FOREIGN KEY (`product_store_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `sales_invoice_products_sale_invoice_id_foreign` FOREIGN KEY (`sale_invoice_id`) REFERENCES `sales_invoices` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `sales_invoice_products_store_id_foreign` FOREIGN KEY (`store_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `sales_invoice_products_tax_id_foreign` FOREIGN KEY (`tax_id`) REFERENCES `taxes` (`id`) ON DELETE SET NULL,
  CONSTRAINT `sales_invoice_products_unit_id_foreign` FOREIGN KEY (`unit_id`) REFERENCES `measurement_units` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `sales_invoice_products_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `sales_invoice_taxes`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `sales_invoice_taxes` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `sales_invoice_id` bigint unsigned NOT NULL,
  `tax_id` bigint unsigned NOT NULL,
  `rate` double NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `sales_invoice_taxes_sales_invoice_id_foreign` (`sales_invoice_id`),
  KEY `sales_invoice_taxes_tax_id_foreign` (`tax_id`),
  CONSTRAINT `sales_invoice_taxes_sales_invoice_id_foreign` FOREIGN KEY (`sales_invoice_id`) REFERENCES `sales_invoices` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `sales_invoice_taxes_tax_id_foreign` FOREIGN KEY (`tax_id`) REFERENCES `taxes` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `sales_invoices`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `sales_invoices` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `user_id` bigint unsigned NOT NULL,
  `marker_id` bigint unsigned DEFAULT NULL,
  `client_id` bigint unsigned DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `date` date NOT NULL,
  `due_after` date DEFAULT NULL,
  `received_date` datetime DEFAULT NULL,
  `custom_field_header` json DEFAULT NULL,
  `store_id` bigint unsigned DEFAULT NULL,
  `currency` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `exchange_rate` double NOT NULL,
  `sub_total` double NOT NULL,
  `discount_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `discount_value` double DEFAULT NULL,
  `discount` double NOT NULL DEFAULT '0',
  `total` double NOT NULL,
  `payed` double NOT NULL DEFAULT '0',
  `shipping_option` int DEFAULT NULL,
  `shipping_amount` double DEFAULT NULL,
  `shipping_address` json DEFAULT NULL,
  `tags` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Sales',
  `cost_center_id` bigint unsigned DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `tax_id` bigint unsigned DEFAULT NULL,
  `payment_method` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `transfer_number` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `transfer_date` date DEFAULT NULL,
  `account_number` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `transfer_amount` decimal(18,2) DEFAULT NULL,
  `cash_account` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `transfer_account` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `proposal_id` bigint unsigned DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `user_contract_id` bigint unsigned DEFAULT NULL,
  `checklists` json DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `sales_invoices_marker_id_foreign` (`marker_id`),
  KEY `sales_invoices_store_id_foreign` (`store_id`),
  KEY `sales_invoices_cost_center_id_foreign` (`cost_center_id`),
  KEY `sales_invoices_company_id_index` (`company_id`),
  KEY `sales_invoices_client_id_index` (`client_id`),
  KEY `sales_invoices_user_id_index` (`user_id`),
  KEY `sales_invoices_date_index` (`date`),
  KEY `sales_invoices_type_index` (`type`),
  KEY `sales_invoices_company_id_date_index` (`company_id`,`date`),
  KEY `sales_invoices_client_id_date_index` (`client_id`,`date`),
  KEY `sales_invoices_deleted_at_index` (`deleted_at`),
  KEY `sales_invoices_tax_id_foreign` (`tax_id`),
  KEY `sales_invoices_proposal_id_foreign` (`proposal_id`),
  KEY `sales_invoices_user_contract_id_foreign` (`user_contract_id`),
  CONSTRAINT `sales_invoices_client_id_foreign` FOREIGN KEY (`client_id`) REFERENCES `sales_clients` (`id`) ON DELETE SET NULL,
  CONSTRAINT `sales_invoices_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `sales_invoices_cost_center_id_foreign` FOREIGN KEY (`cost_center_id`) REFERENCES `cost_centers` (`id`) ON DELETE SET NULL,
  CONSTRAINT `sales_invoices_marker_id_foreign` FOREIGN KEY (`marker_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `sales_invoices_proposal_id_foreign` FOREIGN KEY (`proposal_id`) REFERENCES `proposals` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `sales_invoices_store_id_foreign` FOREIGN KEY (`store_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE CASCADE,
  CONSTRAINT `sales_invoices_tax_id_foreign` FOREIGN KEY (`tax_id`) REFERENCES `taxes` (`id`) ON DELETE SET NULL,
  CONSTRAINT `sales_invoices_user_contract_id_foreign` FOREIGN KEY (`user_contract_id`) REFERENCES `user_contracts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `sales_invoices_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `sales_product_categories`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `sales_product_categories` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `product_id` bigint unsigned NOT NULL,
  `category_id` bigint unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `sales_product_categories_product_id_foreign` (`product_id`),
  KEY `sales_product_categories_category_id_foreign` (`category_id`),
  CONSTRAINT `sales_product_categories_category_id_foreign` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `sales_product_categories_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `sales_products` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `sales_product_prices`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `sales_product_prices` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `product_id` bigint unsigned NOT NULL,
  `purchasing_price` double NOT NULL,
  `selling_price` double NOT NULL,
  `min_selling_price` double NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `unit_id` bigint unsigned DEFAULT NULL,
  `is_main_price` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `sales_product_prices_company_id_foreign` (`company_id`),
  KEY `sales_product_prices_product_id_foreign` (`product_id`),
  KEY `sales_product_prices_unit_id_foreign` (`unit_id`),
  CONSTRAINT `sales_product_prices_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `sales_product_prices_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `sales_products` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `sales_product_prices_unit_id_foreign` FOREIGN KEY (`unit_id`) REFERENCES `measurement_units` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `sales_products`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `sales_products` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` tinyint(1) NOT NULL DEFAULT '0',
  `track_stock` tinyint(1) NOT NULL DEFAULT '0',
  `initial_stock_level` double NOT NULL DEFAULT '0',
  `discount_amount` double DEFAULT NULL,
  `discount_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `barcode` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `categories` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `tags` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `tax_id` bigint unsigned DEFAULT NULL,
  `min_qty` int NOT NULL DEFAULT '1',
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `is_taxable` tinyint(1) NOT NULL DEFAULT '0',
  `section` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'accounting',
  `type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'product',
  `image` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `sale_tax` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `purchase_tax` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `is_returnable` tinyint(1) NOT NULL DEFAULT '0',
  `purchase_account_id` bigint unsigned DEFAULT NULL,
  `barcode_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `barcode_path` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `sales_products_user_id_foreign` (`user_id`),
  KEY `sales_products_tax_id_foreign` (`tax_id`),
  KEY `sales_products_name_index` (`name`),
  KEY `sales_products_code_index` (`code`),
  KEY `sales_products_status_index` (`status`),
  KEY `sales_products_company_id_name_index` (`company_id`,`name`),
  KEY `sales_products_company_id_status_index` (`company_id`,`status`),
  KEY `sales_products_created_at_index` (`created_at`),
  KEY `sales_products_section_index` (`section`),
  KEY `sales_products_purchase_account_id_foreign` (`purchase_account_id`),
  CONSTRAINT `sales_products_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `sales_products_purchase_account_id_foreign` FOREIGN KEY (`purchase_account_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `sales_products_tax_id_foreign` FOREIGN KEY (`tax_id`) REFERENCES `taxes` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `sales_products_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `sales_suppliers`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `sales_suppliers` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `account_id` bigint unsigned DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `trade_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `currency_code` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `balance` double NOT NULL DEFAULT '0',
  `status` tinyint(1) NOT NULL DEFAULT '0',
  `email` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `phone` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `street_address` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `city` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `region` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `postal_code` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `country` varchar(40) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `vat_number` varchar(40) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `national_number` varchar(40) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `website` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `location` json DEFAULT NULL,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `locale` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `categories` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `supplier_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `category_id` bigint unsigned DEFAULT NULL,
  `section` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `device_token` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `slug` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `password` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `production_capacity` int DEFAULT NULL,
  `default_lang` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'en',
  `type` enum('supplier only','supplier and carrier') COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `suppliers_account_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `sales_suppliers_user_id_foreign` (`user_id`),
  KEY `sales_suppliers_account_id_foreign` (`account_id`),
  KEY `sales_suppliers_company_id_index` (`company_id`),
  KEY `sales_suppliers_trade_name_index` (`trade_name`),
  KEY `sales_suppliers_code_index` (`code`),
  KEY `sales_suppliers_email_index` (`email`),
  KEY `sales_suppliers_phone_index` (`phone`),
  KEY `sales_suppliers_vat_number_index` (`vat_number`),
  KEY `sales_suppliers_status_index` (`status`),
  KEY `sales_suppliers_company_id_status_index` (`company_id`,`status`),
  KEY `sales_suppliers_trade_name_company_id_index` (`trade_name`,`company_id`),
  KEY `sales_suppliers_deleted_at_index` (`deleted_at`),
  KEY `sales_suppliers_supplier_type_index` (`supplier_type`),
  KEY `sales_suppliers_category_id_index` (`category_id`),
  KEY `sales_suppliers_section_index` (`section`),
  KEY `sales_suppliers_type_index` (`type`),
  KEY `sales_suppliers_suppliers_account_id_foreign` (`suppliers_account_id`),
  CONSTRAINT `sales_suppliers_account_id_foreign` FOREIGN KEY (`account_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `sales_suppliers_category_id_foreign` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`) ON DELETE SET NULL,
  CONSTRAINT `sales_suppliers_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `sales_suppliers_suppliers_account_id_foreign` FOREIGN KEY (`suppliers_account_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `sales_suppliers_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `sales_suppliers_contacts`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `sales_suppliers_contacts` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `supplier_id` bigint unsigned DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `email` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `phone` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `position` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `sales_suppliers_contacts_supplier_id_foreign` (`supplier_id`),
  KEY `sales_suppliers_contacts_company_id_foreign` (`company_id`),
  KEY `sales_suppliers_contacts_user_id_foreign` (`user_id`),
  CONSTRAINT `sales_suppliers_contacts_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `sales_suppliers_contacts_supplier_id_foreign` FOREIGN KEY (`supplier_id`) REFERENCES `sales_suppliers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `sales_suppliers_contacts_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `section_states`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `section_states` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `section` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `sellers`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `sellers` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `phone` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `tax_number` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `sellers_company_id_foreign` (`company_id`),
  KEY `sellers_user_id_foreign` (`user_id`),
  CONSTRAINT `sellers_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `sellers_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `sessions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `sessions` (
  `id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `ip_address` varchar(45) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `user_agent` text COLLATE utf8mb4_unicode_ci,
  `payload` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
  `last_activity` int NOT NULL,
  PRIMARY KEY (`id`),
  KEY `sessions_user_id_index` (`user_id`),
  KEY `sessions_last_activity_index` (`last_activity`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `settings`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `settings` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `title` json NOT NULL,
  `description` json NOT NULL,
  `address` json DEFAULT NULL,
  `first_email` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `second_email` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `first_phone` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `second_phone` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `whatsapp_phone` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `facebook_link` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `twitter_link` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `instagram_link` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `linkedin_link` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `snapchat_link` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `tiktok_link` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `tax` decimal(8,2) NOT NULL DEFAULT '0.00',
  `additional_settings` json DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `shift_times`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `shift_times` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `shift_id` bigint unsigned NOT NULL,
  `day_of_week` enum('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday') COLLATE utf8mb4_unicode_ci NOT NULL,
  `start_time` time NOT NULL,
  `end_time` time NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  `max_break_minutes` int DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `shift_times_shift_id_foreign` (`shift_id`),
  KEY `shift_times_company_id_foreign` (`company_id`),
  CONSTRAINT `shift_times_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `shift_times_shift_id_foreign` FOREIGN KEY (`shift_id`) REFERENCES `shifts` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `shifts`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `shifts` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `is_default` tinyint(1) NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `allowed_late_minutes` int DEFAULT NULL,
  `allowed_early_leave_minutes` int DEFAULT NULL,
  `shift_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `max_break_minutes` int DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `shifts_company_id_foreign` (`company_id`),
  CONSTRAINT `shifts_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `store_first_term_products`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `store_first_term_products` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `store_first_term_id` bigint unsigned DEFAULT NULL,
  `store_id` bigint unsigned NOT NULL,
  `product_id` bigint unsigned NOT NULL,
  `quantity` double NOT NULL,
  `current_quantity` double NOT NULL DEFAULT '0',
  `price` double NOT NULL,
  `total` double NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `unit_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `store_first_term_products_company_id_foreign` (`company_id`),
  KEY `store_first_term_products_store_first_term_id_foreign` (`store_first_term_id`),
  KEY `store_first_term_products_store_id_foreign` (`store_id`),
  KEY `store_first_term_products_product_id_foreign` (`product_id`),
  KEY `store_first_term_products_unit_id_foreign` (`unit_id`),
  CONSTRAINT `store_first_term_products_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `store_first_term_products_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `sales_products` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `store_first_term_products_store_first_term_id_foreign` FOREIGN KEY (`store_first_term_id`) REFERENCES `store_first_terms` (`id`) ON DELETE SET NULL,
  CONSTRAINT `store_first_term_products_store_id_foreign` FOREIGN KEY (`store_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `store_first_term_products_unit_id_foreign` FOREIGN KEY (`unit_id`) REFERENCES `measurement_units` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `store_first_terms`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `store_first_terms` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `user_id` bigint unsigned NOT NULL,
  `store_id` bigint unsigned NOT NULL,
  `account_id` bigint unsigned DEFAULT NULL,
  `type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `date` date NOT NULL,
  `currency` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `exchange_rate` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `total` double NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `user_id_index` (`user_id`),
  KEY `store_id_index` (`store_id`),
  KEY `account_id_index` (`account_id`),
  KEY `company_user_index` (`company_id`,`user_id`),
  KEY `company_store_index` (`company_id`,`store_id`),
  KEY `company_account_index` (`company_id`,`account_id`),
  KEY `company_type_index` (`company_id`,`type`),
  KEY `store_first_terms_type_index` (`type`),
  KEY `store_first_terms_date_index` (`date`),
  KEY `store_first_terms_currency_index` (`currency`),
  CONSTRAINT `1` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `account_id_index` FOREIGN KEY (`account_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `store_id_index` FOREIGN KEY (`store_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `user_id_index` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `store_request_details`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `store_request_details` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `store_request_id` bigint unsigned NOT NULL,
  `material_id` bigint unsigned DEFAULT NULL,
  `equipment_id` bigint unsigned DEFAULT NULL,
  `quantity` decimal(10,2) NOT NULL,
  `unit` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `store_request_details_store_request_id_foreign` (`store_request_id`),
  KEY `store_request_details_material_id_foreign` (`material_id`),
  KEY `store_request_details_equipment_id_foreign` (`equipment_id`),
  CONSTRAINT `store_request_details_equipment_id_foreign` FOREIGN KEY (`equipment_id`) REFERENCES `equipment` (`id`) ON DELETE SET NULL,
  CONSTRAINT `store_request_details_material_id_foreign` FOREIGN KEY (`material_id`) REFERENCES `materials` (`id`) ON DELETE SET NULL,
  CONSTRAINT `store_request_details_store_request_id_foreign` FOREIGN KEY (`store_request_id`) REFERENCES `store_requests` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `store_requests`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `store_requests` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `project_id` bigint unsigned NOT NULL,
  `item_phase_id` bigint unsigned DEFAULT NULL,
  `contractor_id` bigint unsigned DEFAULT NULL,
  `request_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `store_requests_project_id_foreign` (`project_id`),
  KEY `store_requests_item_phase_id_foreign` (`item_phase_id`),
  KEY `store_requests_contractor_id_foreign` (`contractor_id`),
  CONSTRAINT `store_requests_contractor_id_foreign` FOREIGN KEY (`contractor_id`) REFERENCES `contractors` (`id`) ON DELETE SET NULL,
  CONSTRAINT `store_requests_item_phase_id_foreign` FOREIGN KEY (`item_phase_id`) REFERENCES `item_phases` (`id`) ON DELETE SET NULL,
  CONSTRAINT `store_requests_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `supplier_materials`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `supplier_materials` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `material_id` bigint unsigned DEFAULT NULL,
  `duration_for_delivery` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `supplier_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `supplier_materials_material_id_foreign` (`material_id`),
  KEY `supplier_materials_supplier_id_foreign` (`supplier_id`),
  CONSTRAINT `supplier_materials_material_id_foreign` FOREIGN KEY (`material_id`) REFERENCES `materials` (`id`) ON DELETE SET NULL,
  CONSTRAINT `supplier_materials_supplier_id_foreign` FOREIGN KEY (`supplier_id`) REFERENCES `sales_suppliers` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `supplier_prices`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `supplier_prices` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `unit_id` bigint unsigned NOT NULL,
  `product_id` bigint unsigned NOT NULL,
  `supplier_id` bigint unsigned DEFAULT NULL,
  `driver_id` bigint unsigned DEFAULT NULL,
  `client_id` bigint unsigned DEFAULT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `price` double NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `supplier_prices_unit_id_foreign` (`unit_id`),
  KEY `supplier_prices_product_id_foreign` (`product_id`),
  KEY `supplier_prices_supplier_id_foreign` (`supplier_id`),
  KEY `supplier_prices_driver_id_foreign` (`driver_id`),
  KEY `supplier_prices_client_id_foreign` (`client_id`),
  KEY `supplier_prices_user_id_foreign` (`user_id`),
  KEY `supplier_prices_company_id_client_id_index` (`company_id`,`client_id`),
  KEY `supplier_prices_company_id_product_id_index` (`company_id`,`product_id`),
  KEY `supplier_prices_company_id_driver_id_index` (`company_id`,`driver_id`),
  KEY `supplier_prices_company_id_supplier_id_index` (`company_id`,`supplier_id`),
  KEY `supplier_prices_company_id_index` (`company_id`),
  CONSTRAINT `supplier_prices_client_id_foreign` FOREIGN KEY (`client_id`) REFERENCES `sales_clients` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `supplier_prices_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `supplier_prices_driver_id_foreign` FOREIGN KEY (`driver_id`) REFERENCES `drivers` (`id`) ON DELETE SET NULL,
  CONSTRAINT `supplier_prices_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `sales_products` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `supplier_prices_supplier_id_foreign` FOREIGN KEY (`supplier_id`) REFERENCES `sales_suppliers` (`id`) ON DELETE SET NULL,
  CONSTRAINT `supplier_prices_unit_id_foreign` FOREIGN KEY (`unit_id`) REFERENCES `measurement_units` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `supplier_prices_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `supplier_types`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `supplier_types` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `title` json NOT NULL,
  `status` tinyint(1) NOT NULL DEFAULT '1',
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `suppliers`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `suppliers` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `phone` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  `supplier_type_id` bigint unsigned DEFAULT NULL,
  `organization_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `organization_role` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` tinyint(1) NOT NULL DEFAULT '1',
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `suppliers_company_id_foreign` (`company_id`),
  KEY `suppliers_supplier_type_id_foreign` (`supplier_type_id`),
  CONSTRAINT `suppliers_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE SET NULL,
  CONSTRAINT `suppliers_supplier_type_id_foreign` FOREIGN KEY (`supplier_type_id`) REFERENCES `supplier_types` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `task_categories`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `task_categories` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `title` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `workflow_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `task_dependencies`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `task_dependencies` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `task_id` bigint unsigned DEFAULT NULL,
  `dependent_task_id` bigint unsigned DEFAULT NULL,
  `offset_days` int NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `task_dependencies_task_id_dependent_task_id_unique` (`task_id`,`dependent_task_id`),
  KEY `task_dependencies_dependent_task_id_foreign` (`dependent_task_id`),
  CONSTRAINT `task_dependencies_dependent_task_id_foreign` FOREIGN KEY (`dependent_task_id`) REFERENCES `task_plans` (`id`) ON DELETE CASCADE,
  CONSTRAINT `task_dependencies_task_id_foreign` FOREIGN KEY (`task_id`) REFERENCES `task_plans` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `task_phases`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `task_phases` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `item_phase_id` bigint unsigned NOT NULL,
  `task_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `task_duration` decimal(10,2) NOT NULL,
  `start_date` date NOT NULL,
  `end_date` date NOT NULL,
  `task_description` text COLLATE utf8mb4_unicode_ci,
  `task_notes` text COLLATE utf8mb4_unicode_ci,
  `contractor_id` bigint unsigned DEFAULT NULL,
  `materials` json DEFAULT NULL,
  `equipment` json DEFAULT NULL,
  `workers` json DEFAULT NULL,
  `required_quantity` decimal(10,2) NOT NULL,
  `completed_quantity` decimal(10,2) NOT NULL DEFAULT '0.00',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT 'pending',
  `quantity_unit_id` bigint unsigned DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `task_phases_item_phase_id_foreign` (`item_phase_id`),
  KEY `task_phases_contractor_id_foreign` (`contractor_id`),
  KEY `task_phases_quantity_unit_id_foreign` (`quantity_unit_id`),
  KEY `task_phases_company_id_foreign` (`company_id`),
  CONSTRAINT `task_phases_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `task_phases_contractor_id_foreign` FOREIGN KEY (`contractor_id`) REFERENCES `contractors` (`id`) ON DELETE SET NULL,
  CONSTRAINT `task_phases_item_phase_id_foreign` FOREIGN KEY (`item_phase_id`) REFERENCES `item_phases` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `task_phases_quantity_unit_id_foreign` FOREIGN KEY (`quantity_unit_id`) REFERENCES `measurement_units` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `task_plans`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `task_plans` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint unsigned DEFAULT NULL,
  `main_project_id` bigint unsigned NOT NULL,
  `category_plan_id` bigint unsigned DEFAULT NULL,
  `order` int DEFAULT NULL,
  `title` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `start_date` timestamp NULL DEFAULT NULL,
  `end_date` timestamp NULL DEFAULT NULL,
  `due_date` timestamp NULL DEFAULT NULL,
  `priority` enum('Lowest','Low','Medium','High','Highest') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Medium',
  `number` int DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `task_plans_user_id_foreign` (`user_id`),
  KEY `task_plans_main_project_id_foreign` (`main_project_id`),
  KEY `task_plans_category_plan_id_foreign` (`category_plan_id`),
  KEY `task_plans_company_id_foreign` (`company_id`),
  CONSTRAINT `task_plans_category_plan_id_foreign` FOREIGN KEY (`category_plan_id`) REFERENCES `category_plans` (`id`) ON DELETE SET NULL,
  CONSTRAINT `task_plans_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `task_plans_main_project_id_foreign` FOREIGN KEY (`main_project_id`) REFERENCES `main_projects` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `task_plans_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `task_relations`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `task_relations` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `relation_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `lag_days` int DEFAULT NULL,
  `task_id` bigint unsigned NOT NULL,
  `related_task_id` bigint unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `task_relations_related_task_id_foreign` (`related_task_id`),
  KEY `task_relations_task_id_related_task_id_index` (`task_id`,`related_task_id`),
  CONSTRAINT `task_relations_related_task_id_foreign` FOREIGN KEY (`related_task_id`) REFERENCES `task_phases` (`id`) ON DELETE CASCADE,
  CONSTRAINT `task_relations_task_id_foreign` FOREIGN KEY (`task_id`) REFERENCES `task_phases` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `task_tags`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `task_tags` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `title` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `workflow_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `taxes`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `taxes` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `rate` double NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `taxes_name_index` (`name`),
  KEY `taxes_rate_index` (`rate`),
  KEY `taxes_company_id_foreign` (`company_id`),
  CONSTRAINT `taxes_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `telescope_entries`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `telescope_entries` (
  `sequence` bigint unsigned NOT NULL AUTO_INCREMENT,
  `uuid` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `batch_id` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `family_hash` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `should_display_on_index` tinyint(1) NOT NULL DEFAULT '1',
  `type` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
  `content` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` datetime DEFAULT NULL,
  PRIMARY KEY (`sequence`),
  UNIQUE KEY `telescope_entries_uuid_unique` (`uuid`),
  KEY `telescope_entries_batch_id_index` (`batch_id`),
  KEY `telescope_entries_family_hash_index` (`family_hash`),
  KEY `telescope_entries_created_at_index` (`created_at`),
  KEY `telescope_entries_type_should_display_on_index_index` (`type`,`should_display_on_index`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `telescope_entries_tags`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `telescope_entries_tags` (
  `entry_uuid` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `tag` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  PRIMARY KEY (`entry_uuid`,`tag`),
  KEY `telescope_entries_tags_tag_index` (`tag`),
  CONSTRAINT `telescope_entries_tags_entry_uuid_foreign` FOREIGN KEY (`entry_uuid`) REFERENCES `telescope_entries` (`uuid`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `telescope_monitoring`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `telescope_monitoring` (
  `tag` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  PRIMARY KEY (`tag`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `temp_media_uploads`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `temp_media_uploads` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `uuid` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `templates`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `templates` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `project_type_id` bigint unsigned DEFAULT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `company_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `templates_project_type_id_foreign` (`project_type_id`),
  KEY `templates_company_id_foreign` (`company_id`),
  CONSTRAINT `templates_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `templates_project_type_id_foreign` FOREIGN KEY (`project_type_id`) REFERENCES `project_types` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `temporary_files`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `temporary_files` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `folder` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `filename` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `time_cards`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `time_cards` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `daily_record_id` bigint unsigned NOT NULL,
  `user_id` bigint unsigned NOT NULL,
  `hours_worked` decimal(8,2) NOT NULL,
  `type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'draft',
  `approved_by` bigint unsigned DEFAULT NULL,
  `approval_date` timestamp NULL DEFAULT NULL,
  `item_phase_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `time_cards_daily_record_id_foreign` (`daily_record_id`),
  KEY `time_cards_user_id_foreign` (`user_id`),
  KEY `time_cards_approved_by_foreign` (`approved_by`),
  KEY `time_cards_item_phase_id_foreign` (`item_phase_id`),
  CONSTRAINT `time_cards_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
  CONSTRAINT `time_cards_daily_record_id_foreign` FOREIGN KEY (`daily_record_id`) REFERENCES `daily_records` (`id`) ON DELETE CASCADE,
  CONSTRAINT `time_cards_item_phase_id_foreign` FOREIGN KEY (`item_phase_id`) REFERENCES `item_phases` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `time_cards_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `timers`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `timers` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint unsigned DEFAULT NULL,
  `management_project_id` bigint unsigned DEFAULT NULL,
  `task_id` bigint unsigned DEFAULT NULL,
  `start_time` timestamp NULL DEFAULT NULL,
  `end_time` timestamp NULL DEFAULT NULL,
  `duration` int NOT NULL DEFAULT '0',
  `description` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `timers_user_id_foreign` (`user_id`),
  KEY `timers_management_project_id_foreign` (`management_project_id`),
  KEY `timers_task_id_foreign` (`task_id`),
  KEY `timers_company_id_foreign` (`company_id`),
  CONSTRAINT `timers_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `timers_management_project_id_foreign` FOREIGN KEY (`management_project_id`) REFERENCES `management_projects` (`id`) ON DELETE SET NULL,
  CONSTRAINT `timers_task_id_foreign` FOREIGN KEY (`task_id`) REFERENCES `management_tasks` (`id`) ON DELETE SET NULL,
  CONSTRAINT `timers_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `transaction_histories`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `transaction_histories` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `transaction_id` bigint unsigned DEFAULT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `action` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `note` text COLLATE utf8mb4_unicode_ci,
  `before_state` json DEFAULT NULL,
  `after_state` json DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `transaction_histories_transaction_id_foreign` (`transaction_id`),
  KEY `transaction_histories_user_id_foreign` (`user_id`),
  CONSTRAINT `transaction_histories_transaction_id_foreign` FOREIGN KEY (`transaction_id`) REFERENCES `accounting_transactions` (`id`) ON DELETE CASCADE,
  CONSTRAINT `transaction_histories_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `transactions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `transactions` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `contractor_id` bigint unsigned NOT NULL,
  `invoice_id` bigint unsigned DEFAULT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `date` date NOT NULL,
  `debit` decimal(10,2) NOT NULL DEFAULT '0.00',
  `credit` decimal(10,2) NOT NULL DEFAULT '0.00',
  `balance` decimal(10,2) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `transactions_contractor_id_foreign` (`contractor_id`),
  KEY `transactions_invoice_id_foreign` (`invoice_id`),
  CONSTRAINT `transactions_contractor_id_foreign` FOREIGN KEY (`contractor_id`) REFERENCES `contractors` (`id`) ON DELETE CASCADE,
  CONSTRAINT `transactions_invoice_id_foreign` FOREIGN KEY (`invoice_id`) REFERENCES `invoices` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `translations`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `translations` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `language_id` int unsigned NOT NULL,
  `group` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `key` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `value` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `translations_language_id_foreign` (`language_id`),
  CONSTRAINT `translations_language_id_foreign` FOREIGN KEY (`language_id`) REFERENCES `languages` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `unit_conversions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `unit_conversions` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `base_unit_id` bigint unsigned NOT NULL,
  `sub_unit_id` bigint unsigned NOT NULL,
  `conversion_factor` decimal(18,8) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `unit_conversions_base_unit_id_foreign` (`base_unit_id`),
  KEY `unit_conversions_sub_unit_id_foreign` (`sub_unit_id`),
  CONSTRAINT `unit_conversions_base_unit_id_foreign` FOREIGN KEY (`base_unit_id`) REFERENCES `measurement_units` (`id`),
  CONSTRAINT `unit_conversions_sub_unit_id_foreign` FOREIGN KEY (`sub_unit_id`) REFERENCES `measurement_units` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `units`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `units` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `title` json NOT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` tinyint(1) NOT NULL DEFAULT '1',
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `user_contracts`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `user_contracts` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint unsigned DEFAULT NULL,
  `full_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `employee_number` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `national_id` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `nationality` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `birth_date` date DEFAULT NULL,
  `address` text COLLATE utf8mb4_unicode_ci,
  `marital_status` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `bank_account` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `job_title` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `department` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `work_location` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `employment_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `start_date` date DEFAULT NULL,
  `end_date` date DEFAULT NULL,
  `project_id` bigint unsigned DEFAULT NULL,
  `probation_start` date DEFAULT NULL,
  `probation_end` date DEFAULT NULL,
  `basic_salary` decimal(10,2) DEFAULT NULL,
  `allowances` json DEFAULT NULL,
  `overtime_calculation` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `total_salary` decimal(10,2) DEFAULT NULL,
  `payment_method` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `payment_frequency` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `currency` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `taxable` tinyint(1) DEFAULT NULL,
  `annual_leave` int DEFAULT NULL,
  `insurance` json DEFAULT NULL,
  `sick_leave` int DEFAULT NULL,
  `employee_notice_period` int DEFAULT NULL,
  `company_notice_period` int DEFAULT NULL,
  `termination_conditions` text COLLATE utf8mb4_unicode_ci,
  `confidentiality_clause` text COLLATE utf8mb4_unicode_ci,
  `auto_renewal` tinyint(1) DEFAULT NULL,
  `jurisdiction` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `contract_signed_date` date DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `e_signature_id` bigint unsigned DEFAULT NULL,
  `product_items` json DEFAULT NULL,
  `old_versions` json DEFAULT NULL,
  `preamble` text COLLATE utf8mb4_unicode_ci,
  `signature_status` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `contract_title` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `contract_introduction` text COLLATE utf8mb4_unicode_ci,
  `contract_subject` text COLLATE utf8mb4_unicode_ci,
  `is_renewable` tinyint(1) NOT NULL DEFAULT '0',
  `rights_and_obligations` text COLLATE utf8mb4_unicode_ci,
  PRIMARY KEY (`id`),
  UNIQUE KEY `user_contracts_employee_number_unique` (`employee_number`),
  UNIQUE KEY `user_contracts_national_id_unique` (`national_id`),
  KEY `user_contracts_user_id_foreign` (`user_id`),
  KEY `user_contracts_project_id_foreign` (`project_id`),
  KEY `user_contracts_e_signature_id_foreign` (`e_signature_id`),
  CONSTRAINT `user_contracts_e_signature_id_foreign` FOREIGN KEY (`e_signature_id`) REFERENCES `e_signatures` (`id`) ON DELETE SET NULL,
  CONSTRAINT `user_contracts_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `user_contracts_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `users`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `users` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `phone` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `password` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'active',
  `last_login_at` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `hashed_otp` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `otp_expired_at` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email_verified_at` timestamp NULL DEFAULT NULL,
  `can_change_password` tinyint(1) NOT NULL DEFAULT '0',
  `access_construction_company` tinyint(1) NOT NULL DEFAULT '0',
  `access_supplies_company` tinyint(1) NOT NULL DEFAULT '0',
  `remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  `shift_id` bigint unsigned DEFAULT NULL,
  `device_number` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `job_title` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `job_number` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `contract_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `salary_per_day` decimal(8,2) DEFAULT NULL,
  `fixed_salary` decimal(8,2) DEFAULT NULL,
  `available_qty` int DEFAULT NULL,
  `labor_category_id` bigint unsigned DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `section` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT 'accounting',
  PRIMARY KEY (`id`),
  UNIQUE KEY `users_email_unique` (`email`),
  UNIQUE KEY `users_phone_unique` (`phone`),
  UNIQUE KEY `users_device_number_unique` (`device_number`),
  KEY `users_company_id_foreign` (`company_id`),
  KEY `users_shift_id_foreign` (`shift_id`),
  KEY `users_labor_category_id_foreign` (`labor_category_id`),
  CONSTRAINT `users_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `users_labor_category_id_foreign` FOREIGN KEY (`labor_category_id`) REFERENCES `labor_categories` (`id`) ON DELETE CASCADE,
  CONSTRAINT `users_shift_id_foreign` FOREIGN KEY (`shift_id`) REFERENCES `shifts` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `users_settings`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `users_settings` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint unsigned NOT NULL,
  `treasure_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `users_settings_user_id_foreign` (`user_id`),
  KEY `users_settings_treasure_id_foreign` (`treasure_id`),
  CONSTRAINT `users_settings_treasure_id_foreign` FOREIGN KEY (`treasure_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `users_settings_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `valleys`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `valleys` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `account_id` bigint unsigned DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` tinyint(1) NOT NULL DEFAULT '0',
  `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `administrator_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `phone` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `address` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `valleys_user_id_foreign` (`user_id`),
  KEY `valleys_account_id_foreign` (`account_id`),
  KEY `valleys_company_id_index` (`company_id`),
  KEY `valleys_company_id_code_index` (`company_id`,`code`),
  KEY `valleys_company_id_user_id_index` (`company_id`,`user_id`),
  KEY `valleys_company_id_account_id_index` (`company_id`,`account_id`),
  CONSTRAINT `valleys_account_id_foreign` FOREIGN KEY (`account_id`) REFERENCES `chart_of_accounts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `valleys_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `valleys_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `valuation_rates`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `valuation_rates` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `currency_code` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `rate` decimal(10,4) NOT NULL,
  `company_id` bigint unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `valuation_rates_company_id_foreign` (`company_id`),
  KEY `valuation_rates_currency_code_foreign` (`currency_code`),
  CONSTRAINT `valuation_rates_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`),
  CONSTRAINT `valuation_rates_currency_code_foreign` FOREIGN KEY (`currency_code`) REFERENCES `currencies` (`code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `workers`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `workers` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `available_qty` int NOT NULL DEFAULT '1',
  `contract_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `salary_per_day` double DEFAULT NULL,
  `fixed_salary` double DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `worker_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'internal',
  `identity_number` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `phone_number` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `position` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `worker_classification` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `workers_identity_number_unique` (`identity_number`),
  UNIQUE KEY `workers_phone_number_unique` (`phone_number`),
  KEY `workers_company_id_contract_type_index` (`company_id`,`contract_type`),
  CONSTRAINT `workers_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `workflow_stages`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `workflow_stages` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `main_project_id` bigint unsigned NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `order` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `workflow_stages_main_project_id_order_index` (`main_project_id`,`order`),
  CONSTRAINT `workflow_stages_main_project_id_foreign` FOREIGN KEY (`main_project_id`) REFERENCES `main_projects` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `workplaces`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `workplaces` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `latitude` decimal(10,6) NOT NULL,
  `longitude` decimal(10,6) NOT NULL,
  `radius` int unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `workplaces_name_unique` (`name`),
  KEY `workplaces_company_id_foreign` (`company_id`),
  CONSTRAINT `workplaces_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (1,'0000_00_00_create_companies_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (2,'0000_11_23_211557_create_equipment_types_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (3,'0000_11_23_211645_create_units_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (4,'0000_11_23_211834_create_supplier_types_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (5,'0001_01_01_000000_create_users_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (6,'0001_01_01_000001_create_cache_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (7,'0001_01_01_000002_create_jobs_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (8,'2018_08_29_200844_create_languages_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (9,'2018_08_29_205156_create_translations_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (10,'2023_06_06_132440_create_notifications_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (11,'2024_04_09_094639_create_measurement_units_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (12,'2024_05_06_192857_create_chart_of_accounts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (13,'2024_08_07_205717_create_media_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (14,'2024_08_07_205809_create_error_log_exceptions_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (15,'2024_08_07_210232_create_telescope_entries_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (16,'2024_08_07_211643_create_settings_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (17,'2024_08_08_050600_create_temp_media_uploads_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (18,'2024_08_18_051025_create_permission_tables',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (19,'2024_09_05_200759_create_personal_access_tokens_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (20,'2024_11_01_061646_create_fields_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (21,'2024_11_01_061739_create_contractor_types_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (22,'2024_11_23_211447_create_suppliers_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (23,'2024_11_23_211602_create_equipment_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (24,'2024_11_23_212812_create_equipment_supplier_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (25,'2024_11_23_225242_create_main_contractors_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (26,'2024_11_23_225358_create_projects_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (27,'2024_11_24_223440_create_materials_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (28,'2024_11_24_223516_create_workers_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (29,'2024_11_24_224336_create_supplier_materials_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (30,'2024_11_24_224756_create_contractors_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (31,'2024_11_24_225208_create_project_phases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (32,'2024_11_24_225333_create_project_clauses_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (33,'2024_11_24_225614_create_project_user_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (34,'2024_11_24_225712_create_project_folders_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (35,'2024_11_24_225726_create_project_files_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (36,'2024_11_25_082823_create_material_supplier_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (37,'2024_11_25_090107_create_project_clause_materials_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (38,'2024_11_25_090220_create_project_clause_workers_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (39,'2024_11_25_090646_create_project_clause_equipment_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (40,'2024_12_21_085757_create_categories_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (41,'2024_12_21_095417_create_sellers_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (42,'2024_12_22_063415_create_cost_centers_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (43,'2024_12_22_103856_create_cash_journals_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (44,'2024_12_23_082055_create_journals_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (45,'2024_12_23_100822_create_opening_entries_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (46,'2024_12_23_104510_create_opening_entries_transactions_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (47,'2024_12_24_100122_add_company_id_to_users_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (48,'2024_12_24_123137_create_assets_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (49,'2024_12_24_163004_create_items_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (50,'2024_12_24_164701_create_users_settings_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (51,'2024_12_24_171124_create_finance_categories_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (52,'2024_12_24_201635_create_financial_years_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (53,'2024_12_25_080339_create_taxes_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (54,'2024_12_25_080819_create_sales_products_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (55,'2024_12_25_091927_create_sales_product_categories_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (56,'2024_12_26_074101_create_store_first_terms_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (57,'2024_12_26_093225_create_store_first_term_products_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (58,'2024_12_26_112452_create_sales_clients_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (59,'2024_12_26_120407_create_sales_clients_contacts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (60,'2024_12_26_131305_create_sales_suppliers_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (61,'2024_12_26_131316_create_sales_suppliers_contacts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (62,'2024_12_26_165520_create_purchases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (63,'2024_12_27_173319_create_product_stores_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (64,'2024_12_27_173603_create_purchase_products_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (65,'2024_12_27_190550_create_purchase_taxes_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (66,'2024_12_28_065605_create_sales_invoices_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (67,'2024_12_28_084110_create_sales_invoice_products_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (68,'2024_12_28_085355_create_sales_invoice_taxes_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (69,'2024_12_28_110329_create_arrest_papers_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (70,'2024_12_28_113441_create_payments_papers_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (71,'2024_12_28_120528_create_bank_cheques_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (72,'2024_12_28_134503_create_finance_expenses_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (73,'2024_12_28_195719_create_finance_expenses_transactions_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (74,'2024_12_30_111517_create_accounting_transactions_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (75,'2024_12_31_110801_create_cash_journal_transactions_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (76,'2025_01_01_063957_create_journal_transactions_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (77,'2025_01_04_070818_create_price_approvals_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (78,'2025_01_04_104334_create_information_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (79,'2025_01_04_113806_create_rewards_and_penalties_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (80,'2025_01_06_083919_create_shifts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (81,'2025_01_06_092642_create_shift_times_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (82,'2025_01_06_120340_add_shift_id_column_to_users_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (83,'2025_01_06_123532_create_activity_log_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (84,'2025_01_06_123533_add_event_column_to_activity_log_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (85,'2025_01_06_123534_add_batch_uuid_column_to_activity_log_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (86,'2025_01_06_130642_create_attendances_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (87,'2025_01_07_070027_create_employee_breaks_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (88,'2025_01_07_093537_create_month_salaries_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (89,'2025_01_07_095553_create_workplaces_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (90,'2025_01_07_105528_add_device_number_to_users_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (91,'2025_01_08_083933_create_leaves_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (92,'2025_01_08_084101_create_leave_balances_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (93,'2025_01_10_160535_create_ads_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (94,'2025_01_12_095907_create_project_entities_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (95,'2025_01_12_100536_create_project_entity_user_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (96,'2025_01_13_094149_create_management_task_categories_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (97,'2025_01_14_095907_create_main_projects_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (98,'2025_01_14_095907_create_management_projects_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (99,'2025_01_14_135135_create_main_project_user_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (100,'2025_01_14_145404_create_workflow_stages_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (101,'2025_01_15_121759_create_task_categories_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (102,'2025_01_16_063659_create_task_tags_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (103,'2025_01_18_094638_create_main_tasks_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (104,'2025_01_19_103626_create_temporary_files_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (105,'2025_01_19_172312_add_client_id_to_arrest_papers_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (106,'2025_01_19_173041_add_supplier_id_to_payments_papers_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (107,'2025_01_20_133750_create_main_task_tag_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (108,'2025_01_20_163948_create_main_task_links_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (109,'2025_01_20_175225_create_comments_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (110,'2025_01_23_090121_create_management_tasks_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (111,'2025_01_23_095058_add_taskable_column_to_main_tasks_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (112,'2025_01_23_095910_create_timers_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (113,'2025_01_24_130420_create_checklist_items_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (114,'2025_01_24_183051_create_customer_ratings_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (115,'2025_01_24_184501_create_contacts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (116,'2025_01_26_061337_create_interaction_types_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (117,'2025_01_26_120540_add_branch_details_to_companies_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (118,'2025_01_27_093924_add_taxes_to_purchase_products_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (119,'2025_01_27_094544_add_taxes_to_sales_products_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (120,'2025_01_27_105829_create_notes_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (121,'2025_01_27_134221_create_interaction_stages_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (122,'2025_01_27_165537_create_interactions_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (123,'2025_01_28_174009_create_main_events_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (124,'2025_01_28_174123_create_main_event_schedules_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (125,'2025_01_28_175735_create_events_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (126,'2025_01_29_092320_add_phone_status_to_contacts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (127,'2025_01_29_181803_create_automation_rules_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (128,'2025_01_30_093109_create_section_states_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (129,'2025_01_30_095730_add_section_state_id_to_contacts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (130,'2025_01_30_095749_add_section_state_id_to_sales_clients_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (131,'2025_02_04_134436_create_management_project_files_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (132,'2025_02_04_231925_create_main_phases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (133,'2025_02_05_071527_create_management_phases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (134,'2025_02_05_084333_create_management_categories_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (135,'2025_02_05_110058_create_category_plans_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (136,'2025_02_05_110156_create_task_plans_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (137,'2025_02_05_134616_create_task_dependencies_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (138,'2025_02_06_071816_create_client_companies_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (139,'2025_02_08_080614_add_main_project_id_to_projects',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (140,'2025_02_08_134739_create_item_phases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (141,'2025_02_09_072127_add_contract_file_to_projects',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (142,'2025_02_09_090134_create_task_phases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (143,'2025_02_10_082617_add_tax_column_to_settings_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (144,'2025_02_10_091806_create_invoices_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (145,'2025_02_10_153114_create_transactions_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (146,'2025_02_11_092606_create_expenses_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (147,'2025_02_11_172730_create_revenues_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (148,'2025_02_12_080518_create_quotations_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (149,'2025_02_12_110612_create_account_statements_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (150,'2025_02_12_140218_create_advances_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (151,'2025_02_13_092040_create_change_requests_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (152,'2025_02_13_115807_create_store_requests_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (153,'2025_02_13_120003_create_store_request_details_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (154,'2025_02_15_200700_add_type_to_sales_clients',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (155,'2025_02_16_074326_create_client_responsable_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (156,'2025_02_16_083450_create_client_contracts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (157,'2025_02_16_100805_add_type_to_sales_suppliers',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (158,'2025_02_16_101102_add_position_to_sales_suppliers_contacts',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (159,'2025_02_18_114817_add_fields_to_contractors',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (160,'2025_02_20_114440_add_taxs_to_purchases',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (161,'2025_02_20_114506_add_taxs_to_sales_invoices',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (162,'2025_02_20_123821_add_main_client_id_and_section_to_sales_clients_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (163,'2025_02_22_070431_create_valleys_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (164,'2025_02_22_101444_create_drivers_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (165,'2025_02_22_113456_create_driver_supplier_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (166,'2025_02_22_114637_add_client_id_to_invoices',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (167,'2025_02_22_153454_add_category_id_and_section__to_sales_suppliers_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (168,'2025_02_22_160300_add_remember_token_and_device_token_to_sales_suppliers_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (169,'2025_02_22_160341_add_remember_token_and_device_token_to_sales_clients_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (170,'2025_02_22_214839_add_files_to_quotations',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (171,'2025_02_23_063150_create_sales_product_prices_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (172,'2025_02_23_065200_drop_prices_columns_from_sales_products_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (173,'2025_02_23_070411_add_unit_id_to_purchase_products',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (174,'2025_02_23_111916_create_client_products_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (175,'2025_02_23_122132_create_supplier_prices_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (176,'2025_02_23_172842_add_slug_to_sales_clients_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (177,'2025_02_23_174848_add_slug_to_sales_suppliers_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (178,'2025_02_23_182811_create_orders_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (179,'2025_02_23_193559_create_order_suppliers_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (180,'2025_02_23_195706_create_order_drivers_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (181,'2025_02_25_062840_create_alternative_client_order_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (182,'2025_02_25_072513_create_order_vehicles_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (183,'2025_02_25_090142_add_fields_to_item_phases',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (184,'2025_02_26_152919_create_inventories_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (185,'2025_02_27_081643_add_fields_to_materials',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (186,'2025_02_27_103828_add_fields_to_equipment',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (187,'2025_02_27_131349_add_has_study_to_projects_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (188,'2025_03_02_074342_add_type_to_product_stores_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (189,'2025_03_02_145737_add_quantity_to_expenses_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (190,'2025_03_03_142044_add_product_id_to_product_stores_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (191,'2025_03_04_130007_add_category_to_purchase_products_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (192,'2025_03_05_091059_add_product_to_product_stores_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (193,'2025_03_06_081036_add_company_id_to_materials_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (194,'2025_03_06_081126_add_company_id_to_equipment_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (195,'2025_03_06_130613_add_type_to_workers_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (196,'2025_03_08_130511_add_equipment_asset_to_equipment_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (197,'2025_03_09_094735_create_unit_conversions_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (198,'2025_03_09_113336_add_additional_settings_json_to_settings_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (199,'2025_03_10_121411_add_status_to_accounting_transactions_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (200,'2025_03_11_094621_add_tax_to_sales_products_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (201,'2025_03_11_134147_add_payment_to_purchases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (202,'2025_03_11_135315_add_payment_to_sales_invoices_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (203,'2025_03_12_114153_create_bank_accounts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (204,'2025_03_15_133408_add_status_to_equipment_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (205,'2025_03_16_093518_add_new_columns_to_workers_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (206,'2025_03_16_114747_add_new_columns_to_invoices_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (207,'2025_03_16_115845_create_invoice_details_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (208,'2025_03_16_141344_add_new_columns_to_item_phases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (209,'2025_03_17_090751_add_new_quantity_to_item_phases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (210,'2025_03_17_133513_add_new_colnm_to_project_phases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (211,'2025_03_17_142732_create_invoice_items_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (212,'2025_03_18_081436_add_new_date_to_invoices_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (213,'2025_03_19_092856_create_contracts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (214,'2025_03_19_093251_create_contract_work_items_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (215,'2025_03_19_093336_create_contract_payment_terms_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (216,'2025_03_20_081942_add_procurement_fields_to_sales_suppliers_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (217,'2025_03_20_110532_add_new_clonm_to_item_phases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (218,'2025_03_20_141703_add_new_clonm_to_invoices_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (219,'2025_03_22_081600_add_procurment_fileds_to_sales_clients_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (220,'2025_03_22_095607_create_equipment_project_usage_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (221,'2025_03_22_120657_add_type_to_equipment_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (222,'2025_03_23_125257_add_project_id_to_contracts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (223,'2025_03_23_143336_add_new_status_to_invoices_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (224,'2025_03_24_105521_create_labor_categories_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (225,'2025_03_24_154148_add_new_clounm_to_invoice_details_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (226,'2025_03_24_185907_create_external_labors_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (227,'2025_03_25_082301_create_external_labor_item_phases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (228,'2025_03_25_105340_add_new_clounm_to_users_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (229,'2025_03_27_112818_create_project_types_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (230,'2025_03_27_124916_add_project_type_id_to_projects_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (231,'2025_03_27_133350_add_new_clounm_to_advances_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (232,'2025_03_27_151438_create_task_relations_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (233,'2025_03_28_114155_add_new_clounm_to_main_inventories_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (234,'2025_03_28_131126_add_new_clounm_to_external_labors_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (235,'2025_03_29_100813_add_new_clounm_to_projects_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (236,'2025_04_03_115042_add_new_clounm_to_equipment_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (237,'2025_04_03_151811_add_new_clounm_to_projects_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (238,'2025_04_04_112233_add_new_clounm_to_task_phases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (239,'2025_04_05_080255_add__clounm_to_task_phases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (240,'2025_04_05_130533_add__clounms_to_task_phases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (241,'2025_04_06_082554_create_currencies_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (242,'2025_04_06_084858_add_currency_code_to_accounting_transactions_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (243,'2025_04_06_115458_add_columns_to_projects_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (244,'2025_04_06_124603_add_currency_fields_to_finance_expenses_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (245,'2025_04_06_175201_create_fixed_assets_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (246,'2025_04_06_192546_create_depreciation_pools_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (247,'2025_04_07_131749_add_currencies_to_journals_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (248,'2025_04_07_194528_add_currency_fields_to_equipment_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (249,'2025_04_07_195559_add_currency_fields_to_materials_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (250,'2025_04_07_200206_add_currency_fields_to_expenses_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (251,'2025_04_07_203729_add_currency_fields_to_invoices_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (252,'2025_04_08_074627_create_account_balances_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (253,'2025_04_08_104344_add_unit_id_to_item_phases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (254,'2025_04_08_130431_create_approval_settings_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (255,'2025_04_09_120909_create_valuation_rates_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (256,'2025_04_10_084606_add_item_id_to_quotations_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (257,'2025_04_10_090925_add_currency_fields_to_orders_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (258,'2025_04_13_084305_add_currency_fields_to_fixed_assets_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (259,'2025_04_13_092950_add_currency_fields_to_quotations_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (260,'2025_04_13_101514_add_currency_fields_to_projects_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (261,'2025_04_13_121359_add_currency_fields_to_depreciation_pools_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (262,'2025_04_13_142705_add_items_to_depreciation_pools_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (263,'2025_04_14_063057_add_exchange_rate_to_month_salaries_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (264,'2025_04_14_113906_add_items_to_projects_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (265,'2025_04_15_141001_add_items_to_fixed_assets_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (266,'2025_04_15_183858_add_items_to_main_inventories_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (267,'2025_04_16_110857_add_setting_fields_to_companies_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (268,'2025_04_16_133746_create_invoice_managements_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (269,'2025_04_18_195716_add_payment_fields_to_purchases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (270,'2025_04_18_202220_add_payment_fields_to_sales_invoices_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (271,'2025_04_19_130817_add_imported_code_to_chart_of_accounts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (272,'2025_04_19_140609_add_items_to_equipment_project_usage_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (273,'2025_04_19_184740_add_currencies_to_external_labors_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (274,'2025_04_20_101434_create_holidays_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (275,'2025_04_20_133901_add_items_to_fixed_assets_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (276,'2025_04_21_091028_add_items_to_projects_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (277,'2025_04_22_072325_add_response_time_unit_to_approval_settings_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (278,'2025_04_22_101850_add_item_to_approval_settings_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (279,'2025_04_22_124105_create_business_rules_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (280,'2025_04_22_144056_add_item_to_contracts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (281,'2025_04_22_144352_add_item_to_invoice_managements_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (282,'2025_04_23_081404_add_items_to_equipment_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (283,'2025_04_23_083717_add_items_to_fixed_assets_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (284,'2025_04_23_090915_add_company_fields_to_management_projects_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (285,'2025_04_23_112358_add_items_to_materials_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (286,'2025_04_23_130255_add_colnms_to_equipment_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (287,'2025_04_23_143736_add_new_colnms_to_equipment_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (288,'2025_04_24_064111_create_material_requests_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (289,'2025_04_24_071142_create_company_currency_rates_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (290,'2025_04_24_084841_create_rental_contracts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (291,'2025_04_24_085047_create_rental_items_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (292,'2025_04_24_085705_create_rental_payments_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (293,'2025_04_24_120937_add_payed_amount_to_invoice_managements_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (294,'2025_04_24_121242_add_currency_code_to_invoice_managements_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (295,'2025_04_26_074229_add_title_to_measurement_units_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (296,'2025_04_26_075205_add_new_colnms_to_sales_suppliers_contacts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (297,'2025_04_26_080356_add_new_colnms_to_sales_suppliers_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (298,'2025_04_26_105246_add_new_colnms_to_project_phases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (299,'2025_04_26_105349_add_company_id_to_item_phases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (300,'2025_04_26_105427_add_company_id_to_task_phases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (301,'2025_04_26_105536_add_company_id_to_expenses_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (302,'2025_04_26_105549_add_company_id_to_revenues_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (303,'2025_04_26_105603_add_company_id_to_quotations_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (304,'2025_04_26_110854_add_company_id_to_invoices_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (305,'2025_04_26_130351_add_title_to_measurement_units_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (306,'2025_04_27_071919_create_phase_relations_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (307,'2025_04_27_074538_create_item_relations_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (308,'2025_04_27_075739_add_items_to_item_phases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (309,'2025_04_27_082731_create_client_prices_logs_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (310,'2025_04_27_090825_create_history_logs_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (311,'2025_04_27_121952_add_company_id_to_invoice_managements_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (312,'2025_04_27_122522_create_templates_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (313,'2025_04_27_134142_add_company_id_to_customer_ratings_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (314,'2025_04_27_134323_add_company_id_to_contacts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (315,'2025_04_27_134434_add_company_id_to_interactions_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (316,'2025_04_27_134452_add_company_id_to_interaction_types_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (317,'2025_04_27_134545_add_company_id_to_interaction_stages_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (318,'2025_04_27_134631_add_company_id_to_notes_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (319,'2025_04_27_134653_add_company_id_to_events_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (320,'2025_04_27_134730_add_company_id_to_main_events_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (321,'2025_04_28_111050_add_additional_fields_to_order_vehicles_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (322,'2025_04_28_120337_add_new_colnms_to_sales_product_prices_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (323,'2025_04_28_120927_add_company_id_to_ads_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (324,'2025_04_28_120936_add_company_id_to_attendances_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (325,'2025_04_28_120949_add_company_id_to_client_companies_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (326,'2025_04_28_121011_add_company_id_to_employee_breaks_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (327,'2025_04_28_121027_add_company_id_to_leaves_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (328,'2025_04_28_121045_add_company_id_to_management_categories_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (329,'2025_04_28_121122_add_company_id_to_management_phases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (330,'2025_04_28_121145_add_company_id_to_category_plans_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (331,'2025_04_28_121153_add_company_id_to_task_plans_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (332,'2025_04_28_121211_add_company_id_to_management_project_files_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (333,'2025_04_28_121256_add_company_id_to_management_tasks_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (334,'2025_04_28_121309_add_company_id_to_month_salaries_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (335,'2025_04_28_121323_add_company_id_to_rewards_and_penalties_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (336,'2025_04_28_121331_add_company_id_to_shifts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (337,'2025_04_28_121340_add_company_id_to_shift_times_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (338,'2025_04_28_121351_add_company_id_to_timers_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (339,'2025_04_28_121400_add_company_id_to_workplaces_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (340,'2025_04_29_095034_add_old_price_to_client_price_logs_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (341,'2025_04_29_185441_add_code_to_taxes_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (342,'2025_04_29_191206_add_code_to_projects_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (343,'2025_04_29_194405_add_code_to_invoices_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (344,'2025_04_29_200249_add_code_to_change_requests_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (345,'2025_04_29_201424_add_code_to_workers_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (346,'2025_04_29_202023_add_code_to_item_phases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (347,'2025_04_30_073346_add_unit_to_materials_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (348,'2025_04_30_080510_add_suppliers_to_supplier_materials_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (349,'2025_04_30_131359_add_code_to_measurement_units_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (350,'2025_04_30_132953_add_code_to_depreciation_pools_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (351,'2025_04_30_135547_add_code_to_store_first_terms_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (352,'2025_04_30_145829_add_approval_columns_to_accounting_transactions',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (353,'2025_04_30_182136_add_code_to_rental_contracts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (354,'2025_05_01_072215_add_code_to_bank_cheques_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (355,'2025_05_01_072323_add_code_to_payments_papers_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (356,'2025_05_01_083033_add_code_to_external_labors_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (357,'2025_05_01_091139_add_code_to_rewards_and_penalties_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (358,'2025_05_01_091830_add_code_to_leaves_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (359,'2025_05_01_092149_add_code_to_shifts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (360,'2025_05_01_093250_add_code_to_advances_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (361,'2025_05_01_094216_add_code_to_users_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (362,'2025_05_01_094831_add_code_to_contacts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (363,'2025_05_01_103515_add_code_to_orders_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (364,'2025_05_01_104406_add_code_to_order_vehicles_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (365,'2025_05_01_104806_add_code_to_history_logs_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (366,'2025_05_01_114635_add_for_procurement_to_measurement_units_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (367,'2025_05_01_122713_add_section_to_sales_products_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (368,'2025_05_03_121750_add_time_unit_to_projects_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (369,'2025_05_03_131659_add_time_unit_to_materials_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (370,'2025_05_03_133337_add_category_to_permissions_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (371,'2025_05_03_134544_add_phase_to_companies_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (372,'2025_05_04_085524_add_main_project_id_to_projects_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (373,'2025_05_04_092304_add_main_task_id_to_item_phases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (374,'2025_05_04_121839_add_items_to_advances_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (375,'2025_05_04_134105_add_items_to_change_requests_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (376,'2025_05_05_083529_add_items_to_month_salaries_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (377,'2025_05_05_085217_add_items_to_rewards_and_penalties_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (378,'2025_05_05_113951_add_items_to_external_labors_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (379,'2025_05_05_202658_add_currency_code_to_advances_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (380,'2025_05_05_203706_add_exchange_rate_to_advances_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (381,'2025_05_06_080942_create_company_settings_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (382,'2025_05_06_100330_add_items_to_shifts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (383,'2025_05_06_100403_create_break_times_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (384,'2025_05_06_103745_add_items_to_shift_times_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (385,'2025_05_06_110536_add_items_to_rental_contracts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (386,'2025_05_06_122202_add_items_to_rental_contracts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (387,'2025_05_06_131225_add_items_to_contracts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (388,'2025_05_06_133331_add_items_to_contract_work_items_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (389,'2025_05_06_160938_create_manual_store_transactions_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (390,'2025_05_07_105122_create_cost_estimates_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (391,'2025_05_07_111818_add_items_to_item_phases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (392,'2025_05_07_112756_add_type_to_manual_store_transactions_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (393,'2025_05_07_112822_add_items_to_project_phases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (394,'2025_05_07_145324_create_cost_pools_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (395,'2025_05_07_145625_add_total_budget_to_projects_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (396,'2025_05_07_154721_add_cost_pool_to_item_phases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (397,'2025_05_08_113943_add_account_id_to_invoice_managements_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (398,'2025_05_08_124542_create_purchase_orders_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (399,'2025_05_08_131751_create_user_contracts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (400,'2025_05_08_142526_create_purchase_order_supplier_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (401,'2025_05_10_080643_create_daily_records_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (402,'2025_05_10_092558_create_completed_works_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (403,'2025_05_10_092701_create_time_cards_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (404,'2025_05_10_092712_create_materials_received_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (405,'2025_05_10_092724_create_materials_consumed_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (406,'2025_05_10_092752_create_delays_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (407,'2025_05_10_092909_create_equipment_usage_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (408,'2025_05_10_092938_create_safety_incidents_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (409,'2025_05_10_092949_create_lab_tests_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (410,'2025_05_10_093003_create_consultant_notes_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (411,'2025_05_10_093015_create_general_notes_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (412,'2025_05_10_105009_create_sales_contracts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (413,'2025_05_10_150728_create_maintenance_contracts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (414,'2025_05_10_150822_create_maintenance_contract_assets_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (415,'2025_05_11_091909_create_audit_checklists_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (416,'2025_05_11_092100_create_audit_checklist_items_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (417,'2025_05_11_134739_create_e_signatures_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (418,'2025_05_12_133325_add_supplier_to_fixed_assets_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (419,'2025_05_12_155228_add_break_to_shifts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (420,'2025_05_13_080539_add_item_to_revenues_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (421,'2025_05_13_085353_add_item_to_expenses_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (422,'2025_05_13_102902_add_bank_account_id_to_bank_cheques_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (423,'2025_05_13_104131_drop_bank_feilds_from_bank_cheques_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (424,'2025_05_13_112124_add_category_id_to_finance_expenses_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (425,'2025_05_13_131017_add_itemable_code_to_invoice_managements_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (426,'2025_05_14_081452_create_transaction_histories_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (427,'2025_05_14_083151_add_type_to_sales_products_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (428,'2025_05_14_114015_add_item_to_equipment_project_usage_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (429,'2025_05_14_145215_add_profit_fields_to_sales_invoice_products_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (430,'2025_05_14_210252_add_compnay_id_to_sales_invoice_products_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (431,'2025_05_15_083047_add_price_offer_fields_to_purchase_order_supplier_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (432,'2025_05_15_084129_create_rental_contract_types_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (433,'2025_05_15_094049_add_deleted_at_to_purchase_order_supplier_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (434,'2025_05_15_113414_add_directory_to_media_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (435,'2025_05_15_121413_create_purchase_order_contracts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (436,'2025_05_17_081451_add_item_to_information_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (437,'2025_05_17_094322_create_product_price_histories_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (438,'2025_05_17_114418_add_item_to_item_phases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (439,'2025_05_17_125943_add_extra_columns_to_sales_products_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (440,'2025_05_17_130733_add_purchase_order_contract_id_to_purchases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (441,'2025_05_17_134127_add_credit_limit_to_sales_clients_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (442,'2025_05_17_134810_add_unit_id_to_purchase_orders_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (443,'2025_05_17_143515_add_type_and_status_to_taxes_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (444,'2025_05_17_150113_add_balance_and_min_balance_to_bank_accounts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (445,'2025_05_17_201016_add_contractor_id_to_invoice_managements_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (446,'2025_05_17_202150_add_purchase_order_supplier_id_to_purchase_order_contracts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (447,'2025_05_18_065833_create_receive_purchase_orders_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (448,'2025_05_18_072501_add_payment_method_status_and_invoice_relation_to_arrest_papers_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (449,'2025_05_18_072510_add_payment_method_status_and_invoice_relation_to_payments_papers_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (450,'2025_05_18_074459_create_payment_paper_invoice_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (451,'2025_05_18_074508_create_arrest_paper_purchase_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (452,'2025_05_18_091525_add_extra_columns_to_bank_cheques_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (453,'2025_05_18_113650_create_overtimes_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (454,'2025_05_18_133431_add_type_to_external_labors_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (455,'2025_05_18_133734_create_external_labor_contracts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (456,'2025_05_19_072604_add_type_to_rental_contracts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (457,'2025_05_19_100641_create_proposals_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (458,'2025_05_19_134313_add_rejected_reason_to_proposals_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (459,'2025_05_20_081610_add_type_to_project_phases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (460,'2025_05_20_085643_add_currancy_to_cost_estimates_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (461,'2025_05_20_092853_add_item_to_item_phases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (462,'2025_05_20_111854_create_proposal_comments_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (463,'2025_05_20_120924_add_proposal_id_to_sales_invoices_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (464,'2025_05_21_104848_add_company_id_to_main_tasks_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (465,'2025_05_21_105000_add_indexes_to_management_tasks_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (466,'2025_05_22_102407_add_item_to_payments_papers_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (467,'2025_05_22_122903_drop_supplier_id_constrained_from_driver_supplier_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (468,'2025_05_22_154712_add_closing_account_to_chart_of_accounts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (469,'2025_05_24_085317_add_company_id_to_taxes_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (470,'2025_05_25_065307_add_importance_to_sales_clients_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (471,'2025_05_25_090752_add_is_main_price_to_sales_product_prices_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (472,'2025_05_25_110922_add_is_product_unit_to_purchase_products_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (473,'2025_05_25_142709_add_item_to_leaves_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (474,'2025_05_26_075212_create_invoice_templates_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (475,'2025_05_26_112742_add_currency_fields_to_journal_transactions_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (476,'2025_05_26_114037_drop_currency_fields_from_journals_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (477,'2025_05_26_114646_add_display_currency_code_to_journal_transactions_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (478,'2025_05_26_115212_drop_currency_fields_from_cash_journals_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (479,'2025_05_26_115721_add_currency_fields_to_cash_journal_transactions_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (480,'2025_05_26_124229_add_purchase_account_id_to_sales_products_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (481,'2025_05_26_135756_add_clients_account_id_to_sales_clients_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (482,'2025_05_26_140530_add_clients_account_id_to_sales_suppliers_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (483,'2025_05_27_103635_add_segment_field_to_sales_clients_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (484,'2025_05_27_105334_create_price_segment_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (485,'2025_05_29_103017_create_procurement_purchase_orders_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (486,'2025_05_29_112937_create_purchase_order_drivers_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (487,'2025_05_29_120007_create_purchase_order_vehicles_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (488,'2025_05_29_122245_add_currency_to_procurement_purchase_orders_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (489,'2025_05_29_143055_add_confirmed_to_purchase_order_vehicles_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (490,'2025_05_31_075657_add_item_to_sales_clients_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (491,'2025_05_31_084213_add_item_to_cost_centers_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (492,'2025_05_31_095216_create_material_categories_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (493,'2025_05_31_100446_add_category_id_to_materials_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (494,'2025_05_31_104134_create_price_segment_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (495,'2025_05_31_122446_add_qr_code_value_to_materials_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (496,'2025_05_31_200421_add_reminder_sent_at_to_order_suppliers_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (497,'2025_05_31_200540_add_reminder_sent_at_to_order_vehicles_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (498,'2025_06_01_124436_add_status_to_sales_invoices_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (499,'2025_06_01_124645_add_status_to_purchases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (500,'2025_06_01_135356_add_depreciation_schedule_to_fixed_assets_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (501,'2025_06_02_084410_add_section_to_roles_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (502,'2025_06_02_125717_add_section_to_labor_categories_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (503,'2025_06_02_125836_add_section_to_categories_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (504,'2025_06_02_132317_add_section_to_users_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (505,'2025_06_03_140642_add_purchase_order_supplier_id_to_purchases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (506,'2025_06_10_071628_add_name_to_daily_records_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (507,'2025_06_10_072933_add_status_to_completed_works_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (508,'2025_06_10_072951_add_status_to_time_cards_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (509,'2025_06_10_073005_add_status_to_materials_received_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (510,'2025_06_10_073019_add_status_to_materials_consumed_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (511,'2025_06_10_073039_add_status_to_delays_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (512,'2025_06_10_073051_add_status_to_equipment_usage_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (513,'2025_06_10_073104_add_status_to_safety_incidents_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (514,'2025_06_10_073119_add_status_to_lab_tests_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (515,'2025_06_10_073136_add_status_to_consultant_notes_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (516,'2025_06_10_073152_add_status_to_general_notes_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (517,'2025_06_10_090225_change_project_dates_to_date_type',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (518,'2025_06_10_090916_change_contract_start_date_to_date_in_contractors_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (519,'2025_06_10_091141_change_data_to_data_type_in_project_phases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (520,'2025_06_10_151304_add_signatures_to_sales_contracts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (521,'2025_06_10_151701_add_signatures_to_purchases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (522,'2025_06_10_151903_add_signatures_to_invoices_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (523,'2025_06_10_152113_add_signatures_to_quotations_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (524,'2025_06_12_074053_change_description_in_project_phases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (525,'2025_06_12_075150_change_date_in_project_phases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (526,'2025_06_12_084337_add_bar_code_to_sales_products_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (527,'2025_06_12_111438_add_status_to_purchase_orders_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (528,'2025_06_12_113715_add_code_to_purchase_orders_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (529,'2025_06_12_130935_create_backups_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (530,'2025_06_12_213725_create_product_guides_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (531,'2025_06_12_215340_add_guide_id_to_categories_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (532,'2025_06_12_222916_add_approved_by_to_completed_works_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (533,'2025_06_12_222935_add_approved_by_to_time_cards_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (534,'2025_06_12_222948_add_approved_by_to_materials_received_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (535,'2025_06_12_223017_add_approved_by_to_materials_consumed_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (536,'2025_06_12_223043_add_approved_by_to_delays_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (537,'2025_06_12_223057_add_approved_by_to_equipment_usage_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (538,'2025_06_12_223112_add_approved_by_to_safety_incidents_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (539,'2025_06_12_223127_add_approved_by_to_lab_tests_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (540,'2025_06_12_223142_add_approved_by_to_consultant_notes_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (541,'2025_06_12_223156_add_approved_by_to_general_notes_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (542,'2025_06_14_105939_add_unit_id_to_store_first_term_products_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (543,'2025_06_14_111729_add_columns_to_user_contracts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (544,'2025_06_14_113850_add_columns_to_sales_invoices_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (545,'2025_06_14_115659_add_product_id_to_user_contracts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (546,'2025_06_14_134346_add_product_id_to_sales_contracts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (547,'2025_06_14_151643_add_id_to_maintenance_contract_assets_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (548,'2025_06_14_153807_add_code_to_maintenance_contracts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (549,'2025_06_15_072403_change_unit_in_completed_works_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (550,'2025_06_15_082534_add_item_to_materials_consumed_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (551,'2025_06_15_082638_add_item_to_equipment_usage_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (552,'2025_06_15_082707_add_item_to_time_cards_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (553,'2025_06_15_103549_add_item_to_sales_contracts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (554,'2025_06_15_105602_add_item_to_user_contracts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (555,'2025_06_15_105641_add_item_to_maintenance_contracts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (556,'2025_06_15_121209_add_item_to_purchase_order_contracts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (557,'2025_06_15_153550_add_user_id_to_backups_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (558,'2025_06_16_090351_add_status_to_main_inventories_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (559,'2025_06_16_093005_create_e_signature_models_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (560,'2025_06_16_095200_add_type_to_audit_checklists_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (561,'2025_06_16_163409_add_items_to_audit_checklists_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (562,'2025_06_16_170835_add_items_to_projects_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (563,'2025_06_16_173105_add_items_to_purchases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (564,'2025_06_16_173128_add_items_to_sales_invoices_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (565,'2025_06_17_081318_add_items_to_product_guides_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (566,'2025_06_17_082014_add_items_to_categories_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (567,'2025_06_17_174335_add_product_id_to_contacts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (568,'2025_06_17_213804_add_items_to_sales_contracts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (569,'2025_06_17_214146_create_contract_parties_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (570,'2025_06_18_111919_add_items_to_sales_contracts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (571,'2025_06_18_120850_add_items_to_add_items_to_contract_parties_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (572,'2025_06_18_133217_add_items_to_add_items_to_maintenance_contracts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (573,'2025_06_18_133236_add_items_to_add_items_to_user_contracts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (574,'2025_06_18_211259_add_items_to_add_items_to_equipment_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (575,'2025_06_19_115406_add_items_to_project_phases_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (576,'2025_06_19_120548_add_items_to_user_contracts_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (577,'2025_06_19_120742_add_items_to_contract_parties_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (578,'2025_06_19_141102_create_material_requests_table',2);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (579,'2025_06_21_132222_add_items_to_sales_contracts_table',3);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (580,'2025_06_21_144637_create_reminders_table',3);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (581,'2025_06_22_105417_add_item_to_contract_signatures_table',3);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (582,'2025_06_24_144144_add_clounms_to_item_phases_table',3);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (583,'2025_06_25_140957_add_clounms_to_e_signatures_table',3);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (584,'2025_06_25_181433_add_material_to_equipment_table',3);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (585,'2025_06_26_100627_add_items_to_change_requests_table',3);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (586,'2025_06_26_113522_add_items_to_contracts_table',3);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (587,'2025_06_26_115941_add_items_to_material_requests_table',3);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (588,'2025_06_26_125358_add_items_to_daily_records_table',3);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (589,'2025_06_28_094229_create_document_templates_table',3);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (590,'2025_06_28_173944_add_items_to_invoices_table',3);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (591,'2025_06_29_122018_add_items_to_sales_contracts_table',3);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (592,'2025_06_29_122910_add_items_to_user_contracts_table',3);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (593,'2025_06_29_123611_add_items_to_maintenance_contracts_table',3);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (594,'2025_06_29_124225_add_items_to_rental_contracts_table',3);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (595,'2025_06_30_151319_add_items_to_purchases_table',3);
