CREATE DATABASE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##` DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_bin;$EOL$
SET foreign_key_checks = 0;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`sanordo_clientdb_##CLIENT_ID##`.`api_user_logs` (
  `id` int NOT NULL AUTO_INCREMENT,
  `user_id` int DEFAULT NULL,
  `message` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `ip_address` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `is_master` tinyint DEFAULT NULL,
  `cr_date` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`branch_master` (
  `branch_id` int NOT NULL AUTO_INCREMENT,
  `branch_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `branch_code` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email` varchar(70) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `phone_code` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `phone` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `tel_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `gstin` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `pan_no` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `bank_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `bank_acc_no` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `bank_branch` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `bank_ifsc_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `address` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `city` int DEFAULT NULL,
  `state` int DEFAULT NULL,
  `pincode` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `country` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `invoice_address` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `sms_url` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `sms_api_headers` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `sms_api_data` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `sms_provider` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `whatsapp_url` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `whatsapp_api_headers` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `whatsapp_provider` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `default_message_medium` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT 'SMS',
  `payment_link_email_template` int DEFAULT NULL,
  `payment_link_sms_template` int DEFAULT NULL,
  `payment_link_whatsapp_template` int DEFAULT NULL,
  `http_method` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `dialer_provider` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `dial_api_url` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `dial_api_json` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `agent_dial_apikey` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `click_2_call_header_json` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `hangup_api_url` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `hangup_api_method` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `hangup_api_data` text COLLATE utf8mb4_unicode_ci,
  `hangup_api_header` text COLLATE utf8mb4_unicode_ci,
  `agent_dial_url` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `agent_dial_json` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `email_host` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email_username` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email_password` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email_port` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email_display_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `is_ssl` tinyint NOT NULL DEFAULT '0' COMMENT '1 require SSL connection, 0 not required',
  `signatory` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `branch_prefix` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `order_prefix_id` int DEFAULT NULL,
  `invoice_prefix_id` int DEFAULT NULL,
  `sign_img_path` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `invoice_remarks` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `origin_area` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` int DEFAULT NULL,
  `cr_usr` int DEFAULT NULL,
  `md_usr` int DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `is_default` tinyint NOT NULL DEFAULT '0',
  `vpp_address` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  PRIMARY KEY (`branch_id`),
  UNIQUE KEY `branch_name` (`branch_name`),
  UNIQUE KEY `branch_code` (`branch_code`),
  KEY `idx_branch_name` (`branch_name`),
  KEY `idx_dial_api_url` (`dial_api_url`),
  KEY `idx_city` (`city`),
  KEY `idx_state` (`state`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`branch_user_rights` (
  `id` int NOT NULL AUTO_INCREMENT,
  `user_id` int NOT NULL DEFAULT '0',
  `branch_id` int NOT NULL DEFAULT '0',
  `make_default` tinyint NOT NULL DEFAULT '0' COMMENT '1 - default, 0 -not default',
  `status` int NOT NULL DEFAULT '1' COMMENT '1 active 0 inactive',
  `ip_address` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `cr_usr` int DEFAULT NULL,
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  `md_usr` int DEFAULT NULL,
  `updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`call_logs` (
  `id` int NOT NULL AUTO_INCREMENT,
  `provider` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `ref_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `ref_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `user_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `calltype` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `source` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `disposition` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `calldate` datetime DEFAULT NULL,
  `duration` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `billsec` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `recfile` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `cr_date` datetime DEFAULT (now()),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`campaign_master` (
  `campaign_id` int NOT NULL AUTO_INCREMENT,
  `campaign_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` tinyint NOT NULL DEFAULT '1',
  `cr_usr` int DEFAULT NULL,
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  `md_usr` int DEFAULT NULL,
  `updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`campaign_id`) USING BTREE,
  UNIQUE KEY `Campaign_name` (`campaign_name`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`coupon_list` (
  `id` int NOT NULL AUTO_INCREMENT,
  `is_used` tinyint NOT NULL DEFAULT '0' COMMENT '0 unused 1 used',
  `coupon_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `coupon_master_id` int DEFAULT NULL,
  `status` int NOT NULL DEFAULT '1' COMMENT '1 active 0 inactive',
  `created_at` datetime NOT NULL DEFAULT (now()),
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE KEY `coupon_name` (`coupon_name`) USING BTREE,
  KEY `FK_coupon_list_coupon_master` (`coupon_master_id`),
  CONSTRAINT `FK_coupon_list_coupon_master` FOREIGN KEY (`coupon_master_id`) REFERENCES `coupon_master` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`coupon_master` (
  `id` int NOT NULL AUTO_INCREMENT,
  `coupon_title` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `coupon_count` int NOT NULL DEFAULT '1',
  `valid_from` datetime DEFAULT NULL,
  `valid_to` datetime DEFAULT NULL,
  `coupon_status_type` tinyint DEFAULT NULL COMMENT '1 Individual 2 Bulk ',
  `min_order_amount` decimal(10,2) DEFAULT NULL,
  `discount` decimal(10,2) DEFAULT NULL,
  `maximum_discount_amount` decimal(10,2) DEFAULT NULL,
  `user_apply_count` int DEFAULT NULL COMMENT 'No of times user can apply the coupon',
  `coupon_type` tinyint DEFAULT NULL COMMENT '1 percentage 2 fixed',
  `description` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Description About the coupon',
  `status` int NOT NULL DEFAULT '1' COMMENT '1 active 0 inactive',
  `ip_address` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `cr_usr` int DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `md_usr` int DEFAULT NULL,
  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE KEY `coupon_title` (`coupon_title`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`coupon_used` (
  `id` int NOT NULL AUTO_INCREMENT,
  `coupon_name` varchar(100) DEFAULT NULL,
  `order_id` int DEFAULT NULL,
  `coupon_id` int DEFAULT NULL,
  `customer_id` int DEFAULT NULL,
  `user_id` int DEFAULT NULL,
  `used_time` datetime DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint NOT NULL DEFAULT '1' COMMENT '1 active 2 inactive',
  `coupon_description` text,
  PRIMARY KEY (`id`),
  KEY `FK_tel_coupon_used_tel_order_master` (`order_id`),
  KEY `FK_tel_coupon_used_tel_customer_master` (`customer_id`),
  KEY `FK_tel_coupon_used_tel_coupon_list` (`coupon_id`),
  KEY `coupon_name` (`coupon_name`),
  CONSTRAINT `FK_tel_coupon_used_tel_coupon_list` FOREIGN KEY (`coupon_id`) REFERENCES `tel_coupon_list` (`id`),
  CONSTRAINT `FK_tel_coupon_used_tel_customer_master` FOREIGN KEY (`customer_id`) REFERENCES `tel_customer_master` (`id`),
  CONSTRAINT `FK_tel_coupon_used_tel_order_master` FOREIGN KEY (`order_id`) REFERENCES `tel_order_master` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`courier` (
  `id` int NOT NULL AUTO_INCREMENT,
  `courier_api` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `title` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `customer_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'For DTDC Customer ID | Blue Dart License Key',
  `login_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `api_key_password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `vendor_code` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `webhook_token` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `support_number` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `remarks` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `tracking_url` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` tinyint NOT NULL DEFAULT '1' COMMENT '1 active, 2 inactive',
  `api_create_awbno_url` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `api_tracking_url` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `pincode_servicability_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,
  `cr_usr` int DEFAULT NULL,
  `md_usr` int DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `webhook_token` (`webhook_token`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`courier_api` (
  `id` int NOT NULL AUTO_INCREMENT,
  `courier` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `api_create_awbno_url` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `api_tracking_url` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `pincode_servicability_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`courier_docketno` (
  `id` int NOT NULL AUTO_INCREMENT,
  `courier_id` int DEFAULT NULL,
  `docket_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `cr_usr` int DEFAULT NULL,
  `status` tinyint NOT NULL DEFAULT '0' COMMENT '0 unused 1 used',
  `used_time` datetime DEFAULT NULL,
  `order_id` int DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`courier_pincode` (
  `id` int NOT NULL AUTO_INCREMENT,
  `courier_id` int DEFAULT NULL,
  `pin_code` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `origin_area` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `process_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `cr_usr` int DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`customer_address_master` (
  `id` int NOT NULL AUTO_INCREMENT,
  `customer_id` int DEFAULT NULL,
  `address_title` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `address_pincode` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `address_state_id` int DEFAULT NULL,
  `address_city_id` int DEFAULT NULL,
  `address_mobile` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `address` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `gst` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `is_default` tinyint NOT NULL DEFAULT '0' COMMENT '1 - default, 0 -not default',
  `status` int NOT NULL DEFAULT '1' COMMENT '1 active 0 inactive',
  `ip_address` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `created_by_website` tinyint NOT NULL DEFAULT '0',
  `cr_usr` int DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `FKCutomer` (`customer_id`),
  KEY `FKState` (`address_state_id`),
  KEY `FKCity` (`address_city_id`),
  KEY `customer_id` (`customer_id`),
  KEY `address_pincode` (`address_pincode`),
  CONSTRAINT `FKCity` FOREIGN KEY (`address_city_id`) REFERENCES `location_city` (`id`),
  CONSTRAINT `FKCutomer` FOREIGN KEY (`customer_id`) REFERENCES `customer_master` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$

CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`customer_category_master` (
  `id` int NOT NULL AUTO_INCREMENT,
  `category_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `customer_type` int DEFAULT NULL COMMENT '1 customer 2 dealer 3 vendor',
  `status` int NOT NULL DEFAULT '1' COMMENT '1 active 0 inactive',
  `uid` int NOT NULL DEFAULT '0',
  `ip_address` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT (now()),
  `updated_at` datetime NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,
  `cr_usr` int DEFAULT NULL,
  `md_usr` int DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `category_name` (`category_name`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`customer_master` (
  `id` int NOT NULL AUTO_INCREMENT,
  `customer_name` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `customer_type` int DEFAULT NULL COMMENT '1=Dealer,2=Distributor, etc.',
  `user_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `dial_api` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Used for dial API at dealer end',
  `mobile_number` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `country_code` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `alt_mobile1` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `alt_mobile2` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `alt_mobile3` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `lead_source` int DEFAULT NULL COMMENT 'Lead source ID',
  `branch_id` int DEFAULT NULL,
  `status` tinyint NOT NULL DEFAULT '1' COMMENT '1=Active,2=Inactive',
  `ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT (now()),
  `updated_at` datetime NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,
  `password_otp` int DEFAULT NULL,
  `otp_request_time` datetime DEFAULT NULL,
  `created_by_website` tinyint NOT NULL DEFAULT '0' COMMENT '1=Created by Website,0=Other',
  `cr_usr` int DEFAULT NULL,
  `md_usr` int DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_branch_id` (`branch_id`),
  KEY `idx_user_name` (`user_name`),
  KEY `idx_mobile_number` (`mobile_number`),
  KEY `idx_alt_mobile1` (`alt_mobile1`),
  KEY `idx_alt_mobile2` (`alt_mobile2`),
  KEY `idx_email_id` (`email_id`),
  KEY `idx_customer_name` (`customer_name`),
  KEY `FK2_customer_type` (`customer_type`),
  CONSTRAINT `FK2_customer_type` FOREIGN KEY (`customer_type`) REFERENCES `customer_category_master` (`id`),
  CONSTRAINT `fk_customer_branch` FOREIGN KEY (`branch_id`) REFERENCES `branch_master` (`branch_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`custom_variables` (
  `id` int NOT NULL AUTO_INCREMENT,
  `var_key` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `var_value` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` tinyint NOT NULL DEFAULT (1) COMMENT '1 active 0 inactive',
  `created_at` datetime NOT NULL DEFAULT (now()),
  `cr_usr` int DEFAULT NULL,
  `updated_at` datetime NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,
  `md_usr` int DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE KEY `var_key` (`var_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`disposition_master` (
  `disposition_id` int NOT NULL AUTO_INCREMENT,
  `disposition_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `sub_dispositions` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` tinyint NOT NULL DEFAULT '1',
  `is_default` tinyint(1) NOT NULL DEFAULT '0',
  `cr_usr` int DEFAULT NULL,
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  `md_usr` int DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL,
  PRIMARY KEY (`disposition_id`) USING BTREE,
  UNIQUE KEY `uniq_disposition_name` (`disposition_name`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`email_sms_log` (
  `id` int NOT NULL AUTO_INCREMENT,
  `request_id` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `type` enum('email','whatsapp','sms') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `template_name` varchar(400) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `template_id` int DEFAULT NULL,
  `ref_id` int DEFAULT NULL,
  `ref_type` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `from` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `country_code` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `to` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `cc` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `bcc` varchar(250) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email_subject` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `body` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `attachment` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `response` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `transaction_id` varchar(150) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` tinyint DEFAULT '0',
  `sent` tinyint DEFAULT '0',
  `sent_at` datetime DEFAULT NULL,
  `created_at` datetime DEFAULT (now()),
  `cr_usr` int DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`inventory_type` (
  `id` int NOT NULL AUTO_INCREMENT,
  `inventory_type_name` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` int NOT NULL DEFAULT '1' COMMENT '1 active 0 inactive',
  `ip_address` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `cr_usr` int DEFAULT NULL,
  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `md_usr` int DEFAULT NULL,
  `created_by_website` tinyint NOT NULL DEFAULT '0',
  `isDefault` tinyint NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`invoice_type` (
  `id` int NOT NULL AUTO_INCREMENT,
  `title` varchar(150) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `inv_prefix` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `min_length` int NOT NULL DEFAULT '4',
  `status` int NOT NULL DEFAULT '1' COMMENT '1 active 0 inactive',
  `ip_address` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `cr_usr` int DEFAULT NULL,
  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `md_usr` int DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`itemcategorytax_master` (
  `cattax_id` int NOT NULL AUTO_INCREMENT,
  `cat_id` int DEFAULT NULL,
  `tax_id` int DEFAULT NULL,
  `tax_percentage` decimal(10,2) NOT NULL DEFAULT '0.00',
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `cr_usr` int DEFAULT NULL,
  PRIMARY KEY (`cattax_id`),
  KEY `FKItem_Category` (`cat_id`),
  KEY `FKTax` (`tax_id`),
  KEY `cat_id` (`cat_id`),
  KEY `tax_id` (`tax_id`),
  CONSTRAINT `FKItem_Category` FOREIGN KEY (`cat_id`) REFERENCES `itemcategory_master` (`itemcat_id`),
  CONSTRAINT `FKTax` FOREIGN KEY (`tax_id`) REFERENCES `tax_master` (`tax_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`itemcategory_master` (
  `itemcat_id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `hsn_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `total_tax` decimal(10,2) NOT NULL DEFAULT '0.00',
  `status` int NOT NULL DEFAULT '1',
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `cr_usr` int DEFAULT NULL,
  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `md_usr` int DEFAULT NULL,
  PRIMARY KEY (`itemcat_id`),
  KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`item_group_master` (
  `id` int NOT NULL AUTO_INCREMENT,
  `group_name` varchar(250) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL,
  `sequence` int NOT NULL DEFAULT '0',
  `sale` int NOT NULL DEFAULT '1' COMMENT '1 yes 0 No',
  `purchase` int NOT NULL DEFAULT '1' COMMENT '1 yes 0 No',
  `status` int NOT NULL DEFAULT '1' COMMENT '1 active 2 inactive',
  `uid` int NOT NULL DEFAULT '0',
  `ip_address` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT (now()),
  `updated_at` datetime NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,
  `cr_usr` int DEFAULT NULL,
  `md_usr` int DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT;
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`item_master` (
  `item_id` int NOT NULL AUTO_INCREMENT,
  `item_name` varchar(190) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `item_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `category_id` int DEFAULT NULL,
  `group_id` int NOT NULL DEFAULT '0',
  `item_desc` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin,
  `unit` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `rate` decimal(10,2) DEFAULT NULL,
  `total_rate` decimal(10,2) DEFAULT '0.00',
  `including_tax` tinyint DEFAULT '0' COMMENT '0 not including 1 including',
  `allow_negative_stock` tinyint DEFAULT '0',
  `img_path` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `variant_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` int DEFAULT NULL,
  `cr_usr` int DEFAULT NULL,
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  `ip_address` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `md_usr` int DEFAULT NULL,
  PRIMARY KEY (`item_id`),
  KEY `item_name` (`item_name`),
  KEY `item_code` (`item_code`),
  KEY `category_id` (`category_id`),
  KEY `FKItemGroup` (`group_id`),
  CONSTRAINT `FKItemCateId` FOREIGN KEY (`category_id`) REFERENCES `itemcategory_master` (`itemcat_id`),
  CONSTRAINT `FKItemGroup` FOREIGN KEY (`group_id`) REFERENCES `item_group_master` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`item_package_item_mapping` (
  `id` int NOT NULL AUTO_INCREMENT,
  `package_id` int DEFAULT NULL,
  `item_id` int DEFAULT NULL,
  `quantity` int NOT NULL DEFAULT '0',
  `rate` decimal(10,0) NOT NULL DEFAULT '0',
  `status` int NOT NULL DEFAULT '1',
  `cr_usr` int DEFAULT NULL,
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `md_usr` int DEFAULT NULL,
  `ip_address` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `FKPackage` (`package_id`),
  KEY `FK2Item` (`item_id`),
  CONSTRAINT `FK2Item` FOREIGN KEY (`item_id`) REFERENCES `item_master` (`item_id`) ON DELETE SET NULL ON UPDATE CASCADE,
  CONSTRAINT `FKPackage` FOREIGN KEY (`package_id`) REFERENCES `item_package_master` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`item_package_master` (
  `id` int NOT NULL AUTO_INCREMENT,
  `package_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `item_count` int NOT NULL DEFAULT '0',
  `package_cost` decimal(10,0) NOT NULL DEFAULT '0',
  `remarks` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin,
  `status` int DEFAULT NULL,
  `cr_usr` int DEFAULT NULL,
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `md_usr` int DEFAULT NULL,
  `ip_address` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `package_name` (`package_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`item_rate_master` (
  `id` int NOT NULL AUTO_INCREMENT,
  `item_id` int DEFAULT NULL,
  `customer_type` int DEFAULT NULL,
  `item_rate` decimal(10,2) NOT NULL DEFAULT '0.00',
  `item_total_rate` decimal(10,2) NOT NULL DEFAULT '0.00',
  `cr_usr` int DEFAULT NULL,
  `created_at` datetime DEFAULT (now()),
  PRIMARY KEY (`id`),
  KEY `FKItemId` (`item_id`),
  CONSTRAINT `FKItemId` FOREIGN KEY (`item_id`) REFERENCES `item_master` (`item_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`item_stock` (
  `stock_id` int NOT NULL AUTO_INCREMENT,
  `uid` int NOT NULL DEFAULT '0',
  `item_id` int DEFAULT NULL,
  `branch_id` int DEFAULT NULL,
  `opening_stock` decimal(10,2) NOT NULL DEFAULT '0.00',
  `stock_in` decimal(10,2) NOT NULL DEFAULT '0.00',
  `stock_out` decimal(10,2) NOT NULL DEFAULT '0.00',
  `stock` decimal(10,2) NOT NULL DEFAULT '0.00',
  `opening_time_update` int NOT NULL DEFAULT '0',
  `order_time_update` int NOT NULL DEFAULT '0',
  `rol` decimal(10,2) DEFAULT NULL,
  `cr_usr` int DEFAULT NULL,
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `md_usr` int DEFAULT NULL,
  `ip_address` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`stock_id`),
  UNIQUE KEY `item_id` (`item_id`,`branch_id`),
  KEY `FKItem` (`item_id`),
  KEY `FKBranch` (`branch_id`),
  CONSTRAINT `FKBranch` FOREIGN KEY (`branch_id`) REFERENCES `branch_master` (`branch_id`),
  CONSTRAINT `FKItem` FOREIGN KEY (`item_id`) REFERENCES `item_master` (`item_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`leads` (
  `id` int NOT NULL AUTO_INCREMENT,
  `order_id` int DEFAULT NULL,
  `customer_id` int DEFAULT NULL,
  `contact_code` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `contact_no` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `client_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `branch` int DEFAULT NULL,
  `alt_contact_no` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `alt_contact_code` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `lead_date` date DEFAULT NULL,
  `city` int DEFAULT NULL,
  `state` int DEFAULT NULL,
  `pincode` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `lead_type` int DEFAULT NULL,
  `assign_to` int DEFAULT NULL,
  `lead_status` int DEFAULT NULL,
  `lead_source` int DEFAULT NULL,
  `reference_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `customer_type` int DEFAULT NULL,
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `payment_type` int DEFAULT NULL,
  `status` tinyint DEFAULT '1',
  `payment_terms` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `delivery_terms` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `contact_person` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `client_gst` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `pdf_title` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `additional_discount` decimal(10,2) DEFAULT NULL,
  `discount_amt` decimal(10,2) DEFAULT NULL,
  `gross_amt` decimal(10,2) DEFAULT NULL,
  `net_amount` decimal(10,2) DEFAULT NULL,
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `round_off_amt` decimal(10,2) DEFAULT NULL,
  `tax_amt` decimal(10,2) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `cr_usr` int DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL,
  `md_usr` int DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `FK2_city` (`city`),
  KEY `FK2_branch` (`branch`),
  KEY `FK3_pincode` (`pincode`),
  KEY `FK4_leadType` (`lead_type`),
  KEY `FK5_leadStatus` (`lead_status`),
  KEY `FK6_leadSource` (`lead_source`),
  KEY `FK7_customerType` (`customer_type`),
  KEY `FK11_paymentType` (`payment_type`),
  KEY `FK9_lead_order_id` (`order_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`lead_flp_log` (
  `id` int NOT NULL AUTO_INCREMENT,
  `flp_lead_id` int DEFAULT NULL,
  `lead_flp_comment` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `lead_flp_status` int DEFAULT NULL,
  `lead_flp_date` datetime DEFAULT NULL,
  `cr_usr` int DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `FK1_flp_lead_id` (`flp_lead_id`),
  KEY `FK2_lead_status` (`lead_flp_status`),
  CONSTRAINT `FK1_flp_lead_id` FOREIGN KEY (`flp_lead_id`) REFERENCES `leads` (`id`),
  CONSTRAINT `FK2_lead_status` FOREIGN KEY (`lead_flp_status`) REFERENCES `lead_status` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`lead_item_list` (
  `id` int NOT NULL AUTO_INCREMENT,
  `lead_id` int DEFAULT NULL,
  `category_id` int DEFAULT NULL,
  `item_id` int DEFAULT NULL,
  `item_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `item_package_id` int DEFAULT NULL,
  `hsn_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `rate` decimal(10,2) DEFAULT NULL,
  `including_tax` tinyint DEFAULT NULL,
  `mrp` decimal(10,2) DEFAULT NULL,
  `qty` decimal(10,2) DEFAULT NULL,
  `discount` decimal(10,2) DEFAULT NULL,
  `discount_amount` decimal(10,2) DEFAULT NULL,
  `discount_type` tinyint DEFAULT '1' COMMENT '1 Percentage 2 Fixed',
  `amount` decimal(10,2) DEFAULT NULL,
  `tax_percentage` decimal(10,2) DEFAULT NULL,
  `tax_amount` decimal(10,2) DEFAULT NULL,
  `total_amount` decimal(10,2) DEFAULT NULL,
  `item_detail` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `cr_usr` int DEFAULT NULL,
  `created_at` datetime DEFAULT (now()),
  PRIMARY KEY (`id`),
  KEY `FK1_leadid` (`lead_id`),
  KEY `FK2_lead_item_id` (`item_id`),
  KEY `item_package_id` (`item_package_id`),
  CONSTRAINT `FK1_leadid` FOREIGN KEY (`lead_id`) REFERENCES `leads` (`id`),
  CONSTRAINT `FK2_lead_item_id` FOREIGN KEY (`item_id`) REFERENCES `item_master` (`item_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`lead_order_logs` (
  `id` int NOT NULL AUTO_INCREMENT,
  `req_id` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `lead_id` int DEFAULT NULL,
  `process` int DEFAULT '0',
  `status` int DEFAULT '0',
  `response` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` datetime DEFAULT (now()),
  `updated_at` datetime DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `FK1_lead_log_lead_id` (`lead_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`lead_source` (
  `id` int NOT NULL AUTO_INCREMENT,
  `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `image` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `api_url` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `api_method` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `api_request` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `api_provider` int DEFAULT NULL,
  `img_path` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `status` tinyint DEFAULT '1',
  `created_at` datetime DEFAULT NULL,
  `cr_usr` int DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL,
  `md_usr` int DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `title` (`title`),
  KEY `FK1_api_providerr` (`api_provider`),
  CONSTRAINT `FK1_api_providerr` FOREIGN KEY (`api_provider`) REFERENCES `api_provider` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`lead_status` (
  `id` int NOT NULL AUTO_INCREMENT,
  `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `lead_status_type` int DEFAULT NULL,
  `color_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `create_order` tinyint DEFAULT '0',
  `sms_template_id` int DEFAULT NULL,
  `whatsapp_template_id` int DEFAULT NULL,
  `email_template_id` int DEFAULT NULL,
  `sub_status` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` tinyint DEFAULT '1',
  `created_at` datetime DEFAULT NULL,
  `cr_usr` int DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL,
  `md_usr` int DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `FK2_sms` (`sms_template_id`),
  KEY `FK3_whatsApp` (`whatsapp_template_id`),
  KEY `FK4_email` (`email_template_id`),
  CONSTRAINT `FK2_sms` FOREIGN KEY (`sms_template_id`) REFERENCES `order_message_template` (`id`),
  CONSTRAINT `FK3_whatsApp` FOREIGN KEY (`whatsapp_template_id`) REFERENCES `order_message_template` (`id`),
  CONSTRAINT `FK4_email` FOREIGN KEY (`email_template_id`) REFERENCES `order_message_template` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`lead_tax_list` (
  `id` int NOT NULL AUTO_INCREMENT,
  `lead_id` int DEFAULT NULL,
  `item_id` int DEFAULT NULL,
  `item_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `tax_id` int DEFAULT NULL,
  `tax_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `tax_percentage` decimal(10,2) DEFAULT NULL,
  `taxable_amount` decimal(10,2) DEFAULT NULL,
  `tax_amount` decimal(10,2) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `FK1_lead_id` (`lead_id`),
  CONSTRAINT `FK1_lead_id` FOREIGN KEY (`lead_id`) REFERENCES `leads` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`lead_type` (
  `id` int NOT NULL AUTO_INCREMENT,
  `lead_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` int NOT NULL DEFAULT '1' COMMENT '1 active 0 inactive',
  `isDefault` tinyint NOT NULL DEFAULT '0',
  `ip_address` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `cr_usr` int DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `md_usr` int DEFAULT NULL,
  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE KEY `lead_name` (`lead_name`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`location_city` (
  `id` int NOT NULL AUTO_INCREMENT,
  `city_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `state_id` int DEFAULT NULL COMMENT 'State id',
  `status` tinyint NOT NULL DEFAULT '1' COMMENT '1 active, 2 inactive',
  `ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by_website` tinyint NOT NULL DEFAULT '0',
  `cr_usr` int DEFAULT NULL,
  `md_usr` int DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_city_name` (`city_name`),
  KEY `idx_state_id` (`state_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`location_pincode` (
  `id` int NOT NULL AUTO_INCREMENT,
  `pincode` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `origin_area` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `city_id` int DEFAULT NULL COMMENT 'for city',
  `state_id` int DEFAULT NULL COMMENT 'State id',
  `min_delivery_days` int DEFAULT '0',
  `max_delivery_days` int DEFAULT '0',
  `courier_id` int DEFAULT NULL,
  `dealer_id` int DEFAULT NULL,
  `status` tinyint NOT NULL DEFAULT '1' COMMENT '1 active, 2 inactive',
  `ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by_website` tinyint NOT NULL DEFAULT '0',
  `cr_usr` int DEFAULT NULL,
  `md_usr` int DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_pincode` (`pincode`),
  KEY `idx_city_id` (`city_id`),
  KEY `idx_state_id` (`state_id`),
  KEY `idx_dealer_id` (`dealer_id`),
  KEY `idx_courier_id` (`courier_id`),
  CONSTRAINT `FK_pincode_city` FOREIGN KEY (`city_id`) REFERENCES `location_city` (`id`),
  CONSTRAINT `FK_pincode_courier` FOREIGN KEY (`courier_id`) REFERENCES `courier` (`id`),
  CONSTRAINT `FK_pincode_dealer` FOREIGN KEY (`dealer_id`) REFERENCES `customer_master` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`order_assign_logs` (
  `id` int NOT NULL AUTO_INCREMENT,
  `request_id` varchar(250) DEFAULT NULL,
  `order_id` int DEFAULT NULL,
  `is_assign` int DEFAULT '1',
  `assigned_by` int DEFAULT NULL,
  `assigned_to` int DEFAULT NULL,
  `last_assigned` int DEFAULT NULL,
  `assigned_on` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `o_group_id` int DEFAULT NULL,
  `o_group_name` varchar(50) DEFAULT NULL,
  `o_manager_id` int DEFAULT NULL,
  `o_manager_name` varchar(50) DEFAULT NULL,
  `o_tl_id` int DEFAULT NULL,
  `o_tl_name` varchar(50) DEFAULT NULL,
  `status` tinyint(1) DEFAULT '0' COMMENT '0=>Pending, 1=>Success, 2=>Failed',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `status` (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`order_attachments` (
  `id` int NOT NULL AUTO_INCREMENT,
  `file_name` varchar(400) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `size` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `mime` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `order_id` int DEFAULT NULL,
  `path` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `cr_usr` int DEFAULT NULL,
  `cr_date` datetime DEFAULT (now()),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`order_courier` (
  `order_courier_id` int NOT NULL AUTO_INCREMENT,
  `order_id` int DEFAULT NULL,
  `awb_gen_using_api` int NOT NULL DEFAULT '0' COMMENT '1 To generate AWB using API',
  `courier_product_name` varchar(500) DEFAULT NULL,
  `courier_api_type` varchar(200) DEFAULT NULL,
  `courier_weight` varchar(10) DEFAULT NULL,
  `courier_height` varchar(10) DEFAULT NULL,
  `courier_length` varchar(10) DEFAULT NULL,
  `courier_breath` varchar(10) DEFAULT NULL,
  `courier_payment_mode` varchar(25) DEFAULT 'c' COMMENT 'c for cash p for prepaid',
  `courier_ewaybill_no` varchar(50) DEFAULT NULL,
  `courier_transdistance` varchar(25) DEFAULT NULL,
  `courier_transporter_id` varchar(250) DEFAULT NULL,
  `courier_transporter_name` varchar(250) DEFAULT NULL,
  `courier_type_of_delivery` varchar(250) DEFAULT NULL,
  `courier_type_of_service` varchar(250) DEFAULT NULL,
  `courier_unit_of_measure` varchar(250) DEFAULT NULL,
  `origin_area` varchar(250) DEFAULT NULL,
  `customer_code` varchar(250) DEFAULT NULL,
  `product_type` varchar(250) DEFAULT NULL,
  `pickup_date` date DEFAULT NULL,
  `pickup_hour` varchar(50) DEFAULT NULL,
  `pickup_minutes` varchar(50) DEFAULT NULL,
  `totime_hour` varchar(50) DEFAULT NULL,
  `totime_minutes` varchar(50) DEFAULT NULL,
  `courier_service_type` varchar(100) DEFAULT NULL,
  `courier_airway_bill_number` varchar(100) DEFAULT NULL,
  `courier_mainfest_id` varchar(100) DEFAULT NULL,
  `customer_origin_area` varchar(50) DEFAULT NULL,
  `courier_voulmetric_weight` decimal(10,2) DEFAULT '0.00',
  `courier_packing_type` varchar(150) DEFAULT NULL,
  `image_pdf` text,
  PRIMARY KEY (`order_courier_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT;
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`order_item_list` (
  `id` int NOT NULL AUTO_INCREMENT,
  `order_id` int DEFAULT NULL,
  `category_id` int DEFAULT NULL,
  `item_id` int DEFAULT NULL,
  `item_name` varchar(190) DEFAULT NULL,
  `item_package_id` int DEFAULT NULL COMMENT 'Package ID',
  `hsn_code` varchar(12) DEFAULT NULL,
  `rate` decimal(10,2) DEFAULT '0.00',
  `including_tax` tinyint DEFAULT '0',
  `mrp` decimal(10,2) DEFAULT '0.00',
  `qty` decimal(10,2) DEFAULT '0.00',
  `discount` decimal(10,2) DEFAULT '0.00',
  `discount_amount` decimal(10,2) DEFAULT '0.00',
  `discount_type` tinyint DEFAULT '1' COMMENT '1 Percentage 2 Fixed',
  `amount` decimal(10,2) DEFAULT '0.00',
  `tax_percentage` decimal(10,2) DEFAULT '0.00',
  `tax_amount` decimal(10,2) DEFAULT '0.00',
  `total_amount` decimal(10,2) DEFAULT NULL,
  `item_detail` text,
  `updated_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `time_created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `ip_address` varchar(15) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `FK_tel_order_item_list_tel_order_master` (`order_id`),
  KEY `FK_tel_order_item_list_tel_item_master` (`item_id`),
  KEY `FK_tel_order_item_list_tel_itemcategory_master` (`category_id`),
  KEY `order_id` (`order_id`),
  KEY `item_id` (`item_id`),
  KEY `FK_tel_order_item_list_tel_item_package_master` (`item_package_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT;
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`order_logic` (
  `logic_id` int NOT NULL AUTO_INCREMENT,
  `order_status_id` int DEFAULT NULL,
  `status_action_id` int DEFAULT NULL,
  `status` tinyint NOT NULL DEFAULT '1' COMMENT '1 active 0 inactive',
  `ip_address` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `cr_usr` int DEFAULT '0',
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`logic_id`),
  KEY `FK_order_logic_order_status` (`order_status_id`),
  KEY `FK_action_order_status` (`status_action_id`),
  KEY `order_status_id` (`order_status_id`),
  KEY `status_action_id` (`status_action_id`),
  CONSTRAINT `FK_action_order_status` FOREIGN KEY (`status_action_id`) REFERENCES `order_status` (`id`),
  CONSTRAINT `FK_order_logic_order_status` FOREIGN KEY (`order_status_id`) REFERENCES `order_status` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`order_logs` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `order_id` int NOT NULL DEFAULT '0',
  `user_id` int NOT NULL DEFAULT '0',
  `update_type` tinyint NOT NULL DEFAULT '1' COMMENT '1 CRM 2 Dealer - to map dealer in user_id',
  `last_status_id` int NOT NULL DEFAULT '0',
  `current_status_id` int NOT NULL DEFAULT '0',
  `log_message` text,
  `allocate_uid` int DEFAULT NULL,
  `remarks` text,
  `assign_uid` int DEFAULT NULL,
  `status` int NOT NULL DEFAULT '1' COMMENT '1 active 2 inactive',
  `ip_address` varchar(50) DEFAULT NULL,
  `time_created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `time_updated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `order_id` (`order_id`),
  KEY `last_status_id` (`last_status_id`),
  KEY `current_status_id` (`current_status_id`),
  KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT;
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`order_master` (
  `id` int NOT NULL AUTO_INCREMENT,
  `lead_id` int DEFAULT NULL,
  `customer_order_id` varchar(20) DEFAULT NULL,
  `order_series` int DEFAULT NULL,
  `order_prefix_id` int DEFAULT NULL,
  `invoice_prefix_id` int DEFAULT NULL,
  `branch_id` int DEFAULT '0',
  `customer_id` int DEFAULT '0',
  `address_id` int DEFAULT '0',
  `customer_address` text,
  `shopify_created_at` datetime DEFAULT NULL,
  `same_as_shipping` tinyint NOT NULL DEFAULT '0' COMMENT '1 Same as Billing 0 diffrent',
  `customer_billing_address` text,
  `customer_detail` text,
  `customer_type` varchar(15) DEFAULT 'Customer',
  `package_id` varchar(50) DEFAULT NULL COMMENT 'Comma seprated Multiple package IDs',
  `dealer_id` int DEFAULT '0',
  `quotation_id` int DEFAULT NULL,
  `order_assign_type` tinyint NOT NULL DEFAULT '0' COMMENT '0 self 1 dealer',
  `lead_type` int DEFAULT NULL,
  `payment_type` int DEFAULT '0',
  `transaction_id` varchar(50) DEFAULT NULL,
  `notes` text CHARACTER SET utf32 COLLATE utf32_unicode_ci,
  `total_no_item` int DEFAULT NULL,
  `advance_payment` decimal(10,2) DEFAULT '0.00',
  `courier_charges` decimal(10,2) DEFAULT '0.00',
  `gross_amt` decimal(10,2) DEFAULT NULL,
  `discount_amt` decimal(10,2) DEFAULT '0.00',
  `partial_payment` decimal(10,2) NOT NULL DEFAULT '0.00',
  `additional_discount` decimal(10,2) DEFAULT '0.00',
  `tax_amt` decimal(10,2) DEFAULT NULL,
  `round_off_amt` decimal(10,2) DEFAULT NULL,
  `vpp_disc_percentage` decimal(10,2) NOT NULL DEFAULT '0.00',
  `vpp_disc_amt` decimal(10,2) NOT NULL DEFAULT '0.00',
  `net_amt` decimal(10,2) DEFAULT NULL,
  `order_booked_by_id` int DEFAULT '0',
  `order_booked_by_name` varchar(70) DEFAULT NULL,
  `updated_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `update_order_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `booking_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `hold_till` datetime DEFAULT NULL,
  `current_order_status` int DEFAULT NULL COMMENT 'Order Status ID',
  `order_summary` text,
  `invoice_series` int DEFAULT NULL,
  `invoice_number` varchar(20) DEFAULT NULL,
  `invoice_date` date DEFAULT NULL,
  `invoice_return_date` date DEFAULT NULL,
  `dispatch_date` date DEFAULT NULL,
  `courier_name` varchar(30) DEFAULT NULL,
  `courier_id` int DEFAULT NULL,
  `order_coupon_id` int DEFAULT '0',
  `coupon_code` varchar(30) DEFAULT NULL,
  `docket_number` varchar(30) DEFAULT NULL,
  `payment_date` date DEFAULT NULL,
  `rto_date` date DEFAULT NULL,
  `delivery_date` datetime DEFAULT NULL,
  `last_allocate_uid` int DEFAULT '0',
  `stock_status` tinyint NOT NULL DEFAULT '0' COMMENT '1 stock in eg return,cancel - 2 stock out on new order place',
  `ip_address` varchar(15) DEFAULT NULL,
  `pdfline_count` int DEFAULT '5',
  `courier_expected_del_date` date DEFAULT NULL,
  `order_created_by_id` int DEFAULT NULL,
  `expected_carrier_id` int DEFAULT NULL,
  `paymentgateway` tinyint DEFAULT NULL,
  `payment_confirm_id` varchar(50) DEFAULT NULL,
  `payment_response_json` text,
  `payment_status` enum('SUCCESS','FAILED','PENDING') DEFAULT NULL,
  `transaction_date_time` datetime DEFAULT NULL,
  `is_open` tinyint DEFAULT '0',
  `opened_by` int DEFAULT NULL,
  `opened_time` datetime DEFAULT NULL,
  `lead_date` datetime DEFAULT NULL,
  `shopify_id` varchar(20) DEFAULT NULL,
  `shopify_number` varchar(20) DEFAULT NULL,
  `shopify_log_id` int DEFAULT NULL,
  `delivery_attempt` int(1) unsigned zerofill NOT NULL DEFAULT '0',
  `call_type` varchar(13) DEFAULT NULL,
  `order_platform_origin` tinyint(1) unsigned zerofill NOT NULL DEFAULT '0',
  `is_paid` tinyint unsigned NOT NULL DEFAULT '0',
  `courier_fedex_jobid` varchar(50) DEFAULT NULL,
  `confirm_by` tinyint(1) DEFAULT NULL COMMENT '1 whatsapp, 2 manual , 0 pending',
  `razorpay_order_id` varchar(160) DEFAULT NULL,
  `razorpay_order_id_update` datetime DEFAULT NULL,
  `remarks` text,
  `o_group_id` int DEFAULT NULL,
  `o_group_name` varchar(50) DEFAULT NULL,
  `o_manager_id` int DEFAULT NULL,
  `o_manager_name` varchar(50) DEFAULT NULL,
  `o_tl_id` int DEFAULT NULL,
  `o_tl_name` varchar(50) DEFAULT NULL,
  `next_subscription_date` date DEFAULT NULL,
  `archive` tinyint(1) DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `customer_order_id` (`customer_order_id`),
  KEY `FK_tel_purchase_master_tel_customer_master` (`customer_id`),
  KEY `FK_tel_order_master_tel_customer_address_master` (`address_id`),
  KEY `FK_tel_order_master_tel_payment_type` (`payment_type`),
  KEY `FK_tel_order_master_cds_users_master` (`order_booked_by_id`),
  KEY `customer_id` (`customer_id`),
  KEY `address_id` (`address_id`),
  KEY `dealer_id` (`dealer_id`),
  KEY `dispatch_date` (`dispatch_date`),
  KEY `last_allocate_uid` (`last_allocate_uid`),
  KEY `FK_tel_order_master_tel_coupon_list` (`order_coupon_id`),
  KEY `docket` (`docket_number`),
  KEY `razorpay_order_id` (`razorpay_order_id`),
  KEY `booking_time` (`booking_time`),
  KEY `FK_tel_purchase_master_tel_branch_master` (`branch_id`,`order_prefix_id`) USING BTREE,
  KEY `shopify_number` (`shopify_number`),
  KEY `order_series` (`order_series`),
  KEY `branch_id` (`branch_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT;
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`order_message_template` (
  `id` int NOT NULL AUTO_INCREMENT,
  `template_name` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `subject` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `template_body` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `temp_type` enum('SMS','Email','WhatsApp') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'SMS',
  `template_for` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email_type` enum('TEXT','FORM') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT 'TEXT',
  `sender_id` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `dlt_template_id` varchar(150) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `whatsapp_provider` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `is_whatsapp_business_template` tinyint NOT NULL DEFAULT '0',
  `status` int NOT NULL DEFAULT '1' COMMENT '1 active 0 inactive',
  `ip_address` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `tempKey` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `cr_usr` int DEFAULT NULL,
  `md_usr` int DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`order_payment_link_logs` (
  `id` int NOT NULL AUTO_INCREMENT,
  `request_id` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `medium` enum('email','sms','whatsapp') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `order_id` int DEFAULT NULL,
  `status` tinyint DEFAULT '0' COMMENT '0=>Pending, 1=Success, 2=>Failed',
  `fail_reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `cr_date` datetime DEFAULT (now()),
  `md_date` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  `cr_usr` int DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  KEY `status` (`status`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`order_shopify_log` (
  `id` int NOT NULL AUTO_INCREMENT,
  `order_id` int DEFAULT NULL,
  `status` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT '0' COMMENT '0=>Pending, 1=>Suiccess,2=>Failed,3=>In process',
  `type` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL,
  `url` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `headers` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `request_method` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `request` text CHARACTER SET latin1 COLLATE latin1_swedish_ci,
  `response` text CHARACTER SET latin1 COLLATE latin1_swedish_ci,
  `failed_reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `cr_date` datetime DEFAULT CURRENT_TIMESTAMP,
  `md_date` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  `cr_usr` int DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`order_shopify_process_log` (
  `id` int NOT NULL AUTO_INCREMENT,
  `order_id` int DEFAULT NULL,
  `status` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT '0' COMMENT '0=>Pending, 1=>Suiccess,2=>Failed,3=>In process',
  `failed_reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `cr_date` datetime DEFAULT (now()),
  `md_date` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  `cr_usr` int DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`order_status` (
  `id` int NOT NULL AUTO_INCREMENT,
  `uid` int NOT NULL DEFAULT '0',
  `status_name` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status_sequence` int NOT NULL DEFAULT '0',
  `color_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `sms_template_id` int DEFAULT NULL,
  `email_template_id` int DEFAULT NULL,
  `whatsapp_template_id` int DEFAULT NULL,
  `status` int NOT NULL DEFAULT '1' COMMENT '1 active 0 inactive',
  `ip_address` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `order_editable` tinyint NOT NULL DEFAULT '0' COMMENT '0 not editable 1 editable',
  `mark_as_default_complete` tinyint DEFAULT '0' COMMENT '1 mark as default 2 mark as completed',
  `stock_in_out` tinyint NOT NULL DEFAULT '0' COMMENT '1 stock in 2 stock out ',
  `status_type` tinyint NOT NULL DEFAULT '0' COMMENT '1 invoice 2 dispatch 3 payment 4 delivery 5 hold 6 Item Verify 7 for cancelled 8 for RTO 9 for multi order button',
  `hit_api_to_client` tinyint NOT NULL DEFAULT '0',
  `api_url` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `show_payment_link` tinyint DEFAULT NULL,
  `cr_usr` int DEFAULT NULL,
  `md_usr` int DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `FKEmail_template` (`email_template_id`),
  KEY `FKSMS_template` (`sms_template_id`),
  KEY `status_name` (`status_name`),
  CONSTRAINT `FKEmail_template` FOREIGN KEY (`email_template_id`) REFERENCES `order_message_template` (`id`),
  CONSTRAINT `FKSMS_template` FOREIGN KEY (`sms_template_id`) REFERENCES `order_message_template` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`order_status_update_logs` (
  `id` int NOT NULL AUTO_INCREMENT,
  `request_id` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `order_id` int DEFAULT NULL,
  `current_status_id` int DEFAULT NULL,
  `next_status_id` int DEFAULT NULL,
  `request_data` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `status` tinyint DEFAULT '0' COMMENT '0=>Pending, 1=Success, 2=>Failed',
  `fail_reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `cr_date` datetime DEFAULT (now()),
  `md_date` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  `cr_usr` int DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  KEY `status` (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`order_status_update_shopify_log` (
  `id` int NOT NULL AUTO_INCREMENT,
  `order_id` int DEFAULT NULL,
  `shopify_id` text,
  `log_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `api_respose` text,
  `api_request` text,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`order_status_update_webhook_log` (
  `log_id` int NOT NULL AUTO_INCREMENT,
  `courier_api` varchar(100) DEFAULT NULL,
  `docket_no` varchar(200) DEFAULT NULL,
  `order_id` int DEFAULT NULL,
  `respose` text CHARACTER SET latin1 COLLATE latin1_swedish_ci,
  `payload` text CHARACTER SET latin1 COLLATE latin1_swedish_ci,
  `log_date` datetime NOT NULL DEFAULT (now()),
  PRIMARY KEY (`log_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`order_taxlist` (
  `list_id` int NOT NULL AUTO_INCREMENT,
  `order_id` int DEFAULT NULL,
  `item_id` int DEFAULT NULL,
  `item_name` varchar(190) DEFAULT NULL,
  `tax_id` int DEFAULT NULL,
  `tax_name` varchar(8) DEFAULT NULL,
  `tax_percentage` decimal(10,2) DEFAULT NULL,
  `taxable_amount` decimal(10,2) DEFAULT NULL,
  `tax_amount` decimal(10,2) DEFAULT NULL,
  PRIMARY KEY (`list_id`),
  KEY `FK_tel_purchase_taxlist_tel_purchase_master` (`order_id`),
  KEY `FK_tel_purchase_taxlist_tel_item_master` (`item_id`),
  KEY `FK_tel_purchase_taxlist_tel_tax_master` (`tax_id`),
  KEY `order_id` (`order_id`),
  KEY `item_id` (`item_id`),
  KEY `tax_id` (`tax_id`),
  KEY `item_name` (`item_name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT;
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`payment_gateway` (
  `id` int NOT NULL AUTO_INCREMENT,
  `api` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `mode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `secret` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `token` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `channel` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `productionUrl` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `stageUrl` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `website` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `client` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `isDefault` tinyint NOT NULL DEFAULT (0),
  `webhook_token` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` int NOT NULL DEFAULT '1' COMMENT '1 active 0 inactive',
  `created_at` datetime DEFAULT (now()),
  `cr_usr` int DEFAULT NULL,
  `updated_at` datetime DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,
  `md_usr` int DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`payment_type` (
  `id` int NOT NULL AUTO_INCREMENT,
  `payment_name` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status_sequence` int NOT NULL DEFAULT '0',
  `status` int NOT NULL DEFAULT '1' COMMENT '1 active 0 inactive',
  `ip_address` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `cr_usr` int DEFAULT NULL,
  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `md_usr` int DEFAULT NULL,
  `created_by_website` tinyint NOT NULL DEFAULT '0',
  `isDefault` tinyint NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `payment_name` (`payment_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`payment_webhook_logs` (
  `id` int NOT NULL AUTO_INCREMENT,
  `api` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `payload` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `cr_date` datetime DEFAULT (now()),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`purchasereturn_itemlist` (
  `list_id` int NOT NULL AUTO_INCREMENT,
  `prtn_id` int DEFAULT NULL,
  `item_id` int DEFAULT NULL,
  `item_desc` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin,
  `hsn_sac_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `rate` decimal(10,2) DEFAULT NULL,
  `final_rate` decimal(10,2) DEFAULT NULL,
  `discount` decimal(10,2) DEFAULT NULL,
  `discount_amount` decimal(10,2) DEFAULT NULL,
  `qty` decimal(10,2) DEFAULT NULL,
  `free_qty` decimal(10,2) NOT NULL DEFAULT '0.00',
  `unit` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `amount` decimal(10,2) DEFAULT NULL,
  `tax_percentage` decimal(10,2) DEFAULT NULL,
  `tax_amount` decimal(10,2) DEFAULT NULL,
  `total_amount` decimal(10,2) DEFAULT NULL,
  `cr_usr` int DEFAULT '0',
  PRIMARY KEY (`list_id`),
  KEY `FK_purchasereturn_itemlist_purchasereturn_master` (`prtn_id`),
  KEY `FK_purchasereturn_itemlist_item_master` (`item_id`),
  CONSTRAINT `FK_purchasereturn_itemlist_item_master` FOREIGN KEY (`item_id`) REFERENCES `item_master` (`item_id`),
  CONSTRAINT `FK_purchasereturn_itemlist_purchasereturn_master` FOREIGN KEY (`prtn_id`) REFERENCES `purchasereturn_master` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`purchasereturn_master` (
  `id` int NOT NULL AUTO_INCREMENT,
  `branch_id` int DEFAULT NULL,
  `purchase_id` int DEFAULT NULL,
  `vendor_id` int DEFAULT NULL,
  `invoice_date` date DEFAULT NULL,
  `voucher_date` date DEFAULT NULL,
  `invoice_number` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `no_gst` tinyint NOT NULL DEFAULT '0' COMMENT '0 gst applicable 1 not applicable',
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `total_no_item` int DEFAULT NULL,
  `gross_amt` decimal(10,2) DEFAULT NULL,
  `discount_amt` decimal(10,2) DEFAULT NULL,
  `tax_amt` decimal(10,2) DEFAULT NULL,
  `round_off_amt` decimal(10,2) DEFAULT NULL,
  `net_amt` decimal(10,2) DEFAULT NULL,
  `md_usr` int DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  `cr_usr` int DEFAULT NULL,
  `created_at` datetime DEFAULT (now()),
  `purchase_update_time` int NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `FK_purchase_master_branch_master` (`branch_id`),
  KEY `FK_purchase_master_customer_master` (`vendor_id`),
  KEY `branch_id` (`branch_id`),
  KEY `vendor_id` (`vendor_id`),
  KEY `invoice_date` (`invoice_date`),
  KEY `FK3_purchase_id` (`purchase_id`),
  CONSTRAINT `FK3_purchase_id` FOREIGN KEY (`purchase_id`) REFERENCES `purchase_master` (`id`),
  CONSTRAINT `FK_purchasereturn_master_branch_master` FOREIGN KEY (`branch_id`) REFERENCES `branch_master` (`branch_id`),
  CONSTRAINT `FK_purchasereturn_master_customer_master` FOREIGN KEY (`vendor_id`) REFERENCES `customer_master` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`purchasereturn_taxlist` (
  `list_id` int NOT NULL AUTO_INCREMENT,
  `prtn_id` int DEFAULT NULL,
  `item_id` int DEFAULT NULL,
  `item_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `tax_id` int DEFAULT NULL,
  `tax_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `tax_percentage` decimal(10,2) DEFAULT NULL,
  `taxable_amount` decimal(10,2) DEFAULT NULL,
  `tax_amount` decimal(10,2) DEFAULT NULL,
  PRIMARY KEY (`list_id`),
  KEY `item_id` (`item_id`),
  KEY `FK_purchasereturn_taxlist_purchase_master` (`prtn_id`),
  KEY `FK_purchasereturn_taxlist_item_master` (`item_id`),
  KEY `FK_purchasereturn_taxlist_tax_master` (`tax_id`),
  CONSTRAINT `FK_purchasereturn_taxlist_item_master` FOREIGN KEY (`item_id`) REFERENCES `item_master` (`item_id`),
  CONSTRAINT `FK_purchasereturn_taxlist_purchase_master` FOREIGN KEY (`prtn_id`) REFERENCES `purchasereturn_master` (`id`),
  CONSTRAINT `FK_purchasereturn_taxlist_tax_master` FOREIGN KEY (`tax_id`) REFERENCES `tax_master` (`tax_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`purchase_itemlist` (
  `list_id` int NOT NULL AUTO_INCREMENT,
  `purchase_id` int DEFAULT NULL,
  `item_id` int DEFAULT NULL,
  `item_desc` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin,
  `hsn_sac_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `rate` decimal(10,2) DEFAULT NULL,
  `final_rate` decimal(10,2) DEFAULT NULL,
  `discount` decimal(10,2) DEFAULT NULL,
  `discount_amount` decimal(10,2) DEFAULT NULL,
  `qty` decimal(10,2) DEFAULT NULL,
  `free_qty` decimal(10,2) NOT NULL DEFAULT '0.00',
  `unit` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `amount` decimal(10,2) DEFAULT NULL,
  `tax_percentage` decimal(10,2) DEFAULT NULL,
  `tax_amount` decimal(10,2) DEFAULT NULL,
  `total_amount` decimal(10,2) DEFAULT NULL,
  `cr_usr` int DEFAULT '0',
  PRIMARY KEY (`list_id`),
  KEY `FK_purchase_itemlist_purchase_master` (`purchase_id`),
  KEY `FK_purchase_itemlist_item_master` (`item_id`),
  CONSTRAINT `FK_purchase_itemlist_item_master` FOREIGN KEY (`item_id`) REFERENCES `item_master` (`item_id`),
  CONSTRAINT `FK_purchase_itemlist_purchase_master` FOREIGN KEY (`purchase_id`) REFERENCES `purchase_master` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`purchase_master` (
  `id` int NOT NULL AUTO_INCREMENT,
  `branch_id` int DEFAULT NULL,
  `vendor_id` int DEFAULT NULL,
  `invoice_date` date DEFAULT NULL,
  `voucher_date` date DEFAULT NULL,
  `invoice_number` varchar(70) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `no_gst` tinyint NOT NULL DEFAULT '0' COMMENT '0 gst applicable 1 not applicable',
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `total_no_item` int DEFAULT NULL,
  `gross_amt` decimal(10,2) DEFAULT NULL,
  `discount_amt` decimal(10,2) DEFAULT NULL,
  `tax_amt` decimal(10,2) DEFAULT NULL,
  `round_off_amt` decimal(10,2) DEFAULT NULL,
  `net_amt` decimal(10,2) DEFAULT NULL,
  `md_usr` int DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  `cr_usr` int DEFAULT NULL,
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  `purchase_update_time` int NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `FK_purchase_master_branch_master` (`branch_id`),
  KEY `FK_purchase_master_customer_master` (`vendor_id`),
  KEY `branch_id` (`branch_id`),
  KEY `vendor_id` (`vendor_id`),
  KEY `invoice_date` (`invoice_date`),
  CONSTRAINT `FK_purchase_master_branch_master` FOREIGN KEY (`branch_id`) REFERENCES `branch_master` (`branch_id`),
  CONSTRAINT `FK_purchase_master_customer_master` FOREIGN KEY (`vendor_id`) REFERENCES `customer_master` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`purchase_taxlist` (
  `list_id` int NOT NULL AUTO_INCREMENT,
  `purchase_id` int DEFAULT NULL,
  `item_id` int DEFAULT NULL,
  `item_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `tax_id` int DEFAULT NULL,
  `tax_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `tax_percentage` decimal(10,2) DEFAULT NULL,
  `taxable_amount` decimal(10,2) DEFAULT NULL,
  `tax_amount` decimal(10,2) DEFAULT NULL,
  PRIMARY KEY (`list_id`),
  KEY `FK_purchase_taxlist_purchase_master` (`purchase_id`),
  KEY `FK_purchase_taxlist_item_master` (`item_id`),
  KEY `FK_purchase_taxlist_tax_master` (`tax_id`),
  KEY `purchase_id` (`purchase_id`),
  KEY `item_id` (`item_id`),
  CONSTRAINT `FK_purchase_taxlist_item_master` FOREIGN KEY (`item_id`) REFERENCES `item_master` (`item_id`),
  CONSTRAINT `FK_purchase_taxlist_purchase_master` FOREIGN KEY (`purchase_id`) REFERENCES `purchase_master` (`id`),
  CONSTRAINT `FK_purchase_taxlist_tax_master` FOREIGN KEY (`tax_id`) REFERENCES `tax_master` (`tax_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`stockout_inventory` (
  `inv_id` int NOT NULL AUTO_INCREMENT,
  `branch_id` int DEFAULT NULL,
  `inventory_type_id` int DEFAULT NULL,
  `ref_no` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `inventory_date` date DEFAULT NULL,
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `item_count` decimal(10,2) NOT NULL DEFAULT '0.00',
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `cr_usr` int DEFAULT NULL,
  `md_usr` int DEFAULT NULL,
  PRIMARY KEY (`inv_id`),
  KEY `FKInvenType` (`inventory_type_id`),
  KEY `FKBranchId` (`branch_id`),
  CONSTRAINT `FKBranchId` FOREIGN KEY (`branch_id`) REFERENCES `branch_master` (`branch_id`),
  CONSTRAINT `FKInvenType` FOREIGN KEY (`inventory_type_id`) REFERENCES `inventory_type` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`stockout_inventory_item` (
  `list_id` int NOT NULL AUTO_INCREMENT,
  `inv_id` int DEFAULT NULL,
  `item_id` int DEFAULT NULL,
  `qty` decimal(10,2) NOT NULL DEFAULT '0.00',
  `rto_qty` decimal(10,2) NOT NULL DEFAULT '0.00',
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  `cr_usr` int DEFAULT NULL,
  PRIMARY KEY (`list_id`),
  KEY `FKStockOutinvId` (`inv_id`),
  KEY `FKitem_id` (`item_id`),
  CONSTRAINT `FKitem_id` FOREIGN KEY (`item_id`) REFERENCES `item_master` (`item_id`),
  CONSTRAINT `FKStockOutinvId` FOREIGN KEY (`inv_id`) REFERENCES `stockout_inventory` (`inv_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`tax_master` (
  `tax_id` int NOT NULL AUTO_INCREMENT,
  `tax_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `tax_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `cr_usr` int DEFAULT NULL,
  `created_at` datetime DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,
  `ip_address` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `tax_status` tinyint NOT NULL DEFAULT '1',
  `md_usr` int DEFAULT NULL,
  `updated_at` datetime NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`tax_id`) USING BTREE,
  UNIQUE KEY `tax_name` (`tax_name`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`users_group_master` (
  `id` int NOT NULL AUTO_INCREMENT,
  `uid` int NOT NULL DEFAULT '0',
  `group_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `maximum_discount` decimal(10,2) NOT NULL DEFAULT '0.00',
  `hide_phone` tinyint NOT NULL DEFAULT '0' COMMENT '1 hide mobile, 0 show',
  `assign_order` tinyint NOT NULL DEFAULT '0' COMMENT '1 assign, 0 cannot assign order',
  `show_all` tinyint NOT NULL DEFAULT '0',
  `self_update` tinyint NOT NULL DEFAULT '0',
  `assign_lead` tinyint NOT NULL DEFAULT '0' COMMENT '1 assign, 0 cannot assign lead',
  `lead_update` tinyint NOT NULL DEFAULT '0',
  `order_status_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `campaign_id` int DEFAULT NULL,
  `status` tinyint NOT NULL DEFAULT '1' COMMENT '1 active, 2 inactive',
  `ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `group_ip_adrress` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `time_created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `group_ip_address` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `bulk_order_status` tinyint NOT NULL DEFAULT '0',
  `allow_to_paid_order` tinyint NOT NULL DEFAULT '0',
  `bulk_move_to_shopify` tinyint NOT NULL DEFAULT '0',
  `update_address_after_shopify` tinyint NOT NULL DEFAULT '0',
  `time_updated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `import_permission` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `allow_ip` tinyint NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `idx_group_name` (`group_name`),
  KEY `idx_status` (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`users_logs` (
  `log_id` int NOT NULL AUTO_INCREMENT,
  `user_id` int DEFAULT NULL,
  `reference_id` int DEFAULT NULL COMMENT 'menu controller id',
  `reference_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'menu controller name',
  `reference_type_id` int DEFAULT NULL COMMENT 'specific id if any like order_id, courier_id, payment_id etc.',
  `log_type` tinyint unsigned NOT NULL DEFAULT '0' COMMENT '1 add, 2 edit, 3 delete',
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `log_message` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`log_id`),
  KEY `idx_user_id` (`user_id`),
  KEY `idx_reference_id` (`reference_id`),
  KEY `idx_reference_type_id` (`reference_type_id`),
  KEY `idx_created_at` (`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`users_master` (
  `user_id` int NOT NULL AUTO_INCREMENT,
  `comp_id` int NOT NULL,
  `user_name` varchar(150) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `ext_no` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `user_code` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `user_email` varchar(150) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `user_phone` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `user_login` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `user_pass` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `sys_gen_password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `profile` int DEFAULT NULL,
  `designation` int DEFAULT NULL,
  `master_type` tinyint DEFAULT '0',
  `orderby_change_rights` tinyint NOT NULL DEFAULT '0',
  `manager_id` int DEFAULT NULL,
  `status` tinyint DEFAULT '0',
  `md_usr` int DEFAULT NULL,
  `updated_at` datetime DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,
  `cr_usr` int DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT (now()),
  `doj` date DEFAULT NULL,
  `Daily_Count` int NOT NULL DEFAULT '0',
  `Group_Count` int NOT NULL DEFAULT '0',
  `Overall_Count` int NOT NULL DEFAULT '0',
  `Updated_on` datetime DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`user_id`) USING BTREE,
  UNIQUE KEY `uniq_user_login` (`user_login`) USING BTREE,
  UNIQUE KEY `user_email` (`user_email`) USING BTREE,
  UNIQUE KEY `user_phone` (`user_phone`) USING BTREE,
  KEY `idx_user_name` (`user_name`) USING BTREE,
  KEY `idx_manager_id` (`manager_id`) USING BTREE,
  KEY `idx_profile` (`profile`) USING BTREE,
  CONSTRAINT `FK_users_master_group` FOREIGN KEY (`profile`) REFERENCES `users_group_master` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`users_master_rights` (
  `user_id` int NOT NULL,
  `page_id` int NOT NULL,
  `view_right` tinyint(1) NOT NULL DEFAULT '0',
  `add_right` tinyint(1) NOT NULL DEFAULT '0',
  `edit_right` tinyint(1) NOT NULL DEFAULT '0',
  `excel_right` tinyint(1) NOT NULL DEFAULT '0',
  `delete_right` tinyint(1) NOT NULL DEFAULT '0',
  `created_at` datetime NOT NULL DEFAULT (now()),
  `updated_at` datetime NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`user_id`,`page_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
CREATE TABLE IF NOT EXISTS `sanordo_clientdb_##CLIENT_ID##`.`users_profile_rights` (
  `profile_id` int NOT NULL,
  `page_id` int NOT NULL,
  `view_right` tinyint(1) NOT NULL DEFAULT '0',
  `add_right` tinyint(1) NOT NULL DEFAULT '0',
  `edit_right` tinyint(1) NOT NULL DEFAULT '0',
  `excel_right` tinyint(1) NOT NULL DEFAULT '0',
  `delete_right` tinyint(1) NOT NULL DEFAULT '0',
  `created_at` datetime NOT NULL DEFAULT (now()),
  PRIMARY KEY (`profile_id`,`page_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;$EOL$
