CREATE TABLE `model_has_permissions` (
  `permission_id` int(10) unsigned NOT NULL,
  `model_type` varchar(191) NOT NULL,
  `model_id` bigint(20) unsigned NOT NULL,
  PRIMARY KEY (`permission_id`,`model_id`,`model_type`),
  KEY `model_has_permissions_model_type_model_id_index` (`model_type`,`model_id`),
  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;

INSERT INTO `model_has_permissions` VALUES (567,'App\\User',164),(567,'App\\User',177),(567,'App\\User',183),(567,'App\\User',189),(567,'App\\User',195),(568,'App\\User',164),(568,'App\\User',177),(568,'App\\User',183),(568,'App\\User',189),(568,'App\\User',195),(569,'App\\User',164),(569,'App\\User',177),(569,'App\\User',183),(569,'App\\User',189),(569,'App\\User',195),(570,'App\\User',164),(570,'App\\User',177),(570,'App\\User',183),(570,'App\\User',189),(570,'App\\User',195),(571,'App\\User',164),(571,'App\\User',177),(571,'App\\User',183),(571,'App\\User',189),(571,'App\\User',195),(572,'App\\User',164),(572,'App\\User',177),(572,'App\\User',183),(572,'App\\User',189),(572,'App\\User',195),(573,'App\\User',164),(573,'App\\User',177),(573,'App\\User',183),(573,'App\\User',189),(573,'App\\User',195),(574,'App\\User',164),(574,'App\\User',177),(574,'App\\User',183),(574,'App\\User',189),(574,'App\\User',195);
CREATE TABLE `model_has_roles` (
  `role_id` int(10) unsigned NOT NULL,
  `model_type` varchar(191) NOT NULL,
  `model_id` bigint(20) unsigned NOT NULL,
  PRIMARY KEY (`role_id`,`model_id`,`model_type`),
  KEY `model_has_roles_model_type_model_id_index` (`model_type`,`model_id`),
  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;

INSERT INTO `model_has_roles` VALUES (54,'App\\User',164),(55,'App\\User',165),(55,'App\\User',166),(55,'App\\User',167),(55,'App\\User',168),(55,'App\\User',169),(62,'App\\User',171),(63,'App\\User',172),(63,'App\\User',173),(63,'App\\User',174),(63,'App\\User',175),(63,'App\\User',176),(70,'App\\User',177),(71,'App\\User',178),(71,'App\\User',179),(71,'App\\User',180),(71,'App\\User',181),(71,'App\\User',182),(78,'App\\User',183),(79,'App\\User',184),(79,'App\\User',185),(79,'App\\User',186),(79,'App\\User',187),(79,'App\\User',188),(86,'App\\User',189),(87,'App\\User',190),(87,'App\\User',191),(87,'App\\User',192),(87,'App\\User',193),(87,'App\\User',194),(94,'App\\User',195),(94,'App\\User',201),(95,'App\\User',196),(95,'App\\User',197),(95,'App\\User',198),(95,'App\\User',199),(95,'App\\User',200);
CREATE TABLE `nephrology_patient_profiles` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `clc_patient_id` int(10) unsigned NOT NULL,
  `egfr` decimal(8,2) DEFAULT NULL,
  `creatinine` decimal(8,2) DEFAULT NULL,
  `ckd_stage` varchar(40) DEFAULT NULL,
  `dialysis` tinyint(1) NOT NULL DEFAULT 0,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `nephrology_patient_profiles_clc_patient_id_unique` (`clc_patient_id`),
  CONSTRAINT `nephrology_patient_profiles_clc_patient_id_foreign` FOREIGN KEY (`clc_patient_id`) REFERENCES `clc_patients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `neurology_patient_profiles` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `clc_patient_id` int(10) unsigned NOT NULL,
  `gcs` int(11) DEFAULT NULL,
  `motor_deficit` varchar(40) DEFAULT NULL,
  `sensory_deficit` varchar(40) DEFAULT NULL,
  `seizure_history` tinyint(1) NOT NULL DEFAULT 0,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `neurology_patient_profiles_clc_patient_id_unique` (`clc_patient_id`),
  CONSTRAINT `neurology_patient_profiles_clc_patient_id_foreign` FOREIGN KEY (`clc_patient_id`) REFERENCES `clc_patients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `neurosurgery_patient_profiles` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `clc_patient_id` int(10) unsigned NOT NULL,
  `gcs` int(11) DEFAULT NULL,
  `lesion_site` varchar(120) DEFAULT NULL,
  `planned_procedure` varchar(120) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `neurosurgery_patient_profiles_clc_patient_id_unique` (`clc_patient_id`),
  CONSTRAINT `neurosurgery_patient_profiles_clc_patient_id_foreign` FOREIGN KEY (`clc_patient_id`) REFERENCES `clc_patients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `notification_templates` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(11) NOT NULL,
  `template_for` varchar(191) NOT NULL,
  `email_body` text DEFAULT NULL,
  `sms_body` text DEFAULT NULL,
  `whatsapp_text` text DEFAULT NULL,
  `subject` varchar(191) DEFAULT NULL,
  `cc` varchar(191) DEFAULT NULL,
  `bcc` varchar(191) DEFAULT NULL,
  `auto_send` tinyint(1) NOT NULL DEFAULT 0,
  `auto_send_sms` tinyint(1) NOT NULL DEFAULT 0,
  `auto_send_wa_notif` tinyint(1) NOT NULL DEFAULT 0,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=120 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `notification_templates` VALUES (40,5,'new_sale','<p>Dear {contact_name},</p>\n\n                    <p>Your invoice number is {invoice_number}<br />\n                    Total amount: {total_amount}<br />\n                    Paid amount: {received_amount}</p>\n\n                    <p>Thank you for shopping with us.</p>\n\n                    <p>{business_logo}</p>\n\n                    <p>&nbsp;</p>','Dear {contact_name}, Thank you for shopping with us. {business_name}',NULL,'Thank you from {business_name}',NULL,NULL,0,0,0,'2026-06-15 17:18:42','2026-06-15 17:18:42'),(41,5,'payment_received','<p>Dear {contact_name},</p>\n\n                <p>We have received a payment of {received_amount}</p>\n\n                <p>{business_logo}</p>','Dear {contact_name}, We have received a payment of {received_amount}. {business_name}',NULL,'Payment Received, from {business_name}',NULL,NULL,0,0,0,'2026-06-15 17:18:42','2026-06-15 17:18:42'),(42,5,'payment_reminder','<p>Dear {contact_name},</p>\n\n                    <p>This is to remind you that you have pending payment of {due_amount}. Kindly pay it as soon as possible.</p>\n\n                    <p>{business_logo}</p>','Dear {contact_name}, You have pending payment of {due_amount}. Kindly pay it as soon as possible. {business_name}',NULL,'Payment Reminder, from {business_name}',NULL,NULL,0,0,0,'2026-06-15 17:18:42','2026-06-15 17:18:42'),(43,5,'new_booking','<p>Dear {contact_name},</p>\n\n                    <p>Your booking is confirmed</p>\n\n                    <p>Date: {start_time} to {end_time}</p>\n\n                    <p>Table: {table}</p>\n\n                    <p>Location: {location}</p>\n\n                    <p>{business_logo}</p>','Dear {contact_name}, Your booking is confirmed. Date: {start_time} to {end_time}, Table: {table}, Location: {location}',NULL,'Booking Confirmed - {business_name}',NULL,NULL,0,0,0,'2026-06-15 17:18:42','2026-06-15 17:18:42'),(44,5,'new_order','<p>Dear {contact_name},</p>\n\n                    <p>We have a new order with reference number {order_ref_number}. Kindly process the products as soon as possible.</p>\n\n                    <p>{business_name}<br />\n                    {business_logo}</p>','Dear {contact_name}, We have a new order with reference number {order_ref_number}. Kindly process the products as soon as possible. {business_name}',NULL,'New Order, from {business_name}',NULL,NULL,0,0,0,'2026-06-15 17:18:42','2026-06-15 17:18:42'),(45,5,'payment_paid','<p>Dear {contact_name},</p>\n\n                    <p>We have paid amount {paid_amount} again invoice number {order_ref_number}.<br />\n                    Kindly note it down.</p>\n\n                    <p>{business_name}<br />\n                    {business_logo}</p>','We have paid amount {paid_amount} again invoice number {order_ref_number}.\n                    Kindly note it down. {business_name}',NULL,'Payment Paid, from {business_name}',NULL,NULL,0,0,0,'2026-06-15 17:18:42','2026-06-15 17:18:42'),(46,5,'items_received','<p>Dear {contact_name},</p>\n\n                    <p>We have received all items from invoice reference number {order_ref_number}. Thank you for processing it.</p>\n\n                    <p>{business_name}<br />\n                    {business_logo}</p>','We have received all items from invoice reference number {order_ref_number}. Thank you for processing it. {business_name}',NULL,'Items received, from {business_name}',NULL,NULL,0,0,0,'2026-06-15 17:18:42','2026-06-15 17:18:42'),(47,5,'items_pending','<p>Dear {contact_name},<br />\n                    This is to remind you that we have not yet received some items from invoice reference number {order_ref_number}. Please process it as soon as possible.</p>\n\n                    <p>{business_name}<br />\n                    {business_logo}</p>','This is to remind you that we have not yet received some items from invoice reference number {order_ref_number} . Please process it as soon as possible.{business_name}',NULL,'Items Pending, from {business_name}',NULL,NULL,0,0,0,'2026-06-15 17:18:42','2026-06-15 17:18:42'),(48,5,'new_quotation','<p>Dear {contact_name},</p>\n\n                    <p>Your quotation number is {invoice_number}<br />\n                    Total amount: {total_amount}</p>\n\n                    <p>Thank you for shopping with us.</p>\n\n                    <p>{business_logo}</p>\n\n                    <p>&nbsp;</p>','Dear {contact_name}, Thank you for shopping with us. {business_name}',NULL,'Thank you from {business_name}',NULL,NULL,0,0,0,'2026-06-15 17:18:42','2026-06-15 17:18:42'),(49,5,'purchase_order','<p>Dear {contact_name},</p>\n\n                    <p>We have a new purchase order with reference number {order_ref_number}. The respective invoice is attached here with.</p>\n\n                    <p>{business_logo}</p>','We have a new purchase order with reference number {order_ref_number}. {business_name}',NULL,'New Purchase Order, from {business_name}',NULL,NULL,0,0,0,'2026-06-15 17:18:42','2026-06-15 17:18:42'),(50,6,'new_sale','<p>Dear {contact_name},</p>\n\n                    <p>Your invoice number is {invoice_number}<br />\n                    Total amount: {total_amount}<br />\n                    Paid amount: {received_amount}</p>\n\n                    <p>Thank you for shopping with us.</p>\n\n                    <p>{business_logo}</p>\n\n                    <p>&nbsp;</p>','Dear {contact_name}, Thank you for shopping with us. {business_name}',NULL,'Thank you from {business_name}',NULL,NULL,0,0,0,'2026-06-17 20:54:54','2026-06-17 20:54:54'),(51,6,'payment_received','<p>Dear {contact_name},</p>\n\n                <p>We have received a payment of {received_amount}</p>\n\n                <p>{business_logo}</p>','Dear {contact_name}, We have received a payment of {received_amount}. {business_name}',NULL,'Payment Received, from {business_name}',NULL,NULL,0,0,0,'2026-06-17 20:54:54','2026-06-17 20:54:54'),(52,6,'payment_reminder','<p>Dear {contact_name},</p>\n\n                    <p>This is to remind you that you have pending payment of {due_amount}. Kindly pay it as soon as possible.</p>\n\n                    <p>{business_logo}</p>','Dear {contact_name}, You have pending payment of {due_amount}. Kindly pay it as soon as possible. {business_name}',NULL,'Payment Reminder, from {business_name}',NULL,NULL,0,0,0,'2026-06-17 20:54:54','2026-06-17 20:54:54'),(53,6,'new_booking','<p>Dear {contact_name},</p>\n\n                    <p>Your booking is confirmed</p>\n\n                    <p>Date: {start_time} to {end_time}</p>\n\n                    <p>Table: {table}</p>\n\n                    <p>Location: {location}</p>\n\n                    <p>{business_logo}</p>','Dear {contact_name}, Your booking is confirmed. Date: {start_time} to {end_time}, Table: {table}, Location: {location}',NULL,'Booking Confirmed - {business_name}',NULL,NULL,0,0,0,'2026-06-17 20:54:54','2026-06-17 20:54:54'),(54,6,'new_order','<p>Dear {contact_name},</p>\n\n                    <p>We have a new order with reference number {order_ref_number}. Kindly process the products as soon as possible.</p>\n\n                    <p>{business_name}<br />\n                    {business_logo}</p>','Dear {contact_name}, We have a new order with reference number {order_ref_number}. Kindly process the products as soon as possible. {business_name}',NULL,'New Order, from {business_name}',NULL,NULL,0,0,0,'2026-06-17 20:54:54','2026-06-17 20:54:54'),(55,6,'payment_paid','<p>Dear {contact_name},</p>\n\n                    <p>We have paid amount {paid_amount} again invoice number {order_ref_number}.<br />\n                    Kindly note it down.</p>\n\n                    <p>{business_name}<br />\n                    {business_logo}</p>','We have paid amount {paid_amount} again invoice number {order_ref_number}.\n                    Kindly note it down. {business_name}',NULL,'Payment Paid, from {business_name}',NULL,NULL,0,0,0,'2026-06-17 20:54:54','2026-06-17 20:54:54'),(56,6,'items_received','<p>Dear {contact_name},</p>\n\n                    <p>We have received all items from invoice reference number {order_ref_number}. Thank you for processing it.</p>\n\n                    <p>{business_name}<br />\n                    {business_logo}</p>','We have received all items from invoice reference number {order_ref_number}. Thank you for processing it. {business_name}',NULL,'Items received, from {business_name}',NULL,NULL,0,0,0,'2026-06-17 20:54:54','2026-06-17 20:54:54'),(57,6,'items_pending','<p>Dear {contact_name},<br />\n                    This is to remind you that we have not yet received some items from invoice reference number {order_ref_number}. Please process it as soon as possible.</p>\n\n                    <p>{business_name}<br />\n                    {business_logo}</p>','This is to remind you that we have not yet received some items from invoice reference number {order_ref_number} . Please process it as soon as possible.{business_name}',NULL,'Items Pending, from {business_name}',NULL,NULL,0,0,0,'2026-06-17 20:54:54','2026-06-17 20:54:54'),(58,6,'new_quotation','<p>Dear {contact_name},</p>\n\n                    <p>Your quotation number is {invoice_number}<br />\n                    Total amount: {total_amount}</p>\n\n                    <p>Thank you for shopping with us.</p>\n\n                    <p>{business_logo}</p>\n\n                    <p>&nbsp;</p>','Dear {contact_name}, Thank you for shopping with us. {business_name}',NULL,'Thank you from {business_name}',NULL,NULL,0,0,0,'2026-06-17 20:54:54','2026-06-17 20:54:54'),(59,6,'purchase_order','<p>Dear {contact_name},</p>\n\n                    <p>We have a new purchase order with reference number {order_ref_number}. The respective invoice is attached here with.</p>\n\n                    <p>{business_logo}</p>','We have a new purchase order with reference number {order_ref_number}. {business_name}',NULL,'New Purchase Order, from {business_name}',NULL,NULL,0,0,0,'2026-06-17 20:54:54','2026-06-17 20:54:54'),(60,7,'new_sale','<p>Dear {contact_name},</p>\n\n                    <p>Your invoice number is {invoice_number}<br />\n                    Total amount: {total_amount}<br />\n                    Paid amount: {received_amount}</p>\n\n                    <p>Thank you for shopping with us.</p>\n\n                    <p>{business_logo}</p>\n\n                    <p>&nbsp;</p>','Dear {contact_name}, Thank you for shopping with us. {business_name}',NULL,'Thank you from {business_name}',NULL,NULL,0,0,0,'2026-06-17 20:55:44','2026-06-17 20:55:44'),(61,7,'payment_received','<p>Dear {contact_name},</p>\n\n                <p>We have received a payment of {received_amount}</p>\n\n                <p>{business_logo}</p>','Dear {contact_name}, We have received a payment of {received_amount}. {business_name}',NULL,'Payment Received, from {business_name}',NULL,NULL,0,0,0,'2026-06-17 20:55:44','2026-06-17 20:55:44'),(62,7,'payment_reminder','<p>Dear {contact_name},</p>\n\n                    <p>This is to remind you that you have pending payment of {due_amount}. Kindly pay it as soon as possible.</p>\n\n                    <p>{business_logo}</p>','Dear {contact_name}, You have pending payment of {due_amount}. Kindly pay it as soon as possible. {business_name}',NULL,'Payment Reminder, from {business_name}',NULL,NULL,0,0,0,'2026-06-17 20:55:44','2026-06-17 20:55:44'),(63,7,'new_booking','<p>Dear {contact_name},</p>\n\n                    <p>Your booking is confirmed</p>\n\n                    <p>Date: {start_time} to {end_time}</p>\n\n                    <p>Table: {table}</p>\n\n                    <p>Location: {location}</p>\n\n                    <p>{business_logo}</p>','Dear {contact_name}, Your booking is confirmed. Date: {start_time} to {end_time}, Table: {table}, Location: {location}',NULL,'Booking Confirmed - {business_name}',NULL,NULL,0,0,0,'2026-06-17 20:55:44','2026-06-17 20:55:44'),(64,7,'new_order','<p>Dear {contact_name},</p>\n\n                    <p>We have a new order with reference number {order_ref_number}. Kindly process the products as soon as possible.</p>\n\n                    <p>{business_name}<br />\n                    {business_logo}</p>','Dear {contact_name}, We have a new order with reference number {order_ref_number}. Kindly process the products as soon as possible. {business_name}',NULL,'New Order, from {business_name}',NULL,NULL,0,0,0,'2026-06-17 20:55:44','2026-06-17 20:55:44'),(65,7,'payment_paid','<p>Dear {contact_name},</p>\n\n                    <p>We have paid amount {paid_amount} again invoice number {order_ref_number}.<br />\n                    Kindly note it down.</p>\n\n                    <p>{business_name}<br />\n                    {business_logo}</p>','We have paid amount {paid_amount} again invoice number {order_ref_number}.\n                    Kindly note it down. {business_name}',NULL,'Payment Paid, from {business_name}',NULL,NULL,0,0,0,'2026-06-17 20:55:44','2026-06-17 20:55:44'),(66,7,'items_received','<p>Dear {contact_name},</p>\n\n                    <p>We have received all items from invoice reference number {order_ref_number}. Thank you for processing it.</p>\n\n                    <p>{business_name}<br />\n                    {business_logo}</p>','We have received all items from invoice reference number {order_ref_number}. Thank you for processing it. {business_name}',NULL,'Items received, from {business_name}',NULL,NULL,0,0,0,'2026-06-17 20:55:44','2026-06-17 20:55:44'),(67,7,'items_pending','<p>Dear {contact_name},<br />\n                    This is to remind you that we have not yet received some items from invoice reference number {order_ref_number}. Please process it as soon as possible.</p>\n\n                    <p>{business_name}<br />\n                    {business_logo}</p>','This is to remind you that we have not yet received some items from invoice reference number {order_ref_number} . Please process it as soon as possible.{business_name}',NULL,'Items Pending, from {business_name}',NULL,NULL,0,0,0,'2026-06-17 20:55:44','2026-06-17 20:55:44'),(68,7,'new_quotation','<p>Dear {contact_name},</p>\n\n                    <p>Your quotation number is {invoice_number}<br />\n                    Total amount: {total_amount}</p>\n\n                    <p>Thank you for shopping with us.</p>\n\n                    <p>{business_logo}</p>\n\n                    <p>&nbsp;</p>','Dear {contact_name}, Thank you for shopping with us. {business_name}',NULL,'Thank you from {business_name}',NULL,NULL,0,0,0,'2026-06-17 20:55:44','2026-06-17 20:55:44'),(69,7,'purchase_order','<p>Dear {contact_name},</p>\n\n                    <p>We have a new purchase order with reference number {order_ref_number}. The respective invoice is attached here with.</p>\n\n                    <p>{business_logo}</p>','We have a new purchase order with reference number {order_ref_number}. {business_name}',NULL,'New Purchase Order, from {business_name}',NULL,NULL,0,0,0,'2026-06-17 20:55:44','2026-06-17 20:55:44'),(70,8,'new_sale','<p>Dear {contact_name},</p>\n\n                    <p>Your invoice number is {invoice_number}<br />\n                    Total amount: {total_amount}<br />\n                    Paid amount: {received_amount}</p>\n\n                    <p>Thank you for shopping with us.</p>\n\n                    <p>{business_logo}</p>\n\n                    <p>&nbsp;</p>','Dear {contact_name}, Thank you for shopping with us. {business_name}',NULL,'Thank you from {business_name}',NULL,NULL,0,0,0,'2026-06-17 20:58:10','2026-06-17 20:58:10'),(71,8,'payment_received','<p>Dear {contact_name},</p>\n\n                <p>We have received a payment of {received_amount}</p>\n\n                <p>{business_logo}</p>','Dear {contact_name}, We have received a payment of {received_amount}. {business_name}',NULL,'Payment Received, from {business_name}',NULL,NULL,0,0,0,'2026-06-17 20:58:10','2026-06-17 20:58:10'),(72,8,'payment_reminder','<p>Dear {contact_name},</p>\n\n                    <p>This is to remind you that you have pending payment of {due_amount}. Kindly pay it as soon as possible.</p>\n\n                    <p>{business_logo}</p>','Dear {contact_name}, You have pending payment of {due_amount}. Kindly pay it as soon as possible. {business_name}',NULL,'Payment Reminder, from {business_name}',NULL,NULL,0,0,0,'2026-06-17 20:58:10','2026-06-17 20:58:10'),(73,8,'new_booking','<p>Dear {contact_name},</p>\n\n                    <p>Your booking is confirmed</p>\n\n                    <p>Date: {start_time} to {end_time}</p>\n\n                    <p>Table: {table}</p>\n\n                    <p>Location: {location}</p>\n\n                    <p>{business_logo}</p>','Dear {contact_name}, Your booking is confirmed. Date: {start_time} to {end_time}, Table: {table}, Location: {location}',NULL,'Booking Confirmed - {business_name}',NULL,NULL,0,0,0,'2026-06-17 20:58:10','2026-06-17 20:58:10'),(74,8,'new_order','<p>Dear {contact_name},</p>\n\n                    <p>We have a new order with reference number {order_ref_number}. Kindly process the products as soon as possible.</p>\n\n                    <p>{business_name}<br />\n                    {business_logo}</p>','Dear {contact_name}, We have a new order with reference number {order_ref_number}. Kindly process the products as soon as possible. {business_name}',NULL,'New Order, from {business_name}',NULL,NULL,0,0,0,'2026-06-17 20:58:10','2026-06-17 20:58:10'),(75,8,'payment_paid','<p>Dear {contact_name},</p>\n\n                    <p>We have paid amount {paid_amount} again invoice number {order_ref_number}.<br />\n                    Kindly note it down.</p>\n\n                    <p>{business_name}<br />\n                    {business_logo}</p>','We have paid amount {paid_amount} again invoice number {order_ref_number}.\n                    Kindly note it down. {business_name}',NULL,'Payment Paid, from {business_name}',NULL,NULL,0,0,0,'2026-06-17 20:58:10','2026-06-17 20:58:10'),(76,8,'items_received','<p>Dear {contact_name},</p>\n\n                    <p>We have received all items from invoice reference number {order_ref_number}. Thank you for processing it.</p>\n\n                    <p>{business_name}<br />\n                    {business_logo}</p>','We have received all items from invoice reference number {order_ref_number}. Thank you for processing it. {business_name}',NULL,'Items received, from {business_name}',NULL,NULL,0,0,0,'2026-06-17 20:58:10','2026-06-17 20:58:10'),(77,8,'items_pending','<p>Dear {contact_name},<br />\n                    This is to remind you that we have not yet received some items from invoice reference number {order_ref_number}. Please process it as soon as possible.</p>\n\n                    <p>{business_name}<br />\n                    {business_logo}</p>','This is to remind you that we have not yet received some items from invoice reference number {order_ref_number} . Please process it as soon as possible.{business_name}',NULL,'Items Pending, from {business_name}',NULL,NULL,0,0,0,'2026-06-17 20:58:10','2026-06-17 20:58:10'),(78,8,'new_quotation','<p>Dear {contact_name},</p>\n\n                    <p>Your quotation number is {invoice_number}<br />\n                    Total amount: {total_amount}</p>\n\n                    <p>Thank you for shopping with us.</p>\n\n                    <p>{business_logo}</p>\n\n                    <p>&nbsp;</p>','Dear {contact_name}, Thank you for shopping with us. {business_name}',NULL,'Thank you from {business_name}',NULL,NULL,0,0,0,'2026-06-17 20:58:10','2026-06-17 20:58:10'),(79,8,'purchase_order','<p>Dear {contact_name},</p>\n\n                    <p>We have a new purchase order with reference number {order_ref_number}. The respective invoice is attached here with.</p>\n\n                    <p>{business_logo}</p>','We have a new purchase order with reference number {order_ref_number}. {business_name}',NULL,'New Purchase Order, from {business_name}',NULL,NULL,0,0,0,'2026-06-17 20:58:10','2026-06-17 20:58:10'),(80,9,'new_sale','<p>Dear {contact_name},</p>\n\n                    <p>Your invoice number is {invoice_number}<br />\n                    Total amount: {total_amount}<br />\n                    Paid amount: {received_amount}</p>\n\n                    <p>Thank you for shopping with us.</p>\n\n                    <p>{business_logo}</p>\n\n                    <p>&nbsp;</p>','Dear {contact_name}, Thank you for shopping with us. {business_name}',NULL,'Thank you from {business_name}',NULL,NULL,0,0,0,'2026-06-17 21:00:01','2026-06-17 21:00:01'),(81,9,'payment_received','<p>Dear {contact_name},</p>\n\n                <p>We have received a payment of {received_amount}</p>\n\n                <p>{business_logo}</p>','Dear {contact_name}, We have received a payment of {received_amount}. {business_name}',NULL,'Payment Received, from {business_name}',NULL,NULL,0,0,0,'2026-06-17 21:00:01','2026-06-17 21:00:01'),(82,9,'payment_reminder','<p>Dear {contact_name},</p>\n\n                    <p>This is to remind you that you have pending payment of {due_amount}. Kindly pay it as soon as possible.</p>\n\n                    <p>{business_logo}</p>','Dear {contact_name}, You have pending payment of {due_amount}. Kindly pay it as soon as possible. {business_name}',NULL,'Payment Reminder, from {business_name}',NULL,NULL,0,0,0,'2026-06-17 21:00:01','2026-06-17 21:00:01'),(83,9,'new_booking','<p>Dear {contact_name},</p>\n\n                    <p>Your booking is confirmed</p>\n\n                    <p>Date: {start_time} to {end_time}</p>\n\n                    <p>Table: {table}</p>\n\n                    <p>Location: {location}</p>\n\n                    <p>{business_logo}</p>','Dear {contact_name}, Your booking is confirmed. Date: {start_time} to {end_time}, Table: {table}, Location: {location}',NULL,'Booking Confirmed - {business_name}',NULL,NULL,0,0,0,'2026-06-17 21:00:01','2026-06-17 21:00:01'),(84,9,'new_order','<p>Dear {contact_name},</p>\n\n                    <p>We have a new order with reference number {order_ref_number}. Kindly process the products as soon as possible.</p>\n\n                    <p>{business_name}<br />\n                    {business_logo}</p>','Dear {contact_name}, We have a new order with reference number {order_ref_number}. Kindly process the products as soon as possible. {business_name}',NULL,'New Order, from {business_name}',NULL,NULL,0,0,0,'2026-06-17 21:00:01','2026-06-17 21:00:01'),(85,9,'payment_paid','<p>Dear {contact_name},</p>\n\n                    <p>We have paid amount {paid_amount} again invoice number {order_ref_number}.<br />\n                    Kindly note it down.</p>\n\n                    <p>{business_name}<br />\n                    {business_logo}</p>','We have paid amount {paid_amount} again invoice number {order_ref_number}.\n                    Kindly note it down. {business_name}',NULL,'Payment Paid, from {business_name}',NULL,NULL,0,0,0,'2026-06-17 21:00:01','2026-06-17 21:00:01'),(86,9,'items_received','<p>Dear {contact_name},</p>\n\n                    <p>We have received all items from invoice reference number {order_ref_number}. Thank you for processing it.</p>\n\n                    <p>{business_name}<br />\n                    {business_logo}</p>','We have received all items from invoice reference number {order_ref_number}. Thank you for processing it. {business_name}',NULL,'Items received, from {business_name}',NULL,NULL,0,0,0,'2026-06-17 21:00:01','2026-06-17 21:00:01'),(87,9,'items_pending','<p>Dear {contact_name},<br />\n                    This is to remind you that we have not yet received some items from invoice reference number {order_ref_number}. Please process it as soon as possible.</p>\n\n                    <p>{business_name}<br />\n                    {business_logo}</p>','This is to remind you that we have not yet received some items from invoice reference number {order_ref_number} . Please process it as soon as possible.{business_name}',NULL,'Items Pending, from {business_name}',NULL,NULL,0,0,0,'2026-06-17 21:00:01','2026-06-17 21:00:01'),(88,9,'new_quotation','<p>Dear {contact_name},</p>\n\n                    <p>Your quotation number is {invoice_number}<br />\n                    Total amount: {total_amount}</p>\n\n                    <p>Thank you for shopping with us.</p>\n\n                    <p>{business_logo}</p>\n\n                    <p>&nbsp;</p>','Dear {contact_name}, Thank you for shopping with us. {business_name}',NULL,'Thank you from {business_name}',NULL,NULL,0,0,0,'2026-06-17 21:00:01','2026-06-17 21:00:01'),(89,9,'purchase_order','<p>Dear {contact_name},</p>\n\n                    <p>We have a new purchase order with reference number {order_ref_number}. The respective invoice is attached here with.</p>\n\n                    <p>{business_logo}</p>','We have a new purchase order with reference number {order_ref_number}. {business_name}',NULL,'New Purchase Order, from {business_name}',NULL,NULL,0,0,0,'2026-06-17 21:00:01','2026-06-17 21:00:01'),(90,10,'new_sale','<p>Dear {contact_name},</p>\n\n                    <p>Your invoice number is {invoice_number}<br />\n                    Total amount: {total_amount}<br />\n                    Paid amount: {received_amount}</p>\n\n                    <p>Thank you for shopping with us.</p>\n\n                    <p>{business_logo}</p>\n\n                    <p>&nbsp;</p>','Dear {contact_name}, Thank you for shopping with us. {business_name}',NULL,'Thank you from {business_name}',NULL,NULL,0,0,0,'2026-06-17 21:11:53','2026-06-17 21:11:53'),(91,10,'payment_received','<p>Dear {contact_name},</p>\n\n                <p>We have received a payment of {received_amount}</p>\n\n                <p>{business_logo}</p>','Dear {contact_name}, We have received a payment of {received_amount}. {business_name}',NULL,'Payment Received, from {business_name}',NULL,NULL,0,0,0,'2026-06-17 21:11:53','2026-06-17 21:11:53'),(92,10,'payment_reminder','<p>Dear {contact_name},</p>\n\n                    <p>This is to remind you that you have pending payment of {due_amount}. Kindly pay it as soon as possible.</p>\n\n                    <p>{business_logo}</p>','Dear {contact_name}, You have pending payment of {due_amount}. Kindly pay it as soon as possible. {business_name}',NULL,'Payment Reminder, from {business_name}',NULL,NULL,0,0,0,'2026-06-17 21:11:53','2026-06-17 21:11:53'),(93,10,'new_booking','<p>Dear {contact_name},</p>\n\n                    <p>Your booking is confirmed</p>\n\n                    <p>Date: {start_time} to {end_time}</p>\n\n                    <p>Table: {table}</p>\n\n                    <p>Location: {location}</p>\n\n                    <p>{business_logo}</p>','Dear {contact_name}, Your booking is confirmed. Date: {start_time} to {end_time}, Table: {table}, Location: {location}',NULL,'Booking Confirmed - {business_name}',NULL,NULL,0,0,0,'2026-06-17 21:11:53','2026-06-17 21:11:53'),(94,10,'new_order','<p>Dear {contact_name},</p>\n\n                    <p>We have a new order with reference number {order_ref_number}. Kindly process the products as soon as possible.</p>\n\n                    <p>{business_name}<br />\n                    {business_logo}</p>','Dear {contact_name}, We have a new order with reference number {order_ref_number}. Kindly process the products as soon as possible. {business_name}',NULL,'New Order, from {business_name}',NULL,NULL,0,0,0,'2026-06-17 21:11:53','2026-06-17 21:11:53'),(95,10,'payment_paid','<p>Dear {contact_name},</p>\n\n                    <p>We have paid amount {paid_amount} again invoice number {order_ref_number}.<br />\n                    Kindly note it down.</p>\n\n                    <p>{business_name}<br />\n                    {business_logo}</p>','We have paid amount {paid_amount} again invoice number {order_ref_number}.\n                    Kindly note it down. {business_name}',NULL,'Payment Paid, from {business_name}',NULL,NULL,0,0,0,'2026-06-17 21:11:53','2026-06-17 21:11:53'),(96,10,'items_received','<p>Dear {contact_name},</p>\n\n                    <p>We have received all items from invoice reference number {order_ref_number}. Thank you for processing it.</p>\n\n                    <p>{business_name}<br />\n                    {business_logo}</p>','We have received all items from invoice reference number {order_ref_number}. Thank you for processing it. {business_name}',NULL,'Items received, from {business_name}',NULL,NULL,0,0,0,'2026-06-17 21:11:53','2026-06-17 21:11:53'),(97,10,'items_pending','<p>Dear {contact_name},<br />\n                    This is to remind you that we have not yet received some items from invoice reference number {order_ref_number}. Please process it as soon as possible.</p>\n\n                    <p>{business_name}<br />\n                    {business_logo}</p>','This is to remind you that we have not yet received some items from invoice reference number {order_ref_number} . Please process it as soon as possible.{business_name}',NULL,'Items Pending, from {business_name}',NULL,NULL,0,0,0,'2026-06-17 21:11:53','2026-06-17 21:11:53'),(98,10,'new_quotation','<p>Dear {contact_name},</p>\n\n                    <p>Your quotation number is {invoice_number}<br />\n                    Total amount: {total_amount}</p>\n\n                    <p>Thank you for shopping with us.</p>\n\n                    <p>{business_logo}</p>\n\n                    <p>&nbsp;</p>','Dear {contact_name}, Thank you for shopping with us. {business_name}',NULL,'Thank you from {business_name}',NULL,NULL,0,0,0,'2026-06-17 21:11:53','2026-06-17 21:11:53'),(99,10,'purchase_order','<p>Dear {contact_name},</p>\n\n                    <p>We have a new purchase order with reference number {order_ref_number}. The respective invoice is attached here with.</p>\n\n                    <p>{business_logo}</p>','We have a new purchase order with reference number {order_ref_number}. {business_name}',NULL,'New Purchase Order, from {business_name}',NULL,NULL,0,0,0,'2026-06-17 21:11:53','2026-06-17 21:11:53'),(100,11,'new_sale','<p>Dear {contact_name},</p>\r\n\r\n                    <p>Your invoice number is {invoice_number}<br />\r\n                    Total amount: {total_amount}<br />\r\n                    Paid amount: {received_amount}</p>\r\n\r\n                    <p>Thank you for shopping with us.</p>\r\n\r\n                    <p>{business_logo}</p>\r\n\r\n                    <p>&nbsp;</p>','Dear {contact_name}, Thank you for shopping with us. {business_name}',NULL,'Thank you from {business_name}',NULL,NULL,0,0,0,'2026-07-10 05:40:55','2026-07-10 05:40:55'),(101,11,'payment_received','<p>Dear {contact_name},</p>\r\n\r\n                <p>We have received a payment of {received_amount}</p>\r\n\r\n                <p>{business_logo}</p>','Dear {contact_name}, We have received a payment of {received_amount}. {business_name}',NULL,'Payment Received, from {business_name}',NULL,NULL,0,0,0,'2026-07-10 05:40:55','2026-07-10 05:40:55'),(102,11,'payment_reminder','<p>Dear {contact_name},</p>\r\n\r\n                    <p>This is to remind you that you have pending payment of {due_amount}. Kindly pay it as soon as possible.</p>\r\n\r\n                    <p>{business_logo}</p>','Dear {contact_name}, You have pending payment of {due_amount}. Kindly pay it as soon as possible. {business_name}',NULL,'Payment Reminder, from {business_name}',NULL,NULL,0,0,0,'2026-07-10 05:40:55','2026-07-10 05:40:55'),(103,11,'new_booking','<p>Dear {contact_name},</p>\r\n\r\n                    <p>Your booking is confirmed</p>\r\n\r\n                    <p>Date: {start_time} to {end_time}</p>\r\n\r\n                    <p>Table: {table}</p>\r\n\r\n                    <p>Location: {location}</p>\r\n\r\n                    <p>{business_logo}</p>','Dear {contact_name}, Your booking is confirmed. Date: {start_time} to {end_time}, Table: {table}, Location: {location}',NULL,'Booking Confirmed - {business_name}',NULL,NULL,0,0,0,'2026-07-10 05:40:55','2026-07-10 05:40:55'),(104,11,'new_order','<p>Dear {contact_name},</p>\r\n\r\n                    <p>We have a new order with reference number {order_ref_number}. Kindly process the products as soon as possible.</p>\r\n\r\n                    <p>{business_name}<br />\r\n                    {business_logo}</p>','Dear {contact_name}, We have a new order with reference number {order_ref_number}. Kindly process the products as soon as possible. {business_name}',NULL,'New Order, from {business_name}',NULL,NULL,0,0,0,'2026-07-10 05:40:55','2026-07-10 05:40:55'),(105,11,'payment_paid','<p>Dear {contact_name},</p>\r\n\r\n                    <p>We have paid amount {paid_amount} again invoice number {order_ref_number}.<br />\r\n                    Kindly note it down.</p>\r\n\r\n                    <p>{business_name}<br />\r\n                    {business_logo}</p>','We have paid amount {paid_amount} again invoice number {order_ref_number}.\r\n                    Kindly note it down. {business_name}',NULL,'Payment Paid, from {business_name}',NULL,NULL,0,0,0,'2026-07-10 05:40:55','2026-07-10 05:40:55'),(106,11,'items_received','<p>Dear {contact_name},</p>\r\n\r\n                    <p>We have received all items from invoice reference number {order_ref_number}. Thank you for processing it.</p>\r\n\r\n                    <p>{business_name}<br />\r\n                    {business_logo}</p>','We have received all items from invoice reference number {order_ref_number}. Thank you for processing it. {business_name}',NULL,'Items received, from {business_name}',NULL,NULL,0,0,0,'2026-07-10 05:40:55','2026-07-10 05:40:55'),(107,11,'items_pending','<p>Dear {contact_name},<br />\r\n                    This is to remind you that we have not yet received some items from invoice reference number {order_ref_number}. Please process it as soon as possible.</p>\r\n\r\n                    <p>{business_name}<br />\r\n                    {business_logo}</p>','This is to remind you that we have not yet received some items from invoice reference number {order_ref_number} . Please process it as soon as possible.{business_name}',NULL,'Items Pending, from {business_name}',NULL,NULL,0,0,0,'2026-07-10 05:40:55','2026-07-10 05:40:55'),(108,11,'new_quotation','<p>Dear {contact_name},</p>\r\n\r\n                    <p>Your quotation number is {invoice_number}<br />\r\n                    Total amount: {total_amount}</p>\r\n\r\n                    <p>Thank you for shopping with us.</p>\r\n\r\n                    <p>{business_logo}</p>\r\n\r\n                    <p>&nbsp;</p>','Dear {contact_name}, Thank you for shopping with us. {business_name}',NULL,'Thank you from {business_name}',NULL,NULL,0,0,0,'2026-07-10 05:40:55','2026-07-10 05:40:55'),(109,11,'purchase_order','<p>Dear {contact_name},</p>\r\n\r\n                    <p>We have a new purchase order with reference number {order_ref_number}. The respective invoice is attached here with.</p>\r\n\r\n                    <p>{business_logo}</p>','We have a new purchase order with reference number {order_ref_number}. {business_name}',NULL,'New Purchase Order, from {business_name}',NULL,NULL,0,0,0,'2026-07-10 05:40:55','2026-07-10 05:40:55'),(110,12,'new_sale','<p>Dear {contact_name},</p>\r\n\r\n                    <p>Your invoice number is {invoice_number}<br />\r\n                    Total amount: {total_amount}<br />\r\n                    Paid amount: {received_amount}</p>\r\n\r\n                    <p>Thank you for shopping with us.</p>\r\n\r\n                    <p>{business_logo}</p>\r\n\r\n                    <p>&nbsp;</p>','Dear {contact_name}, Thank you for shopping with us. {business_name}',NULL,'Thank you from {business_name}',NULL,NULL,0,0,0,'2026-07-10 06:43:14','2026-07-10 06:43:14'),(111,12,'payment_received','<p>Dear {contact_name},</p>\r\n\r\n                <p>We have received a payment of {received_amount}</p>\r\n\r\n                <p>{business_logo}</p>','Dear {contact_name}, We have received a payment of {received_amount}. {business_name}',NULL,'Payment Received, from {business_name}',NULL,NULL,0,0,0,'2026-07-10 06:43:14','2026-07-10 06:43:14'),(112,12,'payment_reminder','<p>Dear {contact_name},</p>\r\n\r\n                    <p>This is to remind you that you have pending payment of {due_amount}. Kindly pay it as soon as possible.</p>\r\n\r\n                    <p>{business_logo}</p>','Dear {contact_name}, You have pending payment of {due_amount}. Kindly pay it as soon as possible. {business_name}',NULL,'Payment Reminder, from {business_name}',NULL,NULL,0,0,0,'2026-07-10 06:43:14','2026-07-10 06:43:14'),(113,12,'new_booking','<p>Dear {contact_name},</p>\r\n\r\n                    <p>Your booking is confirmed</p>\r\n\r\n                    <p>Date: {start_time} to {end_time}</p>\r\n\r\n                    <p>Table: {table}</p>\r\n\r\n                    <p>Location: {location}</p>\r\n\r\n                    <p>{business_logo}</p>','Dear {contact_name}, Your booking is confirmed. Date: {start_time} to {end_time}, Table: {table}, Location: {location}',NULL,'Booking Confirmed - {business_name}',NULL,NULL,0,0,0,'2026-07-10 06:43:14','2026-07-10 06:43:14'),(114,12,'new_order','<p>Dear {contact_name},</p>\r\n\r\n                    <p>We have a new order with reference number {order_ref_number}. Kindly process the products as soon as possible.</p>\r\n\r\n                    <p>{business_name}<br />\r\n                    {business_logo}</p>','Dear {contact_name}, We have a new order with reference number {order_ref_number}. Kindly process the products as soon as possible. {business_name}',NULL,'New Order, from {business_name}',NULL,NULL,0,0,0,'2026-07-10 06:43:14','2026-07-10 06:43:14'),(115,12,'payment_paid','<p>Dear {contact_name},</p>\r\n\r\n                    <p>We have paid amount {paid_amount} again invoice number {order_ref_number}.<br />\r\n                    Kindly note it down.</p>\r\n\r\n                    <p>{business_name}<br />\r\n                    {business_logo}</p>','We have paid amount {paid_amount} again invoice number {order_ref_number}.\r\n                    Kindly note it down. {business_name}',NULL,'Payment Paid, from {business_name}',NULL,NULL,0,0,0,'2026-07-10 06:43:14','2026-07-10 06:43:14'),(116,12,'items_received','<p>Dear {contact_name},</p>\r\n\r\n                    <p>We have received all items from invoice reference number {order_ref_number}. Thank you for processing it.</p>\r\n\r\n                    <p>{business_name}<br />\r\n                    {business_logo}</p>','We have received all items from invoice reference number {order_ref_number}. Thank you for processing it. {business_name}',NULL,'Items received, from {business_name}',NULL,NULL,0,0,0,'2026-07-10 06:43:14','2026-07-10 06:43:14'),(117,12,'items_pending','<p>Dear {contact_name},<br />\r\n                    This is to remind you that we have not yet received some items from invoice reference number {order_ref_number}. Please process it as soon as possible.</p>\r\n\r\n                    <p>{business_name}<br />\r\n                    {business_logo}</p>','This is to remind you that we have not yet received some items from invoice reference number {order_ref_number} . Please process it as soon as possible.{business_name}',NULL,'Items Pending, from {business_name}',NULL,NULL,0,0,0,'2026-07-10 06:43:14','2026-07-10 06:43:14'),(118,12,'new_quotation','<p>Dear {contact_name},</p>\r\n\r\n                    <p>Your quotation number is {invoice_number}<br />\r\n                    Total amount: {total_amount}</p>\r\n\r\n                    <p>Thank you for shopping with us.</p>\r\n\r\n                    <p>{business_logo}</p>\r\n\r\n                    <p>&nbsp;</p>','Dear {contact_name}, Thank you for shopping with us. {business_name}',NULL,'Thank you from {business_name}',NULL,NULL,0,0,0,'2026-07-10 06:43:14','2026-07-10 06:43:14'),(119,12,'purchase_order','<p>Dear {contact_name},</p>\r\n\r\n                    <p>We have a new purchase order with reference number {order_ref_number}. The respective invoice is attached here with.</p>\r\n\r\n                    <p>{business_logo}</p>','We have a new purchase order with reference number {order_ref_number}. {business_name}',NULL,'New Purchase Order, from {business_name}',NULL,NULL,0,0,0,'2026-07-10 06:43:14','2026-07-10 06:43:14');
CREATE TABLE `notifications` (
  `id` char(36) NOT NULL,
  `type` varchar(191) NOT NULL,
  `notifiable_type` varchar(191) NOT NULL,
  `notifiable_id` bigint(20) unsigned NOT NULL,
  `data` text 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;

CREATE TABLE `nst_prepare_products` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned NOT NULL,
  `transaction_date` datetime NOT NULL,
  `ref_no` varchar(191) DEFAULT NULL,
  `from_location_id` int(10) unsigned DEFAULT NULL,
  `product_id` int(10) unsigned NOT NULL,
  `variation_id` int(10) unsigned NOT NULL,
  `purchase_lines_id` int(10) unsigned DEFAULT NULL,
  `transfer_quantity` decimal(22,4) NOT NULL,
  `to_location_id` int(10) unsigned DEFAULT NULL,
  `is_important` tinyint(1) NOT NULL DEFAULT 0,
  `shipping_ratio` decimal(5,2) NOT NULL,
  `value_per_unit` decimal(22,4) NOT NULL,
  `unit_price_after_shipping` decimal(22,4) NOT NULL DEFAULT 0.0000,
  `nst_shipping_id` bigint(20) unsigned DEFAULT NULL,
  `is_shipping_calculated` tinyint(1) NOT NULL DEFAULT 0,
  `note` varchar(191) DEFAULT NULL,
  `status` enum('prepare','receive','partial','complete') NOT NULL DEFAULT 'prepare',
  `created_by` int(10) unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `transaction_id` int(10) unsigned DEFAULT NULL,
  `update_file_path` text DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `nst_prepare_products_business_id_foreign` (`business_id`),
  KEY `nst_prepare_products_from_location_id_foreign` (`from_location_id`),
  KEY `nst_prepare_products_product_id_foreign` (`product_id`),
  KEY `nst_prepare_products_variation_id_foreign` (`variation_id`),
  KEY `nst_prepare_products_purchase_lines_id_foreign` (`purchase_lines_id`),
  KEY `nst_prepare_products_to_location_id_foreign` (`to_location_id`),
  KEY `nst_prepare_products_created_by_foreign` (`created_by`),
  KEY `nst_prepare_products_nst_shipping_id_foreign` (`nst_shipping_id`),
  KEY `nst_prepare_products_transaction_id_foreign` (`transaction_id`),
  KEY `nst_prepare_products_from_location_id_index` (`from_location_id`),
  KEY `nst_prepare_products_to_location_id_index` (`to_location_id`),
  KEY `nst_prepare_products_variation_id_index` (`variation_id`),
  KEY `nst_prepare_products_nst_shipping_id_index` (`nst_shipping_id`),
  KEY `nst_prepare_products_business_id_status_index` (`business_id`,`status`),
  CONSTRAINT `nst_prepare_products_business_id_foreign` FOREIGN KEY (`business_id`) REFERENCES `business` (`id`) ON DELETE CASCADE,
  CONSTRAINT `nst_prepare_products_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  CONSTRAINT `nst_prepare_products_from_location_id_foreign` FOREIGN KEY (`from_location_id`) REFERENCES `business_locations` (`id`) ON DELETE SET NULL,
  CONSTRAINT `nst_prepare_products_nst_shipping_id_foreign` FOREIGN KEY (`nst_shipping_id`) REFERENCES `nst_shipping` (`id`) ON DELETE SET NULL,
  CONSTRAINT `nst_prepare_products_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE,
  CONSTRAINT `nst_prepare_products_purchase_lines_id_foreign` FOREIGN KEY (`purchase_lines_id`) REFERENCES `purchase_lines` (`id`) ON DELETE CASCADE,
  CONSTRAINT `nst_prepare_products_to_location_id_foreign` FOREIGN KEY (`to_location_id`) REFERENCES `business_locations` (`id`) ON DELETE SET NULL,
  CONSTRAINT `nst_prepare_products_transaction_id_foreign` FOREIGN KEY (`transaction_id`) REFERENCES `transactions` (`id`) ON DELETE CASCADE,
  CONSTRAINT `nst_prepare_products_variation_id_foreign` FOREIGN KEY (`variation_id`) REFERENCES `variations` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=87326 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `nst_settings` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned NOT NULL,
  `value` text NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `nst_settings_business_id_foreign` (`business_id`),
  CONSTRAINT `nst_settings_business_id_foreign` FOREIGN KEY (`business_id`) REFERENCES `business` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `nst_shipping` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned NOT NULL,
  `shipping_details` varchar(191) DEFAULT NULL,
  `shipping_method` enum('as_charge','different_ratio','equal_ratio') NOT NULL,
  `shipping_charges` decimal(22,4) NOT NULL DEFAULT 0.0000,
  `additional_expense_key_1` varchar(191) DEFAULT NULL,
  `additional_expense_value_1` decimal(22,4) NOT NULL DEFAULT 0.0000,
  `additional_expense_key_2` varchar(191) DEFAULT NULL,
  `additional_expense_value_2` decimal(22,4) NOT NULL DEFAULT 0.0000,
  `additional_expense_key_3` varchar(191) DEFAULT NULL,
  `additional_expense_value_3` decimal(22,4) NOT NULL DEFAULT 0.0000,
  `additional_expense_key_4` varchar(191) DEFAULT NULL,
  `additional_expense_value_4` decimal(22,4) NOT NULL DEFAULT 0.0000,
  `created_by` int(10) unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `ref_num` varchar(191) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `nst_shipping_business_id_foreign` (`business_id`),
  KEY `nst_shipping_created_by_foreign` (`created_by`),
  CONSTRAINT `nst_shipping_business_id_foreign` FOREIGN KEY (`business_id`) REFERENCES `business` (`id`) ON DELETE CASCADE,
  CONSTRAINT `nst_shipping_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=9941 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `nst_user_locations` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned NOT NULL,
  `user_id` int(10) unsigned NOT NULL,
  `type` varchar(191) NOT NULL COMMENT 'index - add - prepare - receive',
  `location_id` int(10) unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `nst_user_loc_unique` (`business_id`,`user_id`,`type`,`location_id`),
  KEY `nst_user_locations_business_id_foreign` (`business_id`),
  KEY `nst_user_locations_user_id_foreign` (`user_id`),
  KEY `nst_user_locations_location_id_foreign` (`location_id`),
  CONSTRAINT `nst_user_locations_business_id_foreign` FOREIGN KEY (`business_id`) REFERENCES `business` (`id`) ON DELETE CASCADE,
  CONSTRAINT `nst_user_locations_location_id_foreign` FOREIGN KEY (`location_id`) REFERENCES `business_locations` (`id`),
  CONSTRAINT `nst_user_locations_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=1491 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `nutrition_patient_profiles` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `clc_patient_id` int(10) unsigned NOT NULL,
  `bmi` decimal(8,2) DEFAULT NULL,
  `weight_kg` decimal(8,2) DEFAULT NULL,
  `waist_cm` decimal(8,2) DEFAULT NULL,
  `diet_plan` varchar(120) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `nutrition_patient_profiles_clc_patient_id_unique` (`clc_patient_id`),
  CONSTRAINT `nutrition_patient_profiles_clc_patient_id_foreign` FOREIGN KEY (`clc_patient_id`) REFERENCES `clc_patients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `nx_communication_logs` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `level` varchar(10) NOT NULL DEFAULT 'info' COMMENT 'info, success, warning, error',
  `category` varchar(20) NOT NULL DEFAULT 'system' COMMENT 'connection, worklist, result, error, system',
  `device_ip` varchar(45) DEFAULT NULL,
  `sample_no` varchar(13) DEFAULT NULL,
  `message` text NOT NULL,
  `context` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`context`)),
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `nx_communication_logs_created_at_index` (`created_at`),
  KEY `nx_communication_logs_level_index` (`level`),
  KEY `nx_communication_logs_category_index` (`category`)
) ENGINE=InnoDB AUTO_INCREMENT=107 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `nx_device_connections` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `device_ip` varchar(45) DEFAULT NULL,
  `device_port` smallint(5) unsigned DEFAULT NULL,
  `comm_type` enum('1','2','3','A','B','4','C') NOT NULL,
  `status` enum('connected','disconnected','error') NOT NULL DEFAULT 'disconnected',
  `connected_at` timestamp NULL DEFAULT NULL,
  `disconnected_at` timestamp NULL DEFAULT NULL,
  `messages_received` int(10) unsigned NOT NULL DEFAULT 0,
  `results_stored` int(10) unsigned NOT NULL DEFAULT 0,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `nx_device_errors` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `error_date` date NOT NULL,
  `error_time` time NOT NULL,
  `error_number` varchar(5) NOT NULL COMMENT 'Alphanumeric error code e.g. E0110',
  `added_info` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT 'Array of up to 9 additional info fields' CHECK (json_valid(`added_info`)),
  `device_ip` varchar(45) DEFAULT NULL,
  `comm_type` enum('1','2','3','A','B','4','C') DEFAULT NULL,
  `acknowledged` tinyint(1) NOT NULL DEFAULT 0,
  `acknowledged_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `nx_device_errors_error_date_error_time_index` (`error_date`,`error_time`),
  KEY `nx_device_errors_error_number_index` (`error_number`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `nx_lab_providers` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned NOT NULL,
  `key` varchar(30) NOT NULL,
  `display_name` varchar(100) NOT NULL,
  `endpoint` text DEFAULT NULL,
  `credentials` text DEFAULT NULL,
  `enabled` tinyint(1) NOT NULL DEFAULT 1,
  `is_default` tinyint(1) NOT NULL DEFAULT 0,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `nx_lab_providers_business_id_key_unique` (`business_id`,`key`),
  KEY `nx_lab_providers_business_id_index` (`business_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `nx_module_settings` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned NOT NULL,
  `key` varchar(100) NOT NULL,
  `value` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `nx_module_settings_business_id_key_unique` (`business_id`,`key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `nx_patients` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned DEFAULT NULL,
  `patient_id` varchar(13) DEFAULT NULL COMMENT 'External / device patient code',
  `patient_name` varchar(60) DEFAULT NULL,
  `sex` tinyint(4) NOT NULL DEFAULT 9 COMMENT '0=Male, 1=Female, 9=Unknown',
  `age` smallint(5) unsigned NOT NULL DEFAULT 999 COMMENT '999=Unknown',
  `species` tinyint(4) NOT NULL DEFAULT 0 COMMENT '0-99 NX600 species code',
  `contact_id` int(10) unsigned DEFAULT NULL COMMENT 'VetClinic pet owner contact',
  `vc_pet_id` int(10) unsigned DEFAULT NULL COMMENT 'VetClinic pet',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `nx_patients_patient_id_index` (`patient_id`),
  KEY `nx_patients_business_id_index` (`business_id`),
  KEY `nx_patients_contact_id_index` (`contact_id`),
  KEY `nx_patients_vc_pet_id_index` (`vc_pet_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `nx_test_results` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `test_session_id` int(10) unsigned NOT NULL,
  `test_name` varchar(10) NOT NULL COMMENT 'e.g. GLU-P, ALB-W',
  `base_name` varchar(8) DEFAULT NULL COMMENT 'Test name without sample type suffix',
  `sample_suffix` varchar(3) DEFAULT NULL COMMENT '-W, -P, -U or empty',
  `equality` varchar(1) NOT NULL DEFAULT '=' COMMENT '= > < *',
  `result` varchar(20) DEFAULT NULL COMMENT 'Numeric or special: +, -, -OR, ****, E, EXP, CHK QC',
  `unit` varchar(8) DEFAULT NULL COMMENT 'e.g. mg/dl',
  `dilution_factor` tinyint(3) unsigned NOT NULL DEFAULT 1,
  `ref_lower` varchar(5) DEFAULT NULL COMMENT 'Reference range lower bound',
  `ref_upper` varchar(5) DEFAULT NULL COMMENT 'Reference range upper bound',
  `warn_high` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'H: above upper reference limit',
  `warn_low` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'L: below lower reference limit',
  `warn_out_of_range` tinyint(1) NOT NULL DEFAULT 0 COMMENT '@: outside determination range',
  `warn_slide_expired` tinyint(1) NOT NULL DEFAULT 0 COMMENT '#: slide valid term expired',
  `warn_temp_error` tinyint(1) NOT NULL DEFAULT 0 COMMENT '$: temperature control error',
  `warn_photometer_error` tinyint(1) NOT NULL DEFAULT 0 COMMENT '*/?',
  `warn_high_value` tinyint(1) NOT NULL DEFAULT 0 COMMENT '&: abnormally high testing value',
  `warn_calc_error` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'E: calculation error',
  `warn_unspotted` tinyint(1) NOT NULL DEFAULT 0 COMMENT '\\: un-spotted slide',
  `raw_warning` varchar(11) DEFAULT NULL COMMENT 'Raw 11-char warning string',
  `is_abnormal` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Any abnormal flag active',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `nx_test_results_test_session_id_test_name_index` (`test_session_id`,`test_name`),
  KEY `nx_test_results_test_name_index` (`test_name`),
  CONSTRAINT `nx_test_results_test_session_id_foreign` FOREIGN KEY (`test_session_id`) REFERENCES `nx_test_sessions` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=73 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `nx_test_sessions` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned DEFAULT NULL,
  `sample_no` varchar(13) NOT NULL,
  `patient_id` varchar(13) DEFAULT NULL,
  `patient_name` varchar(60) DEFAULT NULL,
  `test_condition` enum('NORMAL','CONTROL') NOT NULL DEFAULT 'NORMAL',
  `test_date` date NOT NULL,
  `test_time` time NOT NULL,
  `sample_type` varchar(1) DEFAULT NULL COMMENT 'W=Whole blood, P=Plasma/Serum, U=Urine',
  `species` tinyint(4) NOT NULL DEFAULT 0,
  `sex` tinyint(4) NOT NULL DEFAULT 9 COMMENT '0=Male, 1=Female, 9=Unknown',
  `age` smallint(5) unsigned NOT NULL DEFAULT 999,
  `sample_position` varchar(2) NOT NULL DEFAULT '01',
  `operator_id` varchar(13) DEFAULT NULL,
  `emergency_test` tinyint(1) NOT NULL DEFAULT 0,
  `analyzer_id` varchar(8) DEFAULT NULL,
  `slide_lot` varchar(6) DEFAULT NULL,
  `valid_term` varchar(6) DEFAULT NULL COMMENT 'YYYYMM format',
  `comm_type` enum('1','2','3','A','B','4','C') NOT NULL DEFAULT '1',
  `device_ip` varchar(45) DEFAULT NULL,
  `contact_id` int(10) unsigned DEFAULT NULL COMMENT 'VetClinic pet owner contact',
  `vc_pet_id` int(10) unsigned DEFAULT NULL COMMENT 'VetClinic pet',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `nx_session_sample_date_unique` (`sample_no`,`test_date`),
  KEY `nx_test_sessions_test_date_test_time_index` (`test_date`,`test_time`),
  KEY `nx_test_sessions_business_id_index` (`business_id`),
  KEY `nx_test_sessions_sample_no_index` (`sample_no`),
  KEY `nx_test_sessions_patient_id_index` (`patient_id`),
  KEY `nx_test_sessions_contact_id_index` (`contact_id`),
  KEY `nx_test_sessions_vc_pet_id_index` (`vc_pet_id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `nx_worklist` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned DEFAULT NULL,
  `sample_no` varchar(13) NOT NULL,
  `patient_id` varchar(13) DEFAULT NULL,
  `patient_name` varchar(60) DEFAULT NULL,
  `species` tinyint(4) NOT NULL DEFAULT 0,
  `sex` tinyint(4) NOT NULL DEFAULT 9 COMMENT '0=Male, 1=Female, 9=Unknown',
  `age` smallint(5) unsigned NOT NULL DEFAULT 999,
  `test_names` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT 'Array of test names to run, max 30' CHECK (json_valid(`test_names`)),
  `is_sent` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Whether the device has retrieved this entry',
  `sent_at` timestamp NULL DEFAULT NULL,
  `contact_id` int(10) unsigned DEFAULT NULL COMMENT 'VetClinic pet owner contact',
  `vc_pet_id` int(10) unsigned DEFAULT NULL COMMENT 'VetClinic pet',
  `created_by` bigint(20) unsigned 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 `nx_worklist_sample_no_unique` (`sample_no`),
  KEY `nx_worklist_sample_no_index` (`sample_no`),
  KEY `nx_worklist_is_sent_index` (`is_sent`),
  KEY `nx_worklist_business_id_index` (`business_id`),
  KEY `nx_worklist_contact_id_index` (`contact_id`),
  KEY `nx_worklist_vc_pet_id_index` (`vc_pet_id`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `oauth_access_tokens` (
  `id` varchar(100) NOT NULL,
  `user_id` bigint(20) DEFAULT NULL,
  `client_id` int(10) unsigned NOT NULL,
  `name` varchar(191) DEFAULT NULL,
  `scopes` text DEFAULT NULL,
  `revoked` tinyint(1) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `expires_at` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `oauth_access_tokens_user_id_index` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `oauth_auth_codes` (
  `id` varchar(100) NOT NULL,
  `user_id` bigint(20) NOT NULL,
  `client_id` int(10) unsigned NOT NULL,
  `scopes` text DEFAULT NULL,
  `revoked` tinyint(1) NOT NULL,
  `expires_at` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `oauth_clients` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint(20) DEFAULT NULL,
  `name` varchar(191) NOT NULL,
  `secret` varchar(100) NOT NULL,
  `provider` varchar(191) DEFAULT NULL,
  `redirect` text NOT NULL,
  `personal_access_client` tinyint(1) NOT NULL,
  `password_client` tinyint(1) NOT NULL,
  `revoked` tinyint(1) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `oauth_clients_user_id_index` (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `oauth_clients` VALUES (21,NULL,'VET One Personal Access','BVJtZzY3oviq1YWFO1j4DYaQienExo2CDCcbTPm9',NULL,'http://localhost',1,0,0,'2026-06-15 17:18:45','2026-06-15 17:18:45');
CREATE TABLE `oauth_personal_access_clients` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `client_id` int(10) unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `oauth_personal_access_clients_client_id_index` (`client_id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `oauth_personal_access_clients` VALUES (10,21,'2026-06-15 17:18:45','2026-06-15 17:18:45');
CREATE TABLE `oauth_refresh_tokens` (
  `id` varchar(100) NOT NULL,
  `access_token_id` varchar(100) NOT NULL,
  `revoked` tinyint(1) NOT NULL,
  `expires_at` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `oauth_refresh_tokens_access_token_id_index` (`access_token_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `obgyn_patient_profiles` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `clc_patient_id` int(10) unsigned NOT NULL,
  `gravida` smallint(5) unsigned DEFAULT NULL,
  `para` smallint(5) unsigned DEFAULT NULL,
  `abortions` smallint(5) unsigned DEFAULT NULL,
  `living` smallint(5) unsigned DEFAULT NULL,
  `menarche_age` smallint(5) unsigned DEFAULT NULL,
  `lmp_date` date DEFAULT NULL,
  `cycle_length_days` smallint(5) unsigned DEFAULT NULL,
  `cycle_regular` tinyint(1) NOT NULL DEFAULT 1,
  `contraception` varchar(60) DEFAULT NULL,
  `is_pregnant` tinyint(1) NOT NULL DEFAULT 0,
  `menopause` tinyint(1) NOT NULL DEFAULT 0,
  `notes` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `obgyn_patient_profiles_clc_patient_id_unique` (`clc_patient_id`),
  CONSTRAINT `obgyn_patient_profiles_clc_patient_id_foreign` FOREIGN KEY (`clc_patient_id`) REFERENCES `clc_patients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `oncology_patient_profiles` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `clc_patient_id` int(10) unsigned NOT NULL,
  `tumour_site` varchar(120) DEFAULT NULL,
  `tnm_stage` varchar(120) DEFAULT NULL,
  `ecog` varchar(40) DEFAULT NULL,
  `histology` varchar(120) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `oncology_patient_profiles_clc_patient_id_unique` (`clc_patient_id`),
  CONSTRAINT `oncology_patient_profiles_clc_patient_id_foreign` FOREIGN KEY (`clc_patient_id`) REFERENCES `clc_patients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `oncology_surgery_patient_profiles` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `clc_patient_id` int(10) unsigned NOT NULL,
  `tumour_site` varchar(120) DEFAULT NULL,
  `resectability` varchar(40) DEFAULT NULL,
  `planned_procedure` varchar(120) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `oncology_surgery_patient_profiles_clc_patient_id_unique` (`clc_patient_id`),
  CONSTRAINT `oncology_surgery_patient_profiles_clc_patient_id_foreign` FOREIGN KEY (`clc_patient_id`) REFERENCES `clc_patients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `ophth_patient_profiles` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `clc_patient_id` int(10) unsigned NOT NULL,
  `va_right` varchar(15) DEFAULT NULL,
  `va_left` varchar(15) DEFAULT NULL,
  `sphere_right` decimal(5,2) DEFAULT NULL,
  `cylinder_right` decimal(5,2) DEFAULT NULL,
  `axis_right` smallint(5) unsigned DEFAULT NULL,
  `sphere_left` decimal(5,2) DEFAULT NULL,
  `cylinder_left` decimal(5,2) DEFAULT NULL,
  `axis_left` smallint(5) unsigned DEFAULT NULL,
  `iop_right` decimal(4,1) DEFAULT NULL,
  `iop_left` decimal(4,1) DEFAULT NULL,
  `wears_glasses` tinyint(1) NOT NULL DEFAULT 0,
  `notes` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `ophth_patient_profiles_clc_patient_id_unique` (`clc_patient_id`),
  CONSTRAINT `ophth_patient_profiles_clc_patient_id_foreign` FOREIGN KEY (`clc_patient_id`) REFERENCES `clc_patients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `orthopedics_patient_profiles` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `clc_patient_id` int(10) unsigned NOT NULL,
  `affected_joint` varchar(120) DEFAULT NULL,
  `rom` varchar(40) DEFAULT NULL,
  `neurovascular` varchar(40) DEFAULT NULL,
  `imaging` varchar(120) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `orthopedics_patient_profiles_clc_patient_id_unique` (`clc_patient_id`),
  CONSTRAINT `orthopedics_patient_profiles_clc_patient_id_foreign` FOREIGN KEY (`clc_patient_id`) REFERENCES `clc_patients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `osteopathy_patient_profiles` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `clc_patient_id` int(10) unsigned NOT NULL,
  `posture` varchar(40) DEFAULT NULL,
  `mobility` varchar(40) DEFAULT NULL,
  `notes` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `osteopathy_patient_profiles_clc_patient_id_unique` (`clc_patient_id`),
  CONSTRAINT `osteopathy_patient_profiles_clc_patient_id_foreign` FOREIGN KEY (`clc_patient_id`) REFERENCES `clc_patients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `pain_management_patient_profiles` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `clc_patient_id` int(10) unsigned NOT NULL,
  `pain_score` int(11) DEFAULT NULL,
  `pain_site` varchar(120) DEFAULT NULL,
  `pain_type` varchar(40) DEFAULT NULL,
  `duration` varchar(120) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `pain_management_patient_profiles_clc_patient_id_unique` (`clc_patient_id`),
  CONSTRAINT `pain_management_patient_profiles_clc_patient_id_foreign` FOREIGN KEY (`clc_patient_id`) REFERENCES `clc_patients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `password_resets` (
  `email` varchar(191) NOT NULL,
  `token` varchar(191) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  KEY `password_resets_email_index` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `pc_change_reports` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned NOT NULL,
  `product_id` int(10) unsigned NOT NULL,
  `run_id` varchar(191) NOT NULL,
  `action` enum('parse','enrich') NOT NULL DEFAULT 'parse',
  `old_data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`old_data`)),
  `new_data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`new_data`)),
  `removed_data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`removed_data`)),
  `missing_data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`missing_data`)),
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `pc_change_reports_business_id_product_id_index` (`business_id`,`product_id`),
  KEY `pc_change_reports_run_id_index` (`run_id`)
) ENGINE=InnoDB AUTO_INCREMENT=12770 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `pc_compatibles` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned NOT NULL,
  `product_id` int(10) unsigned NOT NULL,
  `compatible_product_id` int(10) unsigned NOT NULL,
  `relation_type` enum('compatible','replacement','accessory') NOT NULL DEFAULT 'compatible',
  `source` varchar(32) NOT NULL DEFAULT 'manual',
  `confidence` tinyint(3) unsigned NOT NULL DEFAULT 100,
  `needs_review` tinyint(1) NOT NULL DEFAULT 0,
  `verified_at` timestamp NULL DEFAULT NULL,
  `verified_by` int(10) unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `pc_compatibles_unique` (`product_id`,`compatible_product_id`,`relation_type`),
  KEY `pc_compatibles_business_id_product_id_index` (`business_id`,`product_id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `pc_device_compat` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned NOT NULL,
  `product_id` int(10) unsigned NOT NULL,
  `device_model_id` bigint(20) unsigned NOT NULL,
  `source` varchar(32) NOT NULL DEFAULT 'manual',
  `confidence` tinyint(3) unsigned NOT NULL DEFAULT 100,
  `needs_review` tinyint(1) NOT NULL DEFAULT 0,
  `verified_at` timestamp NULL DEFAULT NULL,
  `verified_by` int(10) unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `pc_device_compat_unique` (`product_id`,`device_model_id`),
  KEY `pc_device_compat_business_id_product_id_index` (`business_id`,`product_id`)
) ENGINE=InnoDB AUTO_INCREMENT=25703 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `pc_device_models` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned NOT NULL,
  `brand` varchar(191) DEFAULT NULL,
  `series` varchar(191) DEFAULT NULL,
  `model` varchar(191) NOT NULL,
  `normalized_key` varchar(191) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `pc_device_models_unique` (`business_id`,`normalized_key`),
  KEY `pc_device_models_business_id_brand_index` (`business_id`,`brand`)
) ENGINE=InnoDB AUTO_INCREMENT=18778 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `pc_enrichment_log` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned NOT NULL,
  `product_id` int(10) unsigned NOT NULL,
  `provider` varchar(191) DEFAULT NULL,
  `status` varchar(191) NOT NULL DEFAULT 'pending',
  `raw_payload` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`raw_payload`)),
  `candidates` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`candidates`)),
  `message` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `pc_enrichment_log_business_id_product_id_index` (`business_id`,`product_id`)
) ENGINE=InnoDB AUTO_INCREMENT=9091 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `pc_jobs` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned DEFAULT NULL,
  `type` varchar(32) NOT NULL,
  `status` varchar(16) NOT NULL DEFAULT 'running',
  `total` int(10) unsigned NOT NULL DEFAULT 0,
  `processed` int(10) unsigned NOT NULL DEFAULT 0,
  `matched` int(10) unsigned NOT NULL DEFAULT 0,
  `added_parts` int(10) unsigned NOT NULL DEFAULT 0,
  `added_devices` int(10) unsigned NOT NULL DEFAULT 0,
  `added_barcodes` int(10) unsigned NOT NULL DEFAULT 0,
  `cursor` int(10) unsigned NOT NULL DEFAULT 0,
  `trigger` varchar(16) NOT NULL DEFAULT 'ui',
  `message` text DEFAULT NULL,
  `started_at` timestamp NULL DEFAULT NULL,
  `finished_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `pc_jobs_business_id_type_status_index` (`business_id`,`type`,`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `pc_part_numbers` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned NOT NULL,
  `product_id` int(10) unsigned NOT NULL,
  `part_number` varchar(191) NOT NULL,
  `normalized` varchar(191) NOT NULL,
  `type` enum('mpn','oem','model_code','internal','other') NOT NULL DEFAULT 'other',
  `is_primary` tinyint(1) NOT NULL DEFAULT 0,
  `source` varchar(32) NOT NULL DEFAULT 'manual',
  `confidence` tinyint(3) unsigned NOT NULL DEFAULT 100,
  `needs_review` tinyint(1) NOT NULL DEFAULT 0,
  `verified_at` timestamp NULL DEFAULT NULL,
  `verified_by` int(10) unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `pc_part_numbers_unique` (`business_id`,`product_id`,`normalized`),
  KEY `pc_part_numbers_business_id_normalized_index` (`business_id`,`normalized`),
  KEY `pc_part_numbers_normalized_index` (`normalized`)
) ENGINE=InnoDB AUTO_INCREMENT=46363 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `pc_product_barcodes` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned NOT NULL,
  `product_id` int(10) unsigned NOT NULL,
  `barcode` varchar(64) NOT NULL,
  `type` varchar(16) NOT NULL DEFAULT 'gtin',
  `source` varchar(32) NOT NULL DEFAULT 'manual',
  `confidence` tinyint(3) unsigned NOT NULL DEFAULT 100,
  `needs_review` tinyint(1) NOT NULL DEFAULT 0,
  `verified_at` timestamp NULL DEFAULT NULL,
  `verified_by` int(10) unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `pc_product_barcodes_unique` (`business_id`,`product_id`,`barcode`),
  KEY `pc_product_barcodes_business_id_barcode_index` (`business_id`,`barcode`)
) ENGINE=InnoDB AUTO_INCREMENT=415 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `pc_product_status` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned NOT NULL,
  `product_id` int(10) unsigned NOT NULL,
  `checked_at` timestamp NULL DEFAULT NULL,
  `checked_by` int(10) unsigned DEFAULT NULL,
  `custom_fields_cleared_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `pc_product_status_unique` (`business_id`,`product_id`)
) ENGINE=InnoDB AUTO_INCREMENT=13464 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `pc_settings` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `key` varchar(64) NOT NULL,
  `value` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `pc_settings_key_unique` (`key`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `pediatric_surgery_patient_profiles` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `clc_patient_id` int(10) unsigned NOT NULL,
  `diagnosis` varchar(120) DEFAULT NULL,
  `weight_kg` decimal(8,2) DEFAULT NULL,
  `planned_procedure` varchar(120) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `pediatric_surgery_patient_profiles_clc_patient_id_unique` (`clc_patient_id`),
  CONSTRAINT `pediatric_surgery_patient_profiles_clc_patient_id_foreign` FOREIGN KEY (`clc_patient_id`) REFERENCES `clc_patients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `pediatrics_patient_profiles` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `clc_patient_id` int(10) unsigned NOT NULL,
  `weight_percentile` int(11) DEFAULT NULL,
  `height_percentile` int(11) DEFAULT NULL,
  `head_circ_percentile` int(11) DEFAULT NULL,
  `milestones` varchar(40) DEFAULT NULL,
  `immunisation` varchar(40) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `pediatrics_patient_profiles_clc_patient_id_unique` (`clc_patient_id`),
  CONSTRAINT `pediatrics_patient_profiles_clc_patient_id_foreign` FOREIGN KEY (`clc_patient_id`) REFERENCES `clc_patients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `permissions` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(191) NOT NULL,
  `guard_name` varchar(191) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=629 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `permissions` VALUES (508,'user.view','web','2026-06-15 17:18:41',NULL),(509,'user.create','web','2026-06-15 17:18:41',NULL),(510,'user.update','web','2026-06-15 17:18:41',NULL),(511,'user.delete','web','2026-06-15 17:18:41',NULL),(512,'supplier.view','web','2026-06-15 17:18:41',NULL),(513,'supplier.create','web','2026-06-15 17:18:41',NULL),(514,'supplier.update','web','2026-06-15 17:18:41',NULL),(515,'supplier.delete','web','2026-06-15 17:18:41',NULL),(516,'customer.view','web','2026-06-15 17:18:41',NULL),(517,'customer.create','web','2026-06-15 17:18:41',NULL),(518,'customer.update','web','2026-06-15 17:18:41',NULL),(519,'customer.delete','web','2026-06-15 17:18:41',NULL),(520,'product.view','web','2026-06-15 17:18:41',NULL),(521,'product.create','web','2026-06-15 17:18:41',NULL),(522,'product.update','web','2026-06-15 17:18:41',NULL),(523,'product.delete','web','2026-06-15 17:18:41',NULL),(524,'purchase.view','web','2026-06-15 17:18:41',NULL),(525,'purchase.create','web','2026-06-15 17:18:41',NULL),(526,'purchase.update','web','2026-06-15 17:18:41',NULL),(527,'purchase.delete','web','2026-06-15 17:18:41',NULL),(528,'sell.view','web','2026-06-15 17:18:41',NULL),(529,'sell.create','web','2026-06-15 17:18:41',NULL),(530,'sell.update','web','2026-06-15 17:18:41',NULL),(531,'sell.delete','web','2026-06-15 17:18:41',NULL),(532,'purchase_n_sell_report.view','web','2026-06-15 17:18:41',NULL),(533,'contacts_report.view','web','2026-06-15 17:18:41',NULL),(534,'stock_report.view','web','2026-06-15 17:18:41',NULL),(535,'tax_report.view','web','2026-06-15 17:18:41',NULL),(536,'trending_product_report.view','web','2026-06-15 17:18:41',NULL),(537,'register_report.view','web','2026-06-15 17:18:41',NULL),(538,'sales_representative.view','web','2026-06-15 17:18:41',NULL),(539,'expense_report.view','web','2026-06-15 17:18:41',NULL),(540,'business_settings.access','web','2026-06-15 17:18:41',NULL),(541,'barcode_settings.access','web','2026-06-15 17:18:41',NULL),(542,'invoice_settings.access','web','2026-06-15 17:18:41',NULL),(543,'brand.view','web','2026-06-15 17:18:41',NULL),(544,'brand.create','web','2026-06-15 17:18:41',NULL),(545,'brand.update','web','2026-06-15 17:18:41',NULL),(546,'brand.delete','web','2026-06-15 17:18:41',NULL),(547,'tax_rate.view','web','2026-06-15 17:18:41',NULL),(548,'tax_rate.create','web','2026-06-15 17:18:41',NULL),(549,'tax_rate.update','web','2026-06-15 17:18:41',NULL),(550,'tax_rate.delete','web','2026-06-15 17:18:41',NULL),(551,'unit.view','web','2026-06-15 17:18:41',NULL),(552,'unit.create','web','2026-06-15 17:18:41',NULL),(553,'unit.update','web','2026-06-15 17:18:41',NULL),(554,'unit.delete','web','2026-06-15 17:18:41',NULL),(555,'category.view','web','2026-06-15 17:18:41',NULL),(556,'category.create','web','2026-06-15 17:18:41',NULL),(557,'category.update','web','2026-06-15 17:18:41',NULL),(558,'category.delete','web','2026-06-15 17:18:41',NULL),(559,'expense.access','web','2026-06-15 17:18:41',NULL),(560,'access_all_locations','web','2026-06-15 17:18:41',NULL),(561,'dashboard.data','web','2026-06-15 17:18:41',NULL),(562,'view_cash_register','web','2026-06-15 17:18:42','2026-06-15 17:18:42'),(563,'close_cash_register','web','2026-06-15 17:18:42','2026-06-15 17:18:42'),(564,'location.16','web','2026-06-15 17:18:42','2026-06-15 17:18:42'),(565,'location.17','web','2026-06-15 17:18:42','2026-06-15 17:18:42'),(566,'location.18','web','2026-06-15 17:18:42','2026-06-15 17:18:42'),(567,'tpsTransfer.access_index_stock_transfers','web','2026-06-15 18:11:46','2026-06-15 18:11:46'),(568,'tpsTransfer.access_add_stock_transfer','web','2026-06-15 18:11:46','2026-06-15 18:11:46'),(569,'tpsTransfer.access_prepare_stock_transfer','web','2026-06-15 18:11:46','2026-06-15 18:11:46'),(570,'tpsTransfer.access_received_stock_transfer','web','2026-06-15 18:11:46','2026-06-15 18:11:46'),(571,'tpsTransfer.access_transactions_stock_transfers','web','2026-06-15 18:11:46','2026-06-15 18:11:46'),(572,'tpsTransfer.access_settings_stock_transfer','web','2026-06-15 18:11:46','2026-06-15 18:11:46'),(573,'tpsTransfer.access_all_locations_from','web','2026-06-15 18:11:46','2026-06-15 18:11:46'),(574,'tpsTransfer.access_all_locations_to','web','2026-06-15 18:11:46','2026-06-15 18:11:46'),(575,'location.19','web','2026-06-17 20:54:54','2026-06-17 20:54:54'),(576,'location.20','web','2026-06-17 20:54:54','2026-06-17 20:54:54'),(577,'location.21','web','2026-06-17 20:54:54','2026-06-17 20:54:54'),(578,'location.22','web','2026-06-17 20:55:44','2026-06-17 20:55:44'),(579,'location.23','web','2026-06-17 20:55:44','2026-06-17 20:55:44'),(580,'location.24','web','2026-06-17 20:55:44','2026-06-17 20:55:44'),(581,'location.25','web','2026-06-17 20:58:10','2026-06-17 20:58:10'),(582,'location.26','web','2026-06-17 20:58:10','2026-06-17 20:58:10'),(583,'location.27','web','2026-06-17 20:58:10','2026-06-17 20:58:10'),(584,'location.28','web','2026-06-17 21:00:01','2026-06-17 21:00:01'),(585,'location.29','web','2026-06-17 21:00:01','2026-06-17 21:00:01'),(586,'location.30','web','2026-06-17 21:00:01','2026-06-17 21:00:01'),(587,'location.31','web','2026-06-17 21:11:53','2026-06-17 21:11:53'),(588,'location.32','web','2026-06-17 21:11:53','2026-06-17 21:11:53'),(589,'location.33','web','2026-06-17 21:11:53','2026-06-17 21:11:53'),(590,'vet_site.access_module','web','2026-06-18 20:21:57','2026-06-18 20:21:57'),(591,'vet_site.manage_content','web','2026-06-18 20:21:57','2026-06-18 20:21:57'),(592,'vet_site.manage_design','web','2026-06-18 20:21:57','2026-06-18 20:21:57'),(593,'vet_site.manage_settings','web','2026-06-18 20:21:57','2026-06-18 20:21:57'),(594,'vet_admission.bypass_deposit','web','2026-06-18 22:57:08','2026-06-18 22:57:08'),(595,'vet_clinic.access_module','web','2026-06-24 08:21:15','2026-06-24 08:21:15'),(596,'vet_clinic.manage_pet_owners','web','2026-06-24 08:21:15','2026-06-24 08:21:15'),(597,'vet_clinic.manage_pets','web','2026-06-24 08:21:15','2026-06-24 08:21:15'),(598,'vet_clinic.view_appointments','web','2026-06-24 08:21:15','2026-06-24 08:21:15'),(599,'vet_clinic.manage_appointments','web','2026-06-24 08:21:15','2026-06-24 08:21:15'),(600,'vet_clinic.view_owner_blocking','web','2026-06-24 08:21:15','2026-06-24 08:21:15'),(601,'vet_clinic.change_appointment_doctor','web','2026-06-24 08:21:15','2026-06-24 08:21:15'),(602,'vet_clinic.manage_prescriptions','web','2026-06-24 08:21:15','2026-06-24 08:21:15'),(603,'vet_clinic.dispense_prescriptions','web','2026-06-24 08:21:15','2026-06-24 08:21:15'),(604,'vet_clinic.manage_vaccinations','web','2026-06-24 08:21:15','2026-06-24 08:21:15'),(605,'vet_clinic.manage_reports','web','2026-06-24 08:21:15','2026-06-24 08:21:15'),(606,'vet_clinic.view_reports','web','2026-06-24 08:21:15','2026-06-24 08:21:15'),(607,'vet_clinic.view_critical_report','web','2026-06-24 08:21:15','2026-06-24 08:21:15'),(608,'vet_clinic.record_exam_findings','web','2026-06-24 08:21:15','2026-06-24 08:21:15'),(609,'vet_clinic.view_exam_findings','web','2026-06-24 08:21:15','2026-06-24 08:21:15'),(610,'vet_clinic.evaluate_pet_owner','web','2026-06-24 08:21:16','2026-06-24 08:21:16'),(611,'vet_clinic.manage_subject_notes','web','2026-06-24 08:21:16','2026-06-24 08:21:16'),(612,'vet_clinic.view_confidential_notes','web','2026-06-24 08:21:16','2026-06-24 08:21:16'),(613,'vet_clinic.manage_controlled','web','2026-06-24 08:21:16','2026-06-24 08:21:16'),(614,'vet_ai.access_module','web','2026-06-24 08:21:16','2026-06-24 08:21:16'),(615,'vet_ai.use_assistant','web','2026-06-24 08:21:16','2026-06-24 08:21:16'),(616,'vet_ai.use_transcription','web','2026-06-24 08:21:16','2026-06-24 08:21:16'),(617,'vet_clinic.manage_medicines','web','2026-06-24 08:21:16','2026-06-24 08:21:16'),(618,'vet_clinic.manage_exam_templates','web','2026-06-24 08:21:16','2026-06-24 08:21:16'),(619,'vet_clinic.manage_owner_blocking','web','2026-06-24 08:21:16','2026-06-24 08:21:16'),(620,'vet_clinic.manage_evaluation_questions','web','2026-06-24 08:21:16','2026-06-24 08:21:16'),(621,'vet_clinic.review_evaluations','web','2026-06-24 08:21:16','2026-06-24 08:21:16'),(622,'vet_clinic.evaluate_doctor','web','2026-06-24 08:21:16','2026-06-24 08:21:16'),(623,'vet_clinic.approve_edit_requests','web','2026-06-24 08:21:16','2026-06-24 08:21:16'),(624,'vet_clinic.approve_doctor_change','web','2026-06-24 08:21:16','2026-06-24 08:21:16'),(625,'vet_clinic.manage_settings','web','2026-06-24 08:21:16','2026-06-24 08:21:16'),(626,'vet_ai.manage_settings','web','2026-06-24 08:21:16','2026-06-24 08:21:16'),(627,'location.34','web','2026-07-10 05:40:55','2026-07-10 05:40:55'),(628,'location.35','web','2026-07-10 06:43:14','2026-07-10 06:43:14');
CREATE TABLE `phoniatrics_patient_profiles` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `clc_patient_id` int(10) unsigned NOT NULL,
  `voice_quality` varchar(40) DEFAULT NULL,
  `laryngoscopy` varchar(40) DEFAULT NULL,
  `notes` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `phoniatrics_patient_profiles_clc_patient_id_unique` (`clc_patient_id`),
  CONSTRAINT `phoniatrics_patient_profiles_clc_patient_id_foreign` FOREIGN KEY (`clc_patient_id`) REFERENCES `clc_patients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `physiotherapy_patient_profiles` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `clc_patient_id` int(10) unsigned NOT NULL,
  `affected_region` varchar(120) DEFAULT NULL,
  `rom` varchar(40) DEFAULT NULL,
  `strength` varchar(40) DEFAULT NULL,
  `goal` varchar(120) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `physiotherapy_patient_profiles_clc_patient_id_unique` (`clc_patient_id`),
  CONSTRAINT `physiotherapy_patient_profiles_clc_patient_id_foreign` FOREIGN KEY (`clc_patient_id`) REFERENCES `clc_patients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `plastic_surgery_patient_profiles` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `clc_patient_id` int(10) unsigned NOT NULL,
  `defect_site` varchar(120) DEFAULT NULL,
  `procedure_type` varchar(40) DEFAULT NULL,
  `planned_procedure` varchar(120) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `plastic_surgery_patient_profiles_clc_patient_id_unique` (`clc_patient_id`),
  CONSTRAINT `plastic_surgery_patient_profiles_clc_patient_id_foreign` FOREIGN KEY (`clc_patient_id`) REFERENCES `clc_patients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `portal_brands` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned NOT NULL,
  `slug` varchar(64) NOT NULL,
  `custom_domain` varchar(191) DEFAULT NULL,
  `name` varchar(191) NOT NULL,
  `accent_hex` varchar(9) NOT NULL DEFAULT '#0d9488',
  `logo_url` varchar(191) DEFAULT NULL,
  `contact_phone` varchar(32) DEFAULT NULL,
  `contact_email` varchar(191) DEFAULT NULL,
  `address` varchar(191) DEFAULT NULL,
  `login_methods` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`login_methods`)),
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `public_booking` tinyint(1) NOT NULL DEFAULT 0,
  `booking_otp` tinyint(1) NOT NULL DEFAULT 0,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `portal_brands_business_id_unique` (`business_id`),
  UNIQUE KEY `portal_brands_slug_unique` (`slug`),
  UNIQUE KEY `portal_brands_custom_domain_unique` (`custom_domain`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `portal_brands` VALUES (8,11,'happy-paws-1783662055',NULL,'Happy Paws Test 1783662055','#7c3aed',NULL,'01000000000','owner1783662055@vetone.local','Nasr City, Cairo, Cairo, Egypt','[\"otp\",\"magic\",\"password\",\"staff\"]',1,0,0,'2026-07-10 05:40:55','2026-07-10 05:40:55');
CREATE TABLE `portal_magic_tokens` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `owner_id` bigint(20) unsigned NOT NULL,
  `email` varchar(191) NOT NULL,
  `token_hash` varchar(64) NOT NULL,
  `expires_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `used_at` timestamp NULL DEFAULT NULL,
  `user_agent` varchar(191) DEFAULT NULL,
  `ip` varchar(45) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `portal_magic_tokens_token_hash_unique` (`token_hash`),
  KEY `portal_magic_tokens_owner_id_foreign` (`owner_id`),
  KEY `portal_magic_tokens_email_index` (`email`),
  KEY `portal_magic_tokens_expires_at_index` (`expires_at`),
  CONSTRAINT `portal_magic_tokens_owner_id_foreign` FOREIGN KEY (`owner_id`) REFERENCES `portal_owners` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `portal_messages` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned NOT NULL,
  `owner_id` bigint(20) unsigned NOT NULL,
  `sender` enum('owner','clinic') NOT NULL,
  `sender_user_id` bigint(20) unsigned DEFAULT NULL,
  `body` text NOT NULL,
  `attachments` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`attachments`)),
  `reply_to_id` bigint(20) unsigned DEFAULT NULL,
  `read_at` datetime DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `portal_messages_business_id_owner_id_created_at_index` (`business_id`,`owner_id`,`created_at`),
  KEY `portal_messages_business_id_owner_id_read_at_index` (`business_id`,`owner_id`,`read_at`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `portal_notifications` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned NOT NULL,
  `owner_id` bigint(20) unsigned NOT NULL,
  `category` varchar(32) NOT NULL,
  `title` varchar(191) NOT NULL,
  `body` varchar(500) NOT NULL,
  `url` varchar(300) DEFAULT NULL,
  `read_at` datetime DEFAULT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `portal_notifications_business_id_owner_id_created_at_index` (`business_id`,`owner_id`,`created_at`),
  KEY `portal_notifications_created_at_index` (`created_at`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `portal_otp_challenges` (
  `id` char(36) NOT NULL,
  `owner_id` bigint(20) unsigned DEFAULT NULL,
  `phone` varchar(32) NOT NULL,
  `code_hash` varchar(191) NOT NULL,
  `attempts` tinyint(3) unsigned NOT NULL DEFAULT 0,
  `expires_at` timestamp NULL DEFAULT NULL,
  `used_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `portal_otp_challenges_owner_id_foreign` (`owner_id`),
  KEY `portal_otp_challenges_phone_index` (`phone`),
  KEY `portal_otp_challenges_expires_at_index` (`expires_at`),
  CONSTRAINT `portal_otp_challenges_owner_id_foreign` FOREIGN KEY (`owner_id`) REFERENCES `portal_owners` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `portal_owner_devices` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `owner_id` bigint(20) unsigned NOT NULL,
  `device_hash` varchar(64) NOT NULL,
  `platform` varchar(32) DEFAULT NULL,
  `user_agent` varchar(191) DEFAULT NULL,
  `first_seen_at` timestamp NULL DEFAULT NULL,
  `last_seen_at` timestamp NULL DEFAULT NULL,
  `installed_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `portal_owner_devices_owner_id_device_hash_unique` (`owner_id`,`device_hash`),
  KEY `portal_owner_devices_installed_at_index` (`installed_at`),
  CONSTRAINT `portal_owner_devices_owner_id_foreign` FOREIGN KEY (`owner_id`) REFERENCES `portal_owners` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `portal_owner_tokens` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `owner_id` bigint(20) unsigned NOT NULL,
  `token_hash` varchar(64) NOT NULL,
  `user_agent` varchar(191) DEFAULT NULL,
  `ip` varchar(45) DEFAULT NULL,
  `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 `portal_owner_tokens_token_hash_unique` (`token_hash`),
  KEY `portal_owner_tokens_owner_id_foreign` (`owner_id`),
  KEY `portal_owner_tokens_expires_at_index` (`expires_at`),
  CONSTRAINT `portal_owner_tokens_owner_id_foreign` FOREIGN KEY (`owner_id`) REFERENCES `portal_owners` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=51 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `portal_owners` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned NOT NULL,
  `contact_id` int(10) unsigned DEFAULT NULL,
  `name` varchar(191) NOT NULL,
  `phone` varchar(32) DEFAULT NULL,
  `email` varchar(191) DEFAULT NULL,
  `password` varchar(191) DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `last_login_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `portal_owners_phone_unique` (`phone`),
  UNIQUE KEY `portal_owners_email_unique` (`email`),
  KEY `portal_owners_business_id_index` (`business_id`),
  KEY `portal_owners_contact_id_index` (`contact_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `portal_push_sent_log` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `kind` varchar(32) NOT NULL,
  `subject_id` bigint(20) unsigned NOT NULL,
  `bucket` varchar(32) NOT NULL,
  `sent_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `portal_push_sent_log_kind_subject_id_bucket_unique` (`kind`,`subject_id`,`bucket`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `portal_push_subscriptions` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `owner_id` bigint(20) unsigned NOT NULL,
  `endpoint` varchar(500) NOT NULL,
  `p256dh_key` varchar(191) NOT NULL,
  `auth_key` varchar(64) NOT NULL,
  `user_agent` varchar(191) DEFAULT NULL,
  `categories` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`categories`)),
  `last_used_at` timestamp NULL DEFAULT NULL,
  `last_failed_at` timestamp NULL DEFAULT NULL,
  `consecutive_failures` tinyint(3) unsigned NOT NULL DEFAULT 0,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `portal_push_subscriptions_owner_id_endpoint_index` (`owner_id`,`endpoint`),
  CONSTRAINT `portal_push_subscriptions_owner_id_foreign` FOREIGN KEY (`owner_id`) REFERENCES `portal_owners` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `portal_reviews` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned NOT NULL,
  `owner_id` bigint(20) unsigned NOT NULL,
  `appointment_id` bigint(20) unsigned NOT NULL,
  `doctor_id` bigint(20) unsigned DEFAULT NULL,
  `rating` tinyint(4) NOT NULL,
  `comments` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `portal_reviews_appointment_id_owner_id_unique` (`appointment_id`,`owner_id`),
  KEY `portal_reviews_business_id_doctor_id_index` (`business_id`,`doctor_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `portal_telehealth_requests` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned NOT NULL,
  `owner_id` bigint(20) unsigned NOT NULL,
  `pet_id` bigint(20) unsigned NOT NULL,
  `question` text NOT NULL,
  `photo_paths` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`photo_paths`)),
  `status` enum('pending','answered','closed') NOT NULL DEFAULT 'pending',
  `replied_by` bigint(20) unsigned DEFAULT NULL,
  `reply_body` text DEFAULT NULL,
  `replied_at` datetime DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `portal_telehealth_requests_business_id_owner_id_created_at_index` (`business_id`,`owner_id`,`created_at`),
  KEY `portal_telehealth_requests_business_id_status_index` (`business_id`,`status`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `pr_currencies` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned NOT NULL,
  `code` varchar(10) NOT NULL,
  `name` varchar(100) NOT NULL,
  `symbol` varchar(10) NOT NULL,
  `conversion_rate_to_egp` decimal(22,4) NOT NULL DEFAULT 1.0000,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `pr_currencies_business_id_code_unique` (`business_id`,`code`),
  KEY `pr_currencies_business_id_index` (`business_id`),
  CONSTRAINT `pr_currencies_business_id_foreign` FOREIGN KEY (`business_id`) REFERENCES `business` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `pr_products` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned NOT NULL,
  `pr_request_id` bigint(20) unsigned NOT NULL,
  `product_id` int(10) unsigned NOT NULL,
  `variation_id` int(10) unsigned NOT NULL,
  `current_stock` decimal(22,4) NOT NULL DEFAULT 0.0000,
  `required_quantity` decimal(22,4) NOT NULL DEFAULT 0.0000,
  `covered_qty` decimal(22,4) NOT NULL DEFAULT 0.0000,
  `pending_purchase_qty` decimal(22,4) NOT NULL DEFAULT 0.0000,
  `avg_unit_cost` decimal(22,4) NOT NULL DEFAULT 0.0000,
  `last_purchase_price` decimal(22,4) NOT NULL DEFAULT 0.0000,
  `last_purchased_qty` decimal(22,4) NOT NULL DEFAULT 0.0000,
  `last_purchased_adjusted_qty` decimal(22,4) NOT NULL DEFAULT 0.0000,
  `year_ago_sold_qty` decimal(22,4) NOT NULL DEFAULT 0.0000,
  `selling_price` decimal(22,4) NOT NULL DEFAULT 0.0000,
  `notes` text DEFAULT NULL,
  `has_previous_purchase` tinyint(1) NOT NULL DEFAULT 1,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `pr_products_business_id_foreign` (`business_id`),
  KEY `pr_products_product_id_foreign` (`product_id`),
  KEY `pr_products_pr_request_id_product_id_index` (`pr_request_id`,`product_id`),
  KEY `pr_products_variation_id_index` (`variation_id`),
  CONSTRAINT `pr_products_business_id_foreign` FOREIGN KEY (`business_id`) REFERENCES `business` (`id`) ON DELETE CASCADE,
  CONSTRAINT `pr_products_pr_request_id_foreign` FOREIGN KEY (`pr_request_id`) REFERENCES `pr_requests` (`id`) ON DELETE CASCADE,
  CONSTRAINT `pr_products_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE,
  CONSTRAINT `pr_products_variation_id_foreign` FOREIGN KEY (`variation_id`) REFERENCES `variations` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=1709 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `pr_purchase_changes` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `pr_purchase_share_id` int(10) unsigned NOT NULL,
  `purchase_line_id` int(10) unsigned NOT NULL,
  `original_qty` decimal(8,2) NOT NULL,
  `original_price` decimal(15,4) NOT NULL,
  `requested_qty` decimal(8,2) NOT NULL,
  `requested_price` decimal(15,4) NOT NULL,
  `supplier_note` text DEFAULT NULL,
  `status` enum('pending','approved','rejected') NOT NULL DEFAULT 'pending',
  `admin_note` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `pr_purchase_changes_pr_purchase_share_id_foreign` (`pr_purchase_share_id`),
  KEY `pr_purchase_changes_purchase_line_id_foreign` (`purchase_line_id`),
  CONSTRAINT `pr_purchase_changes_pr_purchase_share_id_foreign` FOREIGN KEY (`pr_purchase_share_id`) REFERENCES `pr_purchase_shares` (`id`) ON DELETE CASCADE,
  CONSTRAINT `pr_purchase_changes_purchase_line_id_foreign` FOREIGN KEY (`purchase_line_id`) REFERENCES `purchase_lines` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `pr_purchase_payments` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `pr_purchase_share_id` int(10) unsigned NOT NULL,
  `paid_amount` decimal(15,4) NOT NULL,
  `paid_currency_id` int(10) unsigned DEFAULT NULL,
  `rate_to_egp` decimal(15,6) NOT NULL DEFAULT 1.000000,
  `egp_amount` decimal(15,4) NOT NULL,
  `order_currency_id` int(10) unsigned DEFAULT NULL,
  `rate_to_order_currency` decimal(15,6) NOT NULL DEFAULT 1.000000,
  `order_currency_amount` decimal(15,4) NOT NULL,
  `notes` text DEFAULT NULL,
  `document` varchar(191) DEFAULT NULL,
  `received` tinyint(1) NOT NULL DEFAULT 0,
  `received_note` text DEFAULT NULL,
  `received_at` timestamp NULL DEFAULT NULL,
  `created_by` int(10) unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `pr_purchase_payments_pr_purchase_share_id_foreign` (`pr_purchase_share_id`),
  KEY `pr_purchase_payments_paid_currency_id_foreign` (`paid_currency_id`),
  KEY `pr_purchase_payments_order_currency_id_foreign` (`order_currency_id`),
  CONSTRAINT `pr_purchase_payments_order_currency_id_foreign` FOREIGN KEY (`order_currency_id`) REFERENCES `pr_currencies` (`id`) ON DELETE SET NULL,
  CONSTRAINT `pr_purchase_payments_paid_currency_id_foreign` FOREIGN KEY (`paid_currency_id`) REFERENCES `pr_currencies` (`id`) ON DELETE SET NULL,
  CONSTRAINT `pr_purchase_payments_pr_purchase_share_id_foreign` FOREIGN KEY (`pr_purchase_share_id`) REFERENCES `pr_purchase_shares` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `pr_purchase_shares` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned NOT NULL,
  `transaction_id` int(10) unsigned NOT NULL,
  `pr_request_ids` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`pr_request_ids`)),
  `share_token` varchar(100) NOT NULL,
  `supplier_order_note` text DEFAULT NULL,
  `row_notes` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`row_notes`)),
  `images` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`images`)),
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `pr_purchase_shares_transaction_id_unique` (`transaction_id`),
  UNIQUE KEY `pr_purchase_shares_share_token_unique` (`share_token`),
  CONSTRAINT `pr_purchase_shares_transaction_id_foreign` FOREIGN KEY (`transaction_id`) REFERENCES `transactions` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `pr_requests` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned NOT NULL,
  `ref_no` varchar(191) NOT NULL,
  `transaction_date` datetime NOT NULL,
  `location_id` int(10) unsigned DEFAULT NULL,
  `status` enum('generating','draft','pending_supplier','pending_approval','approved','completed') DEFAULT 'draft',
  `notes` text DEFAULT NULL,
  `created_by` int(10) unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `pr_requests_ref_no_unique` (`ref_no`),
  KEY `pr_requests_location_id_foreign` (`location_id`),
  KEY `pr_requests_created_by_foreign` (`created_by`),
  KEY `pr_requests_business_id_index` (`business_id`),
  KEY `pr_requests_status_index` (`status`),
  KEY `pr_requests_ref_no_index` (`ref_no`),
  CONSTRAINT `pr_requests_business_id_foreign` FOREIGN KEY (`business_id`) REFERENCES `business` (`id`) ON DELETE CASCADE,
  CONSTRAINT `pr_requests_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  CONSTRAINT `pr_requests_location_id_foreign` FOREIGN KEY (`location_id`) REFERENCES `business_locations` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `pr_settings` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned NOT NULL,
  `value` text NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `pr_settings_business_id_index` (`business_id`),
  CONSTRAINT `pr_settings_business_id_foreign` FOREIGN KEY (`business_id`) REFERENCES `business` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `pr_supplier_products` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned NOT NULL,
  `pr_supplier_response_id` bigint(20) unsigned NOT NULL,
  `pr_product_id` bigint(20) unsigned NOT NULL,
  `available_qty` decimal(22,4) NOT NULL DEFAULT 0.0000,
  `order_qty` decimal(22,4) NOT NULL DEFAULT 0.0000,
  `supplier_price` decimal(22,4) NOT NULL DEFAULT 0.0000,
  `converted_price_egp` decimal(22,4) NOT NULL DEFAULT 0.0000,
  `landed_unit_cost` decimal(22,4) NOT NULL DEFAULT 0.0000,
  `landed_unit_cost_egp` decimal(22,4) NOT NULL DEFAULT 0.0000,
  `supplier_notes` text DEFAULT NULL,
  `approved` tinyint(1) NOT NULL DEFAULT 0,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `pr_supplier_products_business_id_foreign` (`business_id`),
  KEY `pr_supplier_products_pr_supplier_response_id_index` (`pr_supplier_response_id`),
  KEY `pr_supplier_products_pr_product_id_index` (`pr_product_id`),
  CONSTRAINT `fk_pr_supplier_response` FOREIGN KEY (`pr_supplier_response_id`) REFERENCES `pr_supplier_responses` (`id`) ON DELETE CASCADE,
  CONSTRAINT `pr_supplier_products_business_id_foreign` FOREIGN KEY (`business_id`) REFERENCES `business` (`id`) ON DELETE CASCADE,
  CONSTRAINT `pr_supplier_products_pr_product_id_foreign` FOREIGN KEY (`pr_product_id`) REFERENCES `pr_products` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=1931 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `pr_supplier_responses` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned NOT NULL,
  `pr_request_id` bigint(20) unsigned NOT NULL,
  `supplier_id` int(10) unsigned NOT NULL,
  `ref_no` varchar(50) DEFAULT NULL,
  `share_token` varchar(100) NOT NULL,
  `status` enum('pending','submitted','approved','rejected') NOT NULL DEFAULT 'pending',
  `currency_id` int(10) unsigned DEFAULT NULL,
  `submitted_at` datetime DEFAULT NULL,
  `approved_at` datetime DEFAULT NULL,
  `approved_by` int(10) unsigned 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 `pr_supplier_responses_share_token_unique` (`share_token`),
  KEY `pr_supplier_responses_business_id_foreign` (`business_id`),
  KEY `pr_supplier_responses_supplier_id_foreign` (`supplier_id`),
  KEY `pr_supplier_responses_approved_by_foreign` (`approved_by`),
  KEY `pr_supplier_responses_share_token_index` (`share_token`),
  KEY `pr_supplier_responses_pr_request_id_supplier_id_index` (`pr_request_id`,`supplier_id`),
  KEY `pr_supplier_responses_status_index` (`status`),
  KEY `pr_supplier_responses_currency_id_foreign` (`currency_id`),
  KEY `pr_supplier_responses_ref_no_index` (`ref_no`),
  CONSTRAINT `pr_supplier_responses_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `pr_supplier_responses_business_id_foreign` FOREIGN KEY (`business_id`) REFERENCES `business` (`id`) ON DELETE CASCADE,
  CONSTRAINT `pr_supplier_responses_currency_id_foreign` FOREIGN KEY (`currency_id`) REFERENCES `pr_currencies` (`id`) ON DELETE SET NULL,
  CONSTRAINT `pr_supplier_responses_pr_request_id_foreign` FOREIGN KEY (`pr_request_id`) REFERENCES `pr_requests` (`id`) ON DELETE CASCADE,
  CONSTRAINT `pr_supplier_responses_supplier_id_foreign` FOREIGN KEY (`supplier_id`) REFERENCES `contacts` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=36 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `pr_user_locations` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned NOT NULL,
  `user_id` int(10) unsigned NOT NULL,
  `type` varchar(191) NOT NULL,
  `location_id` int(10) unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `pr_user_locations_business_id_foreign` (`business_id`),
  KEY `pr_user_locations_location_id_foreign` (`location_id`),
  KEY `pr_user_locations_user_id_business_id_type_index` (`user_id`,`business_id`,`type`),
  CONSTRAINT `pr_user_locations_business_id_foreign` FOREIGN KEY (`business_id`) REFERENCES `business` (`id`) ON DELETE CASCADE,
  CONSTRAINT `pr_user_locations_location_id_foreign` FOREIGN KEY (`location_id`) REFERENCES `business_locations` (`id`) ON DELETE CASCADE,
  CONSTRAINT `pr_user_locations_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `primary_care_patient_profiles` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `clc_patient_id` int(10) unsigned NOT NULL,
  `bmi` decimal(8,2) DEFAULT NULL,
  `chronic_problems` text DEFAULT NULL,
  `screening_due` varchar(120) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `primary_care_patient_profiles_clc_patient_id_unique` (`clc_patient_id`),
  CONSTRAINT `primary_care_patient_profiles_clc_patient_id_foreign` FOREIGN KEY (`clc_patient_id`) REFERENCES `clc_patients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `printers` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned NOT NULL,
  `name` varchar(191) NOT NULL,
  `connection_type` enum('network','windows','linux') NOT NULL,
  `capability_profile` enum('default','simple','SP2000','TEP-200M','P822D') NOT NULL DEFAULT 'default',
  `char_per_line` varchar(191) DEFAULT NULL,
  `ip_address` varchar(191) DEFAULT NULL,
  `port` varchar(191) DEFAULT NULL,
  `path` varchar(191) DEFAULT NULL,
  `created_by` int(10) unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `printers_business_id_foreign` (`business_id`),
  CONSTRAINT `printers_business_id_foreign` FOREIGN KEY (`business_id`) REFERENCES `business` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `product_compatibles` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `product_id` bigint(20) unsigned NOT NULL,
  `compatible_product_id` bigint(20) unsigned NOT NULL,
  `compatible_with` text NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `product_locations` (
  `product_id` int(11) NOT NULL,
  `location_id` int(11) NOT NULL,
  KEY `product_locations_product_id_index` (`product_id`),
  KEY `product_locations_location_id_index` (`location_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `product_parts` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `product_id` bigint(20) unsigned NOT NULL,
  `variation_id` bigint(20) unsigned NOT NULL,
  `part_number` text 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;

CREATE TABLE `product_racks` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned NOT NULL,
  `location_id` int(10) unsigned NOT NULL,
  `product_id` int(10) unsigned NOT NULL,
  `rack` varchar(191) DEFAULT NULL,
  `row` varchar(191) DEFAULT NULL,
  `position` varchar(191) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `product_racks_business_id_index` (`business_id`),
  KEY `product_racks_location_id_index` (`location_id`),
  KEY `product_racks_product_id_index` (`product_id`)
) ENGINE=InnoDB AUTO_INCREMENT=124723 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `product_variations` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `variation_template_id` int(11) DEFAULT NULL,
  `name` varchar(191) NOT NULL,
  `product_id` int(10) unsigned NOT NULL,
  `is_dummy` tinyint(1) NOT NULL DEFAULT 1,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `product_variations_name_index` (`name`),
  KEY `product_variations_product_id_index` (`product_id`),
  CONSTRAINT `product_variations_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=15911 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `product_variations` VALUES (15624,NULL,'DUMMY',15648,1,'2026-06-15 17:18:43','2026-06-15 17:18:43'),(15625,NULL,'DUMMY',15649,1,'2026-06-15 17:18:43','2026-06-15 17:18:43'),(15626,NULL,'DUMMY',15650,1,'2026-06-15 17:18:43','2026-06-15 17:18:43'),(15627,NULL,'DUMMY',15651,1,'2026-06-15 17:18:43','2026-06-15 17:18:43'),(15628,NULL,'DUMMY',15652,1,'2026-06-15 17:18:43','2026-06-15 17:18:43'),(15629,NULL,'DUMMY',15653,1,'2026-06-15 17:18:43','2026-06-15 17:18:43'),(15630,NULL,'DUMMY',15654,1,'2026-06-15 17:18:43','2026-06-15 17:18:43'),(15631,NULL,'DUMMY',15655,1,'2026-06-15 17:18:43','2026-06-15 17:18:43'),(15632,NULL,'DUMMY',15656,1,'2026-06-15 17:18:43','2026-06-15 17:18:43'),(15633,NULL,'DUMMY',15657,1,'2026-06-15 17:18:43','2026-06-15 17:18:43'),(15634,NULL,'DUMMY',15658,1,'2026-06-15 17:18:43','2026-06-15 17:18:43'),(15635,NULL,'DUMMY',15659,1,'2026-06-15 17:18:43','2026-06-15 17:18:43'),(15636,NULL,'DUMMY',15660,1,'2026-06-15 17:18:43','2026-06-15 17:18:43'),(15637,NULL,'DUMMY',15661,1,'2026-06-15 17:18:43','2026-06-15 17:18:43'),(15638,NULL,'DUMMY',15662,1,'2026-06-15 17:18:43','2026-06-15 17:18:43'),(15639,NULL,'DUMMY',15663,1,'2026-06-15 17:18:43','2026-06-15 17:18:43'),(15640,NULL,'DUMMY',15664,1,'2026-06-15 17:18:43','2026-06-15 17:18:43'),(15641,NULL,'DUMMY',15665,1,'2026-06-15 17:18:43','2026-06-15 17:18:43'),(15642,NULL,'DUMMY',15666,1,'2026-06-15 17:18:43','2026-06-15 17:18:43'),(15643,NULL,'DUMMY',15667,1,'2026-06-15 17:18:43','2026-06-15 17:18:43'),(15644,NULL,'DUMMY',15668,1,'2026-06-15 17:18:43','2026-06-15 17:18:43'),(15645,NULL,'DUMMY',15669,1,'2026-06-15 17:18:43','2026-06-15 17:18:43'),(15646,NULL,'DUMMY',15670,1,'2026-06-17 20:54:55','2026-06-17 20:54:55'),(15647,NULL,'DUMMY',15671,1,'2026-06-17 20:54:55','2026-06-17 20:54:55'),(15648,NULL,'DUMMY',15672,1,'2026-06-17 20:54:55','2026-06-17 20:54:55'),(15649,NULL,'DUMMY',15673,1,'2026-06-17 20:54:55','2026-06-17 20:54:55'),(15650,NULL,'DUMMY',15674,1,'2026-06-17 20:54:55','2026-06-17 20:54:55'),(15651,NULL,'DUMMY',15675,1,'2026-06-17 20:54:55','2026-06-17 20:54:55'),(15652,NULL,'DUMMY',15676,1,'2026-06-17 20:54:55','2026-06-17 20:54:55'),(15653,NULL,'DUMMY',15677,1,'2026-06-17 20:54:55','2026-06-17 20:54:55'),(15654,NULL,'DUMMY',15678,1,'2026-06-17 20:54:55','2026-06-17 20:54:55'),(15655,NULL,'DUMMY',15679,1,'2026-06-17 20:54:55','2026-06-17 20:54:55'),(15656,NULL,'DUMMY',15680,1,'2026-06-17 20:54:55','2026-06-17 20:54:55'),(15657,NULL,'DUMMY',15681,1,'2026-06-17 20:54:55','2026-06-17 20:54:55'),(15658,NULL,'DUMMY',15682,1,'2026-06-17 20:54:55','2026-06-17 20:54:55'),(15659,NULL,'DUMMY',15683,1,'2026-06-17 20:54:55','2026-06-17 20:54:55'),(15660,NULL,'DUMMY',15684,1,'2026-06-17 20:54:55','2026-06-17 20:54:55'),(15661,NULL,'DUMMY',15685,1,'2026-06-17 20:54:55','2026-06-17 20:54:55'),(15662,NULL,'DUMMY',15686,1,'2026-06-17 20:54:55','2026-06-17 20:54:55'),(15663,NULL,'DUMMY',15687,1,'2026-06-17 20:54:55','2026-06-17 20:54:55'),(15664,NULL,'DUMMY',15688,1,'2026-06-17 20:54:55','2026-06-17 20:54:55'),(15665,NULL,'DUMMY',15689,1,'2026-06-17 20:54:55','2026-06-17 20:54:55'),(15666,NULL,'DUMMY',15690,1,'2026-06-17 20:54:55','2026-06-17 20:54:55'),(15667,NULL,'DUMMY',15691,1,'2026-06-17 20:54:55','2026-06-17 20:54:55'),(15668,NULL,'DUMMY',15692,1,'2026-06-17 20:54:55','2026-06-17 20:54:55'),(15669,NULL,'DUMMY',15693,1,'2026-06-17 20:54:55','2026-06-17 20:54:55'),(15670,NULL,'DUMMY',15694,1,'2026-06-17 20:54:55','2026-06-17 20:54:55'),(15671,NULL,'DUMMY',15695,1,'2026-06-17 20:54:55','2026-06-17 20:54:55'),(15672,NULL,'DUMMY',15696,1,'2026-06-17 20:54:55','2026-06-17 20:54:55'),(15673,NULL,'DUMMY',15697,1,'2026-06-17 20:54:55','2026-06-17 20:54:55'),(15674,NULL,'DUMMY',15698,1,'2026-06-17 20:54:55','2026-06-17 20:54:55'),(15675,NULL,'DUMMY',15699,1,'2026-06-17 20:54:55','2026-06-17 20:54:55'),(15676,NULL,'DUMMY',15700,1,'2026-06-17 20:54:55','2026-06-17 20:54:55'),(15677,NULL,'DUMMY',15701,1,'2026-06-17 20:54:55','2026-06-17 20:54:55'),(15678,NULL,'DUMMY',15702,1,'2026-06-17 20:54:55','2026-06-17 20:54:55'),(15679,NULL,'DUMMY',15703,1,'2026-06-17 20:54:55','2026-06-17 20:54:55'),(15680,NULL,'DUMMY',15704,1,'2026-06-17 20:54:55','2026-06-17 20:54:55'),(15681,NULL,'DUMMY',15705,1,'2026-06-17 20:54:55','2026-06-17 20:54:55'),(15682,NULL,'DUMMY',15706,1,'2026-06-17 20:54:55','2026-06-17 20:54:55'),(15683,NULL,'DUMMY',15707,1,'2026-06-17 20:54:55','2026-06-17 20:54:55'),(15684,NULL,'DUMMY',15708,1,'2026-06-17 20:54:56','2026-06-17 20:54:56'),(15685,NULL,'DUMMY',15709,1,'2026-06-17 20:54:56','2026-06-17 20:54:56'),(15686,NULL,'DUMMY',15710,1,'2026-06-17 20:54:56','2026-06-17 20:54:56'),(15687,NULL,'DUMMY',15711,1,'2026-06-17 20:54:56','2026-06-17 20:54:56'),(15688,NULL,'DUMMY',15712,1,'2026-06-17 20:54:56','2026-06-17 20:54:56'),(15689,NULL,'DUMMY',15713,1,'2026-06-17 20:54:56','2026-06-17 20:54:56'),(15690,NULL,'DUMMY',15714,1,'2026-06-17 20:54:56','2026-06-17 20:54:56'),(15691,NULL,'DUMMY',15715,1,'2026-06-17 20:54:56','2026-06-17 20:54:56'),(15692,NULL,'DUMMY',15716,1,'2026-06-17 20:54:56','2026-06-17 20:54:56'),(15693,NULL,'DUMMY',15717,1,'2026-06-17 20:54:56','2026-06-17 20:54:56'),(15694,NULL,'DUMMY',15718,1,'2026-06-17 20:54:56','2026-06-17 20:54:56'),(15695,NULL,'DUMMY',15719,1,'2026-06-17 20:54:56','2026-06-17 20:54:56'),(15696,NULL,'DUMMY',15720,1,'2026-06-17 20:54:56','2026-06-17 20:54:56'),(15697,NULL,'DUMMY',15721,1,'2026-06-17 20:54:56','2026-06-17 20:54:56'),(15698,NULL,'DUMMY',15722,1,'2026-06-17 20:54:56','2026-06-17 20:54:56'),(15699,NULL,'DUMMY',15723,1,'2026-06-17 20:55:44','2026-06-17 20:55:44'),(15700,NULL,'DUMMY',15724,1,'2026-06-17 20:55:44','2026-06-17 20:55:44'),(15701,NULL,'DUMMY',15725,1,'2026-06-17 20:55:44','2026-06-17 20:55:44'),(15702,NULL,'DUMMY',15726,1,'2026-06-17 20:55:44','2026-06-17 20:55:44'),(15703,NULL,'DUMMY',15727,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15704,NULL,'DUMMY',15728,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15705,NULL,'DUMMY',15729,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15706,NULL,'DUMMY',15730,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15707,NULL,'DUMMY',15731,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15708,NULL,'DUMMY',15732,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15709,NULL,'DUMMY',15733,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15710,NULL,'DUMMY',15734,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15711,NULL,'DUMMY',15735,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15712,NULL,'DUMMY',15736,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15713,NULL,'DUMMY',15737,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15714,NULL,'DUMMY',15738,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15715,NULL,'DUMMY',15739,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15716,NULL,'DUMMY',15740,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15717,NULL,'DUMMY',15741,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15718,NULL,'DUMMY',15742,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15719,NULL,'DUMMY',15743,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15720,NULL,'DUMMY',15744,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15721,NULL,'DUMMY',15745,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15722,NULL,'DUMMY',15746,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15723,NULL,'DUMMY',15747,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15724,NULL,'DUMMY',15748,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15725,NULL,'DUMMY',15749,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15726,NULL,'DUMMY',15750,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15727,NULL,'DUMMY',15751,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15728,NULL,'DUMMY',15752,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15729,NULL,'DUMMY',15753,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15730,NULL,'DUMMY',15754,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15731,NULL,'DUMMY',15755,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15732,NULL,'DUMMY',15756,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15733,NULL,'DUMMY',15757,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15734,NULL,'DUMMY',15758,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15735,NULL,'DUMMY',15759,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15736,NULL,'DUMMY',15760,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15737,NULL,'DUMMY',15761,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15738,NULL,'DUMMY',15762,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15739,NULL,'DUMMY',15763,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15740,NULL,'DUMMY',15764,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15741,NULL,'DUMMY',15765,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15742,NULL,'DUMMY',15766,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15743,NULL,'DUMMY',15767,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15744,NULL,'DUMMY',15768,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15745,NULL,'DUMMY',15769,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15746,NULL,'DUMMY',15770,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15747,NULL,'DUMMY',15771,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15748,NULL,'DUMMY',15772,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15749,NULL,'DUMMY',15773,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15750,NULL,'DUMMY',15774,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15751,NULL,'DUMMY',15775,1,'2026-06-17 20:55:45','2026-06-17 20:55:45'),(15752,NULL,'DUMMY',15776,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15753,NULL,'DUMMY',15777,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15754,NULL,'DUMMY',15778,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15755,NULL,'DUMMY',15779,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15756,NULL,'DUMMY',15780,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15757,NULL,'DUMMY',15781,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15758,NULL,'DUMMY',15782,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15759,NULL,'DUMMY',15783,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15760,NULL,'DUMMY',15784,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15761,NULL,'DUMMY',15785,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15762,NULL,'DUMMY',15786,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15763,NULL,'DUMMY',15787,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15764,NULL,'DUMMY',15788,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15765,NULL,'DUMMY',15789,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15766,NULL,'DUMMY',15790,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15767,NULL,'DUMMY',15791,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15768,NULL,'DUMMY',15792,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15769,NULL,'DUMMY',15793,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15770,NULL,'DUMMY',15794,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15771,NULL,'DUMMY',15795,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15772,NULL,'DUMMY',15796,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15773,NULL,'DUMMY',15797,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15774,NULL,'DUMMY',15798,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15775,NULL,'DUMMY',15799,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15776,NULL,'DUMMY',15800,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15777,NULL,'DUMMY',15801,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15778,NULL,'DUMMY',15802,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15779,NULL,'DUMMY',15803,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15780,NULL,'DUMMY',15804,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15781,NULL,'DUMMY',15805,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15782,NULL,'DUMMY',15806,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15783,NULL,'DUMMY',15807,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15784,NULL,'DUMMY',15808,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15785,NULL,'DUMMY',15809,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15786,NULL,'DUMMY',15810,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15787,NULL,'DUMMY',15811,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15788,NULL,'DUMMY',15812,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15789,NULL,'DUMMY',15813,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15790,NULL,'DUMMY',15814,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15791,NULL,'DUMMY',15815,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15792,NULL,'DUMMY',15816,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15793,NULL,'DUMMY',15817,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15794,NULL,'DUMMY',15818,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15795,NULL,'DUMMY',15819,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15796,NULL,'DUMMY',15820,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15797,NULL,'DUMMY',15821,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15798,NULL,'DUMMY',15822,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15799,NULL,'DUMMY',15823,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15800,NULL,'DUMMY',15824,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15801,NULL,'DUMMY',15825,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15802,NULL,'DUMMY',15826,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15803,NULL,'DUMMY',15827,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15804,NULL,'DUMMY',15828,1,'2026-06-17 20:58:11','2026-06-17 20:58:11'),(15805,NULL,'DUMMY',15829,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15806,NULL,'DUMMY',15830,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15807,NULL,'DUMMY',15831,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15808,NULL,'DUMMY',15832,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15809,NULL,'DUMMY',15833,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15810,NULL,'DUMMY',15834,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15811,NULL,'DUMMY',15835,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15812,NULL,'DUMMY',15836,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15813,NULL,'DUMMY',15837,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15814,NULL,'DUMMY',15838,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15815,NULL,'DUMMY',15839,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15816,NULL,'DUMMY',15840,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15817,NULL,'DUMMY',15841,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15818,NULL,'DUMMY',15842,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15819,NULL,'DUMMY',15843,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15820,NULL,'DUMMY',15844,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15821,NULL,'DUMMY',15845,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15822,NULL,'DUMMY',15846,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15823,NULL,'DUMMY',15847,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15824,NULL,'DUMMY',15848,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15825,NULL,'DUMMY',15849,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15826,NULL,'DUMMY',15850,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15827,NULL,'DUMMY',15851,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15828,NULL,'DUMMY',15852,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15829,NULL,'DUMMY',15853,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15830,NULL,'DUMMY',15854,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15831,NULL,'DUMMY',15855,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15832,NULL,'DUMMY',15856,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15833,NULL,'DUMMY',15857,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15834,NULL,'DUMMY',15858,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15835,NULL,'DUMMY',15859,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15836,NULL,'DUMMY',15860,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15837,NULL,'DUMMY',15861,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15838,NULL,'DUMMY',15862,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15839,NULL,'DUMMY',15863,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15840,NULL,'DUMMY',15864,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15841,NULL,'DUMMY',15865,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15842,NULL,'DUMMY',15866,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15843,NULL,'DUMMY',15867,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15844,NULL,'DUMMY',15868,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15845,NULL,'DUMMY',15869,1,'2026-06-17 21:00:02','2026-06-17 21:00:02'),(15846,NULL,'DUMMY',15870,1,'2026-06-17 21:00:03','2026-06-17 21:00:03'),(15847,NULL,'DUMMY',15871,1,'2026-06-17 21:00:03','2026-06-17 21:00:03'),(15848,NULL,'DUMMY',15872,1,'2026-06-17 21:00:03','2026-06-17 21:00:03'),(15849,NULL,'DUMMY',15873,1,'2026-06-17 21:00:03','2026-06-17 21:00:03'),(15850,NULL,'DUMMY',15874,1,'2026-06-17 21:00:03','2026-06-17 21:00:03'),(15851,NULL,'DUMMY',15875,1,'2026-06-17 21:00:03','2026-06-17 21:00:03'),(15852,NULL,'DUMMY',15876,1,'2026-06-17 21:00:03','2026-06-17 21:00:03'),(15853,NULL,'DUMMY',15877,1,'2026-06-17 21:00:03','2026-06-17 21:00:03'),(15854,NULL,'DUMMY',15878,1,'2026-06-17 21:00:03','2026-06-17 21:00:03'),(15855,NULL,'DUMMY',15879,1,'2026-06-17 21:00:03','2026-06-17 21:00:03'),(15856,NULL,'DUMMY',15880,1,'2026-06-17 21:00:03','2026-06-17 21:00:03'),(15857,NULL,'DUMMY',15881,1,'2026-06-17 21:00:03','2026-06-17 21:00:03'),(15858,NULL,'DUMMY',15882,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15859,NULL,'DUMMY',15883,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15860,NULL,'DUMMY',15884,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15861,NULL,'DUMMY',15885,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15862,NULL,'DUMMY',15886,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15863,NULL,'DUMMY',15887,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15864,NULL,'DUMMY',15888,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15865,NULL,'DUMMY',15889,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15866,NULL,'DUMMY',15890,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15867,NULL,'DUMMY',15891,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15868,NULL,'DUMMY',15892,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15869,NULL,'DUMMY',15893,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15870,NULL,'DUMMY',15894,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15871,NULL,'DUMMY',15895,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15872,NULL,'DUMMY',15896,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15873,NULL,'DUMMY',15897,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15874,NULL,'DUMMY',15898,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15875,NULL,'DUMMY',15899,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15876,NULL,'DUMMY',15900,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15877,NULL,'DUMMY',15901,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15878,NULL,'DUMMY',15902,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15879,NULL,'DUMMY',15903,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15880,NULL,'DUMMY',15904,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15881,NULL,'DUMMY',15905,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15882,NULL,'DUMMY',15906,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15883,NULL,'DUMMY',15907,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15884,NULL,'DUMMY',15908,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15885,NULL,'DUMMY',15909,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15886,NULL,'DUMMY',15910,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15887,NULL,'DUMMY',15911,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15888,NULL,'DUMMY',15912,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15889,NULL,'DUMMY',15913,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15890,NULL,'DUMMY',15914,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15891,NULL,'DUMMY',15915,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15892,NULL,'DUMMY',15916,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15893,NULL,'DUMMY',15917,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15894,NULL,'DUMMY',15918,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15895,NULL,'DUMMY',15919,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15896,NULL,'DUMMY',15920,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15897,NULL,'DUMMY',15921,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15898,NULL,'DUMMY',15922,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15899,NULL,'DUMMY',15923,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15900,NULL,'DUMMY',15924,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15901,NULL,'DUMMY',15925,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15902,NULL,'DUMMY',15926,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15903,NULL,'DUMMY',15927,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15904,NULL,'DUMMY',15928,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15905,NULL,'DUMMY',15929,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15906,NULL,'DUMMY',15930,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15907,NULL,'DUMMY',15931,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15908,NULL,'DUMMY',15932,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15909,NULL,'DUMMY',15933,1,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15910,NULL,'DUMMY',15934,1,'2026-06-17 21:11:54','2026-06-17 21:11:54');
CREATE TABLE `products` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(191) NOT NULL,
  `business_id` int(10) unsigned NOT NULL,
  `type` enum('single','variable','modifier','combo') DEFAULT NULL,
  `unit_id` int(11) unsigned DEFAULT NULL,
  `secondary_unit_id` int(11) DEFAULT NULL,
  `sub_unit_ids` text DEFAULT NULL,
  `brand_id` int(10) unsigned DEFAULT NULL,
  `category_id` int(10) unsigned DEFAULT NULL,
  `sub_category_id` int(10) unsigned DEFAULT NULL,
  `tax` int(10) unsigned DEFAULT NULL,
  `tax_type` enum('inclusive','exclusive') NOT NULL,
  `enable_stock` tinyint(1) NOT NULL DEFAULT 0,
  `alert_quantity` decimal(22,4) DEFAULT NULL,
  `sku` varchar(191) NOT NULL,
  `barcode_type` enum('C39','C128','EAN13','EAN8','UPCA','UPCE') DEFAULT 'C128',
  `expiry_period` decimal(4,2) DEFAULT NULL,
  `expiry_period_type` enum('days','months') DEFAULT NULL,
  `enable_sr_no` tinyint(1) NOT NULL DEFAULT 0,
  `weight` varchar(191) DEFAULT NULL,
  `product_custom_field1` varchar(191) DEFAULT NULL,
  `product_custom_field2` varchar(191) DEFAULT NULL,
  `product_custom_field3` longtext DEFAULT NULL,
  `product_custom_field4` varchar(191) DEFAULT NULL,
  `product_custom_field5` varchar(191) DEFAULT NULL,
  `product_custom_field6` varchar(191) DEFAULT NULL,
  `product_custom_field7` varchar(191) DEFAULT NULL,
  `product_custom_field8` varchar(191) DEFAULT NULL,
  `product_custom_field9` varchar(191) DEFAULT NULL,
  `product_custom_field10` varchar(191) DEFAULT NULL,
  `product_custom_field11` varchar(191) DEFAULT NULL,
  `product_custom_field12` varchar(191) DEFAULT NULL,
  `product_custom_field13` varchar(191) DEFAULT NULL,
  `product_custom_field14` varchar(191) DEFAULT NULL,
  `product_custom_field15` varchar(191) DEFAULT NULL,
  `product_custom_field16` varchar(191) DEFAULT NULL,
  `product_custom_field17` varchar(191) DEFAULT NULL,
  `product_custom_field18` varchar(191) DEFAULT NULL,
  `product_custom_field19` varchar(191) DEFAULT NULL,
  `product_custom_field20` varchar(191) DEFAULT NULL,
  `image` varchar(191) DEFAULT NULL,
  `product_description` text DEFAULT NULL,
  `created_by` int(10) unsigned NOT NULL,
  `preparation_time_in_minutes` int(11) DEFAULT NULL,
  `warranty_id` int(11) DEFAULT NULL,
  `is_inactive` tinyint(1) NOT NULL DEFAULT 0,
  `not_for_selling` tinyint(1) NOT NULL DEFAULT 0,
  `bms_is_asset` tinyint(1) NOT NULL DEFAULT 0,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `products_brand_id_foreign` (`brand_id`),
  KEY `products_category_id_foreign` (`category_id`),
  KEY `products_sub_category_id_foreign` (`sub_category_id`),
  KEY `products_tax_foreign` (`tax`),
  KEY `products_name_index` (`name`),
  KEY `products_business_id_index` (`business_id`),
  KEY `products_unit_id_index` (`unit_id`),
  KEY `products_created_by_index` (`created_by`),
  KEY `products_warranty_id_index` (`warranty_id`),
  KEY `products_type_index` (`type`),
  KEY `products_tax_type_index` (`tax_type`),
  KEY `products_barcode_type_index` (`barcode_type`),
  KEY `products_secondary_unit_id_index` (`secondary_unit_id`),
  CONSTRAINT `products_brand_id_foreign` FOREIGN KEY (`brand_id`) REFERENCES `brands` (`id`) ON DELETE CASCADE,
  CONSTRAINT `products_business_id_foreign` FOREIGN KEY (`business_id`) REFERENCES `business` (`id`) ON DELETE CASCADE,
  CONSTRAINT `products_category_id_foreign` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`) ON DELETE CASCADE,
  CONSTRAINT `products_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  CONSTRAINT `products_sub_category_id_foreign` FOREIGN KEY (`sub_category_id`) REFERENCES `categories` (`id`) ON DELETE CASCADE,
  CONSTRAINT `products_tax_foreign` FOREIGN KEY (`tax`) REFERENCES `tax_rates` (`id`),
  CONSTRAINT `products_unit_id_foreign` FOREIGN KEY (`unit_id`) REFERENCES `units` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=15935 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `products` VALUES (15882,'Rabies Vaccine (1 dose)',10,'single',10,NULL,NULL,NULL,204,NULL,NULL,'exclusive',1,10.0000,'VET8BC533CA','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-vaccines.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15883,'DHPPi Vaccine (1 dose)',10,'single',10,NULL,NULL,NULL,204,NULL,NULL,'exclusive',1,10.0000,'VETF39BC5FE','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-vaccines.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15884,'Tricat Feline Vaccine',10,'single',10,NULL,NULL,NULL,204,NULL,NULL,'exclusive',1,10.0000,'VET5AB5DE58','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-vaccines.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15885,'Leptospirosis Vaccine',10,'single',10,NULL,NULL,NULL,204,NULL,NULL,'exclusive',1,10.0000,'VETD692F911','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-vaccines.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15886,'Kennel Cough (Bordetella)',10,'single',10,NULL,NULL,NULL,204,NULL,NULL,'exclusive',1,10.0000,'VET74258769','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-vaccines.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15887,'Amoxicillin 250mg (10 tabs)',10,'single',10,NULL,NULL,NULL,205,NULL,NULL,'exclusive',1,10.0000,'VET45BD7DC5','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-pharmacy.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15888,'Meloxicam Oral Susp 15ml',10,'single',10,NULL,NULL,NULL,205,NULL,NULL,'exclusive',1,10.0000,'VET8B41449E','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-pharmacy.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15889,'Flea & Tick Spot-On',10,'single',10,NULL,NULL,NULL,205,NULL,NULL,'exclusive',1,10.0000,'VET92F6564F','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-pharmacy.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15890,'Metronidazole 200mg (20 tabs)',10,'single',10,NULL,NULL,NULL,205,NULL,NULL,'exclusive',1,10.0000,'VET8A1D7B77','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-pharmacy.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15891,'Enrofloxacin 50mg (10 tabs)',10,'single',10,NULL,NULL,NULL,205,NULL,NULL,'exclusive',1,10.0000,'VETD6828C83','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-pharmacy.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15892,'Otic Ear Drops 10ml',10,'single',10,NULL,NULL,NULL,205,NULL,NULL,'exclusive',1,10.0000,'VET39C1EFB7','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-pharmacy.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15893,'Premium Dog Food 10kg',10,'single',10,NULL,NULL,NULL,206,NULL,NULL,'exclusive',1,10.0000,'VET1B4A1A43','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-pet-food-retail.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15894,'Premium Cat Food 5kg',10,'single',10,NULL,NULL,NULL,206,NULL,NULL,'exclusive',1,10.0000,'VET47C2027A','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-pet-food-retail.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15895,'Hypoallergenic Diet 2kg',10,'single',10,NULL,NULL,NULL,206,NULL,NULL,'exclusive',1,10.0000,'VET47377A68','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-pet-food-retail.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15896,'Dental Chews (Pack)',10,'single',10,NULL,NULL,NULL,206,NULL,NULL,'exclusive',1,10.0000,'VETD2DCACAA','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-pet-food-retail.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15897,'Surgical Gloves (Box 100)',10,'single',10,NULL,NULL,NULL,207,NULL,NULL,'exclusive',1,10.0000,'VETDD0E52A4','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-surgical-supplies.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15898,'IV Catheter 22G (each)',10,'single',10,NULL,NULL,NULL,207,NULL,NULL,'exclusive',1,10.0000,'VETDBB492E8','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-surgical-supplies.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15899,'Suture Kit (sterile)',10,'single',10,NULL,NULL,NULL,207,NULL,NULL,'exclusive',1,10.0000,'VET946CC775','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-surgical-supplies.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15900,'Surgical Drape (sterile)',10,'single',10,NULL,NULL,NULL,207,NULL,NULL,'exclusive',1,10.0000,'VET6203C2D6','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-surgical-supplies.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15901,'Ketamine 50mg/ml (10ml)',10,'single',10,NULL,NULL,NULL,212,NULL,NULL,'exclusive',1,10.0000,'VET06FC0DA1','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-controlled-drugs.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15902,'Diazepam 5mg/ml (2ml)',10,'single',10,NULL,NULL,NULL,212,NULL,NULL,'exclusive',1,10.0000,'VET65482AF5','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-controlled-drugs.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15903,'Tramadol 50mg (10 caps)',10,'single',10,NULL,NULL,NULL,212,NULL,NULL,'exclusive',1,10.0000,'VET835A9AC5','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-controlled-drugs.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15904,'Phenobarbital 30mg (30 tabs)',10,'single',10,NULL,NULL,NULL,212,NULL,NULL,'exclusive',1,10.0000,'VET66642B87','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-controlled-drugs.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15905,'Buprenorphine 0.3mg/ml (1ml)',10,'single',10,NULL,NULL,NULL,212,NULL,NULL,'exclusive',1,10.0000,'VET0B6753EA','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-controlled-drugs.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15906,'Premium Pet Meal',10,'single',10,NULL,NULL,NULL,208,NULL,NULL,'exclusive',0,0.0000,'VETCD6BB515','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-boarding.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15907,'Kennel Cleaning',10,'single',10,NULL,NULL,NULL,208,NULL,NULL,'exclusive',0,0.0000,'VETB6CAEEF8','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-boarding.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15908,'Daily Walk & Play',10,'single',10,NULL,NULL,NULL,208,NULL,NULL,'exclusive',0,0.0000,'VETCA39442D','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-boarding.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15909,'Boarding Day Package',10,'combo',10,NULL,NULL,NULL,208,NULL,NULL,'exclusive',0,0.0000,'VETBE58BDE0','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-boarding.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15910,'General Consultation',10,'single',10,NULL,NULL,NULL,209,NULL,NULL,'exclusive',0,0.0000,'VET9D0FE95F','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-clinical-services.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15911,'Vaccination Visit',10,'single',10,NULL,NULL,NULL,209,NULL,NULL,'exclusive',0,0.0000,'VET5E782BF0','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-clinical-services.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15912,'Spay / Neuter Surgery',10,'single',10,NULL,NULL,NULL,209,NULL,NULL,'exclusive',0,0.0000,'VET60DAC899','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-clinical-services.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15913,'Dental Cleaning',10,'single',10,NULL,NULL,NULL,209,NULL,NULL,'exclusive',0,0.0000,'VET25D275FD','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-clinical-services.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15914,'Grooming Session',10,'single',10,NULL,NULL,NULL,209,NULL,NULL,'exclusive',0,0.0000,'VET4A345959','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-clinical-services.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15915,'Boarding (per night)',10,'single',10,NULL,NULL,NULL,209,NULL,NULL,'exclusive',0,0.0000,'VET69D1DCEF','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-clinical-services.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15916,'Emergency Triage',10,'single',10,NULL,NULL,NULL,209,NULL,NULL,'exclusive',0,0.0000,'VET433850FF','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-clinical-services.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15917,'Microchipping',10,'single',10,NULL,NULL,NULL,209,NULL,NULL,'exclusive',0,0.0000,'VETC9CCB615','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-clinical-services.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15918,'Wound Dressing & Bandage',10,'single',10,NULL,NULL,NULL,209,NULL,NULL,'exclusive',0,0.0000,'VET4067AE5A','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-clinical-services.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15919,'Euthanasia & Aftercare',10,'single',10,NULL,NULL,NULL,209,NULL,NULL,'exclusive',0,0.0000,'VET407AF314','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-clinical-services.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15920,'X-Ray / Imaging (per view)',10,'single',10,NULL,NULL,NULL,210,NULL,NULL,'exclusive',0,0.0000,'VET1B148473','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-diagnostic-exams.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15921,'Abdominal Ultrasound',10,'single',10,NULL,NULL,NULL,210,NULL,NULL,'exclusive',0,0.0000,'VET678AEC1C','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-diagnostic-exams.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15922,'Cardiac Ultrasound (Echo)',10,'single',10,NULL,NULL,NULL,210,NULL,NULL,'exclusive',0,0.0000,'VET73DC201A','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-diagnostic-exams.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15923,'ECG / Electrocardiogram',10,'single',10,NULL,NULL,NULL,210,NULL,NULL,'exclusive',0,0.0000,'VETC6E96597','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-diagnostic-exams.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15924,'Ophthalmic Exam',10,'single',10,NULL,NULL,NULL,210,NULL,NULL,'exclusive',0,0.0000,'VETE7D78663','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-diagnostic-exams.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15925,'Dermatology Exam',10,'single',10,NULL,NULL,NULL,210,NULL,NULL,'exclusive',0,0.0000,'VET058C22D3','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-diagnostic-exams.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15926,'Endoscopy',10,'single',10,NULL,NULL,NULL,210,NULL,NULL,'exclusive',0,0.0000,'VETF2A3686D','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-diagnostic-exams.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15927,'CBC / Hematology Panel',10,'single',10,NULL,NULL,NULL,211,NULL,NULL,'exclusive',0,0.0000,'VETF7B7FA9C','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-laboratory-tests.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15928,'Biochemistry Panel',10,'single',10,NULL,NULL,NULL,211,NULL,NULL,'exclusive',0,0.0000,'VETBB061D94','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-laboratory-tests.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15929,'Urinalysis',10,'single',10,NULL,NULL,NULL,211,NULL,NULL,'exclusive',0,0.0000,'VET2B915559','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-laboratory-tests.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15930,'SDMA Renal Test',10,'single',10,NULL,NULL,NULL,211,NULL,NULL,'exclusive',0,0.0000,'VET1D39AD77','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-laboratory-tests.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15931,'Thyroid (T4) Test',10,'single',10,NULL,NULL,NULL,211,NULL,NULL,'exclusive',0,0.0000,'VETC2739A54','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-laboratory-tests.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15932,'Fecal Float / Parasitology',10,'single',10,NULL,NULL,NULL,211,NULL,NULL,'exclusive',0,0.0000,'VET5AFE50C6','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-laboratory-tests.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15933,'Cytology',10,'single',10,NULL,NULL,NULL,211,NULL,NULL,'exclusive',0,0.0000,'VETBBE3DD74','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-laboratory-tests.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54'),(15934,'Blood Smear',10,'single',10,NULL,NULL,NULL,211,NULL,NULL,'exclusive',0,0.0000,'VETAFE82EC9','C128',NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'vet-laboratory-tests.png',NULL,195,NULL,NULL,0,0,0,'2026-06-17 21:11:54','2026-06-17 21:11:54');
CREATE TABLE `psychiatry_patient_profiles` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `clc_patient_id` int(10) unsigned NOT NULL,
  `mood` varchar(40) DEFAULT NULL,
  `risk_level` varchar(40) DEFAULT NULL,
  `diagnosis` varchar(120) DEFAULT NULL,
  `notes` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `psychiatry_patient_profiles_clc_patient_id_unique` (`clc_patient_id`),
  CONSTRAINT `psychiatry_patient_profiles_clc_patient_id_foreign` FOREIGN KEY (`clc_patient_id`) REFERENCES `clc_patients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `pulmonology_patient_profiles` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `clc_patient_id` int(10) unsigned NOT NULL,
  `fev1` decimal(8,2) DEFAULT NULL,
  `fvc` decimal(8,2) DEFAULT NULL,
  `spo2` int(11) DEFAULT NULL,
  `mmrc` varchar(40) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `pulmonology_patient_profiles_clc_patient_id_unique` (`clc_patient_id`),
  CONSTRAINT `pulmonology_patient_profiles_clc_patient_id_foreign` FOREIGN KEY (`clc_patient_id`) REFERENCES `clc_patients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `purchase_lines` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `transaction_id` int(10) unsigned NOT NULL,
  `product_id` int(10) unsigned NOT NULL,
  `variation_id` int(10) unsigned NOT NULL,
  `quantity` decimal(22,4) NOT NULL DEFAULT 0.0000,
  `secondary_unit_quantity` decimal(22,4) NOT NULL DEFAULT 0.0000,
  `pp_without_discount` decimal(22,4) NOT NULL DEFAULT 0.0000 COMMENT 'Purchase price before inline discounts',
  `discount_percent` decimal(5,2) NOT NULL DEFAULT 0.00 COMMENT 'Inline discount percentage',
  `purchase_price` decimal(22,4) NOT NULL,
  `purchase_price_inc_tax` decimal(22,4) NOT NULL DEFAULT 0.0000,
  `item_tax` decimal(22,4) NOT NULL COMMENT 'Tax for one quantity',
  `tax_id` int(10) unsigned DEFAULT NULL,
  `purchase_requisition_line_id` int(11) DEFAULT NULL,
  `purchase_order_line_id` int(11) DEFAULT NULL,
  `quantity_sold` decimal(22,4) NOT NULL DEFAULT 0.0000 COMMENT 'Quanity sold from this purchase line',
  `quantity_adjusted` decimal(22,4) NOT NULL DEFAULT 0.0000 COMMENT 'Quanity adjusted in stock adjustment from this purchase line',
  `quantity_returned` decimal(22,4) NOT NULL DEFAULT 0.0000,
  `po_quantity_purchased` decimal(22,4) NOT NULL DEFAULT 0.0000,
  `mfg_quantity_used` decimal(22,4) NOT NULL DEFAULT 0.0000,
  `mfg_date` date DEFAULT NULL,
  `exp_date` date DEFAULT NULL,
  `lot_number` varchar(191) DEFAULT NULL,
  `sub_unit_id` int(11) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `purchase_lines_transaction_id_foreign` (`transaction_id`),
  KEY `purchase_lines_product_id_foreign` (`product_id`),
  KEY `purchase_lines_variation_id_foreign` (`variation_id`),
  KEY `purchase_lines_tax_id_foreign` (`tax_id`),
  KEY `purchase_lines_sub_unit_id_index` (`sub_unit_id`),
  KEY `purchase_lines_lot_number_index` (`lot_number`),
  CONSTRAINT `purchase_lines_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE,
  CONSTRAINT `purchase_lines_tax_id_foreign` FOREIGN KEY (`tax_id`) REFERENCES `tax_rates` (`id`) ON DELETE CASCADE,
  CONSTRAINT `purchase_lines_transaction_id_foreign` FOREIGN KEY (`transaction_id`) REFERENCES `transactions` (`id`) ON DELETE CASCADE,
  CONSTRAINT `purchase_lines_variation_id_foreign` FOREIGN KEY (`variation_id`) REFERENCES `variations` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=135778 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `purchase_lines` VALUES (135758,295335,15648,15632,50.0000,0.0000,0.0000,0.00,120.0000,120.0000,0.0000,NULL,NULL,NULL,0.0000,0.0000,0.0000,0.0000,0.0000,NULL,NULL,NULL,NULL,'2026-05-26 17:18:45','2026-05-26 17:18:45'),(135759,295335,15649,15633,50.0000,0.0000,0.0000,0.00,180.0000,180.0000,0.0000,NULL,NULL,NULL,0.0000,0.0000,0.0000,0.0000,0.0000,NULL,NULL,NULL,NULL,'2026-05-26 17:18:45','2026-05-26 17:18:45'),(135760,295335,15650,15634,50.0000,0.0000,0.0000,0.00,200.0000,200.0000,0.0000,NULL,NULL,NULL,0.0000,0.0000,0.0000,0.0000,0.0000,NULL,NULL,NULL,NULL,'2026-05-26 17:18:45','2026-05-26 17:18:45'),(135761,295335,15651,15635,50.0000,0.0000,0.0000,0.00,35.0000,35.0000,0.0000,NULL,NULL,NULL,0.0000,0.0000,0.0000,0.0000,0.0000,NULL,NULL,NULL,NULL,'2026-05-26 17:18:45','2026-05-26 17:18:45'),(135762,295341,15723,15707,50.0000,0.0000,0.0000,0.00,120.0000,120.0000,0.0000,NULL,NULL,NULL,0.0000,0.0000,0.0000,0.0000,0.0000,NULL,NULL,NULL,NULL,'2026-05-28 20:55:46','2026-05-28 20:55:46'),(135763,295341,15724,15708,50.0000,0.0000,0.0000,0.00,180.0000,180.0000,0.0000,NULL,NULL,NULL,0.0000,0.0000,0.0000,0.0000,0.0000,NULL,NULL,NULL,NULL,'2026-05-28 20:55:46','2026-05-28 20:55:46'),(135764,295341,15725,15709,50.0000,0.0000,0.0000,0.00,200.0000,200.0000,0.0000,NULL,NULL,NULL,0.0000,0.0000,0.0000,0.0000,0.0000,NULL,NULL,NULL,NULL,'2026-05-28 20:55:46','2026-05-28 20:55:46'),(135765,295341,15726,15710,50.0000,0.0000,0.0000,0.00,160.0000,160.0000,0.0000,NULL,NULL,NULL,0.0000,0.0000,0.0000,0.0000,0.0000,NULL,NULL,NULL,NULL,'2026-05-28 20:55:46','2026-05-28 20:55:46'),(135766,295347,15776,15760,50.0000,0.0000,0.0000,0.00,120.0000,120.0000,0.0000,NULL,NULL,NULL,0.0000,0.0000,0.0000,0.0000,0.0000,NULL,NULL,NULL,NULL,'2026-05-28 20:58:13','2026-05-28 20:58:13'),(135767,295347,15777,15761,50.0000,0.0000,0.0000,0.00,180.0000,180.0000,0.0000,NULL,NULL,NULL,0.0000,0.0000,0.0000,0.0000,0.0000,NULL,NULL,NULL,NULL,'2026-05-28 20:58:13','2026-05-28 20:58:13'),(135768,295347,15778,15762,50.0000,0.0000,0.0000,0.00,200.0000,200.0000,0.0000,NULL,NULL,NULL,0.0000,0.0000,0.0000,0.0000,0.0000,NULL,NULL,NULL,NULL,'2026-05-28 20:58:13','2026-05-28 20:58:13'),(135769,295347,15779,15763,50.0000,0.0000,0.0000,0.00,160.0000,160.0000,0.0000,NULL,NULL,NULL,0.0000,0.0000,0.0000,0.0000,0.0000,NULL,NULL,NULL,NULL,'2026-05-28 20:58:13','2026-05-28 20:58:13'),(135770,295354,15829,15813,50.0000,0.0000,0.0000,0.00,120.0000,120.0000,0.0000,NULL,NULL,NULL,0.0000,0.0000,0.0000,0.0000,0.0000,NULL,NULL,NULL,NULL,'2026-05-28 21:00:04','2026-05-28 21:00:04'),(135771,295354,15830,15814,50.0000,0.0000,0.0000,0.00,180.0000,180.0000,0.0000,NULL,NULL,NULL,0.0000,0.0000,0.0000,0.0000,0.0000,NULL,NULL,NULL,NULL,'2026-05-28 21:00:04','2026-05-28 21:00:04'),(135772,295354,15831,15815,50.0000,0.0000,0.0000,0.00,200.0000,200.0000,0.0000,NULL,NULL,NULL,0.0000,0.0000,0.0000,0.0000,0.0000,NULL,NULL,NULL,NULL,'2026-05-28 21:00:04','2026-05-28 21:00:04'),(135773,295354,15832,15816,50.0000,0.0000,0.0000,0.00,160.0000,160.0000,0.0000,NULL,NULL,NULL,0.0000,0.0000,0.0000,0.0000,0.0000,NULL,NULL,NULL,NULL,'2026-05-28 21:00:04','2026-05-28 21:00:04'),(135774,295360,15882,15866,50.0000,0.0000,0.0000,0.00,120.0000,120.0000,0.0000,NULL,NULL,NULL,0.0000,0.0000,0.0000,0.0000,0.0000,NULL,NULL,NULL,NULL,'2026-05-28 21:11:55','2026-05-28 21:11:55'),(135775,295360,15883,15867,50.0000,0.0000,0.0000,0.00,180.0000,180.0000,0.0000,NULL,NULL,NULL,0.0000,0.0000,0.0000,0.0000,0.0000,NULL,NULL,NULL,NULL,'2026-05-28 21:11:55','2026-05-28 21:11:55'),(135776,295360,15884,15868,50.0000,0.0000,0.0000,0.00,200.0000,200.0000,0.0000,NULL,NULL,NULL,0.0000,0.0000,0.0000,0.0000,0.0000,NULL,NULL,NULL,NULL,'2026-05-28 21:11:55','2026-05-28 21:11:55'),(135777,295360,15885,15869,50.0000,0.0000,0.0000,0.00,160.0000,160.0000,0.0000,NULL,NULL,NULL,0.0000,0.0000,0.0000,0.0000,0.0000,NULL,NULL,NULL,NULL,'2026-05-28 21:11:55','2026-05-28 21:11:55');
CREATE TABLE `radiology_patient_profiles` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `clc_patient_id` int(10) unsigned NOT NULL,
  `modality` varchar(40) DEFAULT NULL,
  `region` varchar(120) DEFAULT NULL,
  `contrast` tinyint(1) NOT NULL DEFAULT 0,
  `findings` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `radiology_patient_profiles_clc_patient_id_unique` (`clc_patient_id`),
  CONSTRAINT `radiology_patient_profiles_clc_patient_id_foreign` FOREIGN KEY (`clc_patient_id`) REFERENCES `clc_patients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `reference_counts` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `ref_type` varchar(191) NOT NULL,
  `ref_count` int(11) NOT NULL,
  `business_id` int(11) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `reference_counts_business_id_index` (`business_id`)
) ENGINE=InnoDB AUTO_INCREMENT=44 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `reference_counts` VALUES (28,'contacts',16,5,'2026-06-15 17:18:42','2026-06-15 17:18:44'),(29,'business_location',3,5,'2026-06-15 17:18:42','2026-06-15 17:18:42'),(30,'contacts',16,6,'2026-06-17 20:54:54','2026-06-17 20:54:56'),(31,'business_location',3,6,'2026-06-17 20:54:54','2026-06-17 20:54:54'),(32,'contacts',16,7,'2026-06-17 20:55:44','2026-06-17 20:55:45'),(33,'business_location',3,7,'2026-06-17 20:55:44','2026-06-17 20:55:44'),(34,'contacts',16,8,'2026-06-17 20:58:10','2026-06-17 20:58:12'),(35,'business_location',3,8,'2026-06-17 20:58:10','2026-06-17 20:58:10'),(36,'contacts',16,9,'2026-06-17 21:00:01','2026-06-17 21:00:03'),(37,'business_location',3,9,'2026-06-17 21:00:01','2026-06-17 21:00:01'),(38,'contacts',16,10,'2026-06-17 21:11:53','2026-06-17 21:11:54'),(39,'business_location',3,10,'2026-06-17 21:11:53','2026-06-17 21:11:53'),(40,'contacts',1,11,'2026-07-10 05:40:55','2026-07-10 05:40:55'),(41,'business_location',1,11,'2026-07-10 05:40:55','2026-07-10 05:40:55'),(42,'contacts',1,12,'2026-07-10 06:43:14','2026-07-10 06:43:14'),(43,'business_location',1,12,'2026-07-10 06:43:14','2026-07-10 06:43:14');
CREATE TABLE `res_product_modifier_sets` (
  `modifier_set_id` int(10) unsigned NOT NULL,
  `product_id` int(10) unsigned NOT NULL COMMENT 'Table use to store the modifier sets applicable for a product',
  KEY `res_product_modifier_sets_modifier_set_id_foreign` (`modifier_set_id`),
  CONSTRAINT `res_product_modifier_sets_modifier_set_id_foreign` FOREIGN KEY (`modifier_set_id`) REFERENCES `products` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `res_tables` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned NOT NULL,
  `location_id` int(10) unsigned NOT NULL,
  `name` varchar(191) NOT NULL,
  `description` text DEFAULT NULL,
  `created_by` int(10) unsigned NOT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `res_tables_business_id_foreign` (`business_id`),
  CONSTRAINT `res_tables_business_id_foreign` FOREIGN KEY (`business_id`) REFERENCES `business` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `rheumatology_patient_profiles` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `clc_patient_id` int(10) unsigned NOT NULL,
  `tender_joints` int(11) DEFAULT NULL,
  `swollen_joints` int(11) DEFAULT NULL,
  `das28` decimal(8,2) DEFAULT NULL,
  `rf_status` varchar(40) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `rheumatology_patient_profiles_clc_patient_id_unique` (`clc_patient_id`),
  CONSTRAINT `rheumatology_patient_profiles_clc_patient_id_foreign` FOREIGN KEY (`clc_patient_id`) REFERENCES `clc_patients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `role_has_permissions` (
  `permission_id` int(10) unsigned NOT NULL,
  `role_id` int(10) 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;

INSERT INTO `role_has_permissions` VALUES (516,48),(516,53),(516,56),(516,61),(516,64),(516,69),(516,72),(516,77),(516,80),(516,85),(516,88),(516,93),(517,48),(517,56),(517,64),(517,72),(517,80),(517,88),(528,55),(528,63),(528,71),(528,79),(528,87),(528,95),(529,55),(529,63),(529,71),(529,79),(529,87),(529,95),(530,55),(530,63),(530,71),(530,79),(530,87),(530,95),(531,55),(531,63),(531,71),(531,79),(531,87),(531,95),(560,55),(560,63),(560,71),(560,79),(560,87),(560,95),(562,55),(562,63),(562,71),(562,79),(562,87),(562,95),(563,55),(563,63),(563,71),(563,79),(563,87),(563,95),(567,54),(567,70),(567,78),(567,86),(567,94),(568,54),(568,70),(568,78),(568,86),(568,94),(569,54),(569,70),(569,78),(569,86),(569,94),(570,54),(570,70),(570,78),(570,86),(570,94),(571,54),(571,70),(571,78),(571,86),(571,94),(572,54),(572,70),(572,78),(572,86),(572,94),(573,54),(573,70),(573,78),(573,86),(573,94),(574,54),(574,70),(574,78),(574,86),(574,94),(590,94),(591,94),(592,94),(593,94),(595,88),(595,89),(595,90),(595,91),(595,92),(595,93),(596,88),(596,89),(596,90),(596,91),(596,92),(597,88),(597,89),(597,90),(597,91),(597,92),(598,88),(598,89),(598,90),(598,91),(598,92),(598,93),(599,88),(599,89),(599,90),(599,92),(600,88),(600,92),(600,93),(601,89),(601,92),(602,89),(602,92),(603,89),(603,92),(604,89),(604,90),(604,92),(605,89),(605,92),(606,89),(606,92),(606,93),(607,89),(607,92),(607,93),(608,89),(608,90),(608,92),(609,89),(609,90),(609,91),(609,92),(610,89),(610,92),(611,89),(611,90),(611,92),(612,89),(612,92),(613,89),(613,92),(614,89),(614,92),(615,89),(615,92),(616,89),(616,90),(617,92),(618,92),(619,92),(619,93),(620,92),(621,92),(622,92),(623,92),(624,92),(625,92),(626,92);
CREATE TABLE `roles` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(191) NOT NULL,
  `guard_name` varchar(191) NOT NULL,
  `business_id` int(10) unsigned NOT NULL,
  `is_default` tinyint(1) NOT NULL DEFAULT 0,
  `is_service_staff` tinyint(1) NOT NULL DEFAULT 0,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `roles_business_id_foreign` (`business_id`),
  CONSTRAINT `roles_business_id_foreign` FOREIGN KEY (`business_id`) REFERENCES `business` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=113 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `roles` VALUES (88,'Receptionist#10','web',10,0,0,'2026-06-17 21:11:53','2026-06-17 21:11:53'),(89,'Doctor#10','web',10,0,0,'2026-06-17 21:11:53','2026-06-17 21:11:53'),(90,'Nurse#10','web',10,0,0,'2026-06-17 21:11:53','2026-06-17 21:11:53'),(91,'Assistant#10','web',10,0,0,'2026-06-17 21:11:53','2026-06-17 21:11:53'),(92,'Branch Manager#10','web',10,0,0,'2026-06-17 21:11:53','2026-06-17 21:11:53'),(93,'Accounting#10','web',10,0,0,'2026-06-17 21:11:53','2026-06-17 21:11:53'),(94,'Admin#10','web',10,1,0,'2026-06-17 21:11:53','2026-06-17 21:11:53'),(95,'Cashier#10','web',10,0,0,'2026-06-17 21:11:53','2026-06-17 21:11:53');
CREATE TABLE `sell_line_warranties` (
  `sell_line_id` int(11) NOT NULL,
  `warranty_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `selling_price_groups` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(191) NOT NULL,
  `description` text DEFAULT NULL,
  `business_id` int(10) unsigned NOT NULL,
  `is_active` 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 `selling_price_groups_business_id_foreign` (`business_id`),
  CONSTRAINT `selling_price_groups_business_id_foreign` FOREIGN KEY (`business_id`) REFERENCES `business` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `services_patient_profiles` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `clc_patient_id` int(10) unsigned NOT NULL,
  `service_type` varchar(120) DEFAULT NULL,
  `notes` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `services_patient_profiles_clc_patient_id_unique` (`clc_patient_id`),
  CONSTRAINT `services_patient_profiles_clc_patient_id_foreign` FOREIGN KEY (`clc_patient_id`) REFERENCES `clc_patients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `sessions` (
  `id` varchar(191) NOT NULL,
  `user_id` int(10) unsigned DEFAULT NULL,
  `ip_address` varchar(45) DEFAULT NULL,
  `user_agent` text DEFAULT NULL,
  `payload` text NOT NULL,
  `last_activity` int(11) NOT NULL,
  UNIQUE KEY `sessions_id_unique` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `shared_product_items` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `shared_product_id` bigint(20) unsigned NOT NULL,
  `business_id` int(10) unsigned DEFAULT NULL,
  `product_id` bigint(20) unsigned DEFAULT NULL,
  `sku` varchar(191) DEFAULT NULL,
  `product_name` varchar(255) DEFAULT NULL,
  `category_id` int(10) unsigned DEFAULT NULL,
  `sub_category_id` int(10) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `shared_product_items_business_id_category_id_index` (`business_id`,`category_id`),
  KEY `shared_product_items_business_id_sub_category_id_index` (`business_id`,`sub_category_id`),
  KEY `shared_product_items_shared_product_id_index` (`shared_product_id`),
  KEY `shared_product_items_business_id_index` (`business_id`),
  KEY `shared_product_items_product_id_index` (`product_id`),
  KEY `shared_product_items_sku_index` (`sku`)
) ENGINE=InnoDB AUTO_INCREMENT=55528 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `shared_products` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `token` varchar(191) NOT NULL,
  `business_id` int(10) unsigned DEFAULT NULL,
  `user_id` int(10) unsigned DEFAULT NULL,
  `products_data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`products_data`)),
  `expires_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `shared_products_token_unique` (`token`),
  KEY `shared_products_expires_at_index` (`expires_at`),
  KEY `shared_products_business_id_user_id_index` (`business_id`,`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=30592 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `spinal_surgery_patient_profiles` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `clc_patient_id` int(10) unsigned NOT NULL,
  `spinal_level` varchar(120) DEFAULT NULL,
  `neuro_deficit` varchar(40) DEFAULT NULL,
  `planned_procedure` varchar(120) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `spinal_surgery_patient_profiles_clc_patient_id_unique` (`clc_patient_id`),
  CONSTRAINT `spinal_surgery_patient_profiles_clc_patient_id_foreign` FOREIGN KEY (`clc_patient_id`) REFERENCES `clc_patients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `ss_access_logs` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned DEFAULT NULL,
  `file_id` bigint(20) unsigned DEFAULT NULL,
  `logical_path` varchar(500) DEFAULT NULL,
  `action` varchar(20) NOT NULL,
  `granted` tinyint(1) NOT NULL DEFAULT 1,
  `reason` varchar(191) DEFAULT NULL,
  `user_id` int(10) unsigned DEFAULT NULL,
  `device_fingerprint` varchar(191) DEFAULT NULL,
  `ip` varchar(64) DEFAULT NULL,
  `user_agent` varchar(255) DEFAULT NULL,
  `geo_country` varchar(100) DEFAULT NULL,
  `geo_city` varchar(100) DEFAULT NULL,
  `geo_lat` decimal(10,6) DEFAULT NULL,
  `geo_lng` decimal(10,6) DEFAULT NULL,
  `otp_session_id` bigint(20) unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `ss_access_logs_business_id_index` (`business_id`),
  KEY `ss_access_logs_file_id_index` (`file_id`),
  KEY `ss_access_logs_action_index` (`action`),
  KEY `ss_access_logs_user_id_index` (`user_id`),
  KEY `ss_access_logs_ip_index` (`ip`),
  KEY `ss_access_logs_created_at_index` (`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `ss_devices` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned DEFAULT NULL,
  `name` varchar(191) DEFAULT NULL,
  `fingerprint_hash` varchar(191) NOT NULL,
  `ip_cidr` varchar(64) DEFAULT NULL,
  `approved` tinyint(1) NOT NULL DEFAULT 0,
  `last_ip` varchar(64) DEFAULT NULL,
  `last_user_agent` varchar(255) DEFAULT NULL,
  `last_seen_at` timestamp NULL DEFAULT NULL,
  `created_by` int(10) unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `ss_devices_business_id_index` (`business_id`),
  KEY `ss_devices_fingerprint_hash_index` (`fingerprint_hash`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `ss_files` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned DEFAULT NULL,
  `logical_path` varchar(500) NOT NULL,
  `backend` varchar(50) NOT NULL,
  `backend_path` varchar(500) NOT NULL,
  `is_encrypted` tinyint(1) NOT NULL DEFAULT 0,
  `enc_algo` varchar(30) DEFAULT NULL,
  `enc_iv` varchar(64) DEFAULT NULL,
  `enc_tag` varchar(64) DEFAULT NULL,
  `mime` varchar(191) DEFAULT NULL,
  `size` bigint(20) unsigned DEFAULT NULL,
  `stored_size` bigint(20) unsigned DEFAULT NULL,
  `checksum` varchar(64) DEFAULT NULL,
  `uploaded_by` int(10) unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `ss_files_logical_unique` (`logical_path`,`business_id`),
  KEY `ss_files_business_id_index` (`business_id`),
  KEY `ss_files_logical_path_index` (`logical_path`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `ss_otp_sessions` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned DEFAULT NULL,
  `user_id` int(10) unsigned DEFAULT NULL,
  `device_fingerprint` varchar(191) DEFAULT NULL,
  `code_hash` varchar(191) NOT NULL,
  `ip` varchar(64) DEFAULT NULL,
  `verified_at` timestamp NULL DEFAULT NULL,
  `expires_at` timestamp NULL DEFAULT NULL,
  `attempts` tinyint(3) unsigned NOT NULL DEFAULT 0,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `ss_otp_sessions_business_id_index` (`business_id`),
  KEY `ss_otp_sessions_user_id_index` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `ss_settings` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned DEFAULT NULL,
  `active_backend` varchar(50) NOT NULL DEFAULT 'laravel-default',
  `encryption_enabled` tinyint(1) NOT NULL DEFAULT 0,
  `otp_enabled` tinyint(1) NOT NULL DEFAULT 0,
  `otp_ttl_minutes` smallint(5) unsigned NOT NULL DEFAULT 15,
  `otp_channel` varchar(20) NOT NULL DEFAULT 'auto',
  `local_submode` varchar(30) NOT NULL DEFAULT 'this_device_only',
  `lan_cidrs` text DEFAULT NULL,
  `bound_device_fingerprint` varchar(191) DEFAULT NULL,
  `tunnel_url` varchar(255) DEFAULT NULL,
  `tunnel_secret` text DEFAULT NULL,
  `geo_provider` varchar(20) NOT NULL DEFAULT 'none',
  `track_reads` tinyint(1) NOT NULL DEFAULT 1,
  `track_writes` tinyint(1) NOT NULL DEFAULT 1,
  `credentials` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `ss_settings_business_id_index` (`business_id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `ss_settings` VALUES (2,NULL,'laravel-default',0,0,15,'auto','this_device_only','10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,127.0.0.1/32',NULL,'','','none',1,1,NULL,'2026-06-15 16:53:50','2026-06-15 16:53:50');
CREATE TABLE `stock_adjustment_lines` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `transaction_id` int(10) unsigned NOT NULL,
  `product_id` int(10) unsigned NOT NULL,
  `variation_id` int(10) unsigned NOT NULL,
  `quantity` decimal(22,4) NOT NULL,
  `secondary_unit_quantity` decimal(22,4) NOT NULL DEFAULT 0.0000,
  `unit_price` decimal(22,4) DEFAULT NULL COMMENT 'Last purchase unit price',
  `removed_purchase_line` int(11) DEFAULT NULL,
  `lot_no_line_id` int(11) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `stock_adjustment_lines_product_id_foreign` (`product_id`),
  KEY `stock_adjustment_lines_variation_id_foreign` (`variation_id`),
  KEY `stock_adjustment_lines_transaction_id_index` (`transaction_id`),
  KEY `stock_adjustment_lines_lot_no_line_id_index` (`lot_no_line_id`),
  CONSTRAINT `stock_adjustment_lines_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE,
  CONSTRAINT `stock_adjustment_lines_transaction_id_foreign` FOREIGN KEY (`transaction_id`) REFERENCES `transactions` (`id`) ON DELETE CASCADE,
  CONSTRAINT `stock_adjustment_lines_variation_id_foreign` FOREIGN KEY (`variation_id`) REFERENCES `variations` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=4752 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `stock_adjustments_temp` (
  `id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;

CREATE TABLE `stock_reports` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `business_location_id` int(10) unsigned NOT NULL,
  `path` varchar(191) NOT NULL,
  `products_count` int(11) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `stock_reports_business_location_id_foreign` (`business_location_id`),
  CONSTRAINT `stock_reports_business_location_id_foreign` FOREIGN KEY (`business_location_id`) REFERENCES `business_locations` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `system` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `key` varchar(191) NOT NULL,
  `value` text DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=46 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `system` VALUES (1,'db_version','6.7'),(2,'default_business_active_status','1'),(3,'crm_version','3.0'),(4,'connector_version','3.0'),(5,'essentials_version','5.2'),(8,'tpsProduct_version','0.1'),(9,'stockissues_version','1.0.0'),(12,'additional_js','<script>\n$(\"#sku\").prop(\'readonly\',true);\n$(\'.modal\').attr( \'tabIndex\', \"\" );\n</script>'),(13,'TpsTransfer_version','1.1.0'),(14,'PurchaseRequisition_version','1.5.2'),(15,'ActivityLog_version','1.2.0'),(16,'VetClinic_version','2.2.0'),(17,'NX600Lab_version','1.1.0'),(18,'VetAdmission_version','2.0.0'),(19,'VetAI_version','1.1.0'),(20,'VetPortal_version','1.0.0'),(21,'LabCore_version','1.0.0'),(22,'AbaxisLab_version','1.0.0'),(23,'WhatsApp_version','1.0.0'),(24,'landedcost_version','1.2.0'),(25,'AiCore_version','1.0.0'),(26,'productcompat_version','1.0.0'),(27,'DermatologyClinic_version','2.2.0'),(28,'DentalClinic_version','1.0.0'),(29,'SmartStorage_version','1.0.0'),(30,'bms_version','1.0.0'),(31,'AdvancedTransfer_version','1.1.0'),(32,'IdexxLab_version','1.0.0'),(33,'VetSite_version','1.0.0'),(35,'accounting_version','1.0'),(36,'saasswitcher_version','1.0.0'),(37,'neoskin_version','1.0.0'),(38,'neoskin_enabled','1'),(40,'neoskin_theme','{\"accent\":\"#e6b450\",\"accent2\":\"#f0c674\",\"bg\":\"#0a0a12\",\"surface\":\"#15151f\",\"surface2\":\"#0e0e16\",\"bg_preset\":\"obsidian\"}'),(41,'turboboost_version','1.0.0'),(42,'turboboost_enabled','1'),(43,'turboboost_compress','1'),(44,'turboboost_lazy_images','1'),(45,'guidedtour_version','1.0.0');
CREATE TABLE `tax_rates` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `business_id` int(10) unsigned NOT NULL,
  `name` varchar(191) NOT NULL,
  `amount` double(22,4) NOT NULL,
  `is_tax_group` tinyint(1) NOT NULL DEFAULT 0,
  `for_tax_group` tinyint(1) NOT NULL DEFAULT 0,
  `created_by` int(10) unsigned NOT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `tax_rates_business_id_foreign` (`business_id`),
  KEY `tax_rates_created_by_foreign` (`created_by`),
  CONSTRAINT `tax_rates_business_id_foreign` FOREIGN KEY (`business_id`) REFERENCES `business` (`id`) ON DELETE CASCADE,
  CONSTRAINT `tax_rates_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `temp_transfer_products` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `product_id` int(11) NOT NULL,
  `variation_id` int(10) NOT NULL,
  `quantity` decimal(22,4) NOT NULL,
  `location_id` int(11) NOT NULL,
  `transfer_location_id` int(11) NOT NULL,
  `lot_no_line_id` int(11) NOT NULL DEFAULT 0,
  `transaction_date` datetime NOT NULL,
  `additional_notes` text DEFAULT NULL,
  `ref_no` varchar(191) DEFAULT NULL,
  `checked` enum('YES','NO') NOT NULL,
  `status` enum('PREPARE','RECEIVED','TRANSFERED') NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1743 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

CREATE TABLE `tour_flows` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `key` varchar(100) NOT NULL,
  `title` varchar(150) NOT NULL,
  `vertical` varchar(40) DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `autostart_once` tinyint(1) NOT NULL DEFAULT 1,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `tour_flows_key_unique` (`key`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `tour_flows` VALUES (1,'vet-full-tour','VetOne — full walkthrough','vet',1,1,'2026-07-10 06:48:43','2026-07-10 06:48:43');
CREATE TABLE `tour_media` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `kind` enum('image','video') NOT NULL,
  `disk` varchar(40) NOT NULL DEFAULT 'local',
  `path` varchar(255) NOT NULL,
  `mime` varchar(100) DEFAULT NULL,
  `original_name` varchar(255) DEFAULT NULL,
  `size` bigint(20) unsigned 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;

CREATE TABLE `tour_progress` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint(20) unsigned NOT NULL,
  `flow_id` int(10) unsigned NOT NULL,
  `last_step` int(10) unsigned NOT NULL DEFAULT 0,
  `completed_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `tour_progress_user_id_flow_id_unique` (`user_id`,`flow_id`),
  KEY `tour_progress_user_id_index` (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `tour_progress` VALUES (1,211,1,1,NULL,'2026-07-10 06:49:00','2026-07-10 06:49:30');
CREATE TABLE `tour_steps` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `flow_id` int(10) unsigned NOT NULL,
  `sort_order` int(10) unsigned NOT NULL DEFAULT 0,
  `route` varchar(255) DEFAULT NULL,
  `target_selector` varchar(255) DEFAULT NULL,
  `title` varchar(200) NOT NULL,
  `body_html` text DEFAULT NULL,
  `media_id` int(10) unsigned DEFAULT NULL,
  `placement` varchar(20) NOT NULL DEFAULT 'auto',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `tour_steps_flow_id_sort_order_index` (`flow_id`,`sort_order`),
  KEY `tour_steps_media_id_foreign` (`media_id`),
  CONSTRAINT `tour_steps_flow_id_foreign` FOREIGN KEY (`flow_id`) REFERENCES `tour_flows` (`id`) ON DELETE CASCADE,
  CONSTRAINT `tour_steps_media_id_foreign` FOREIGN KEY (`media_id`) REFERENCES `tour_media` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `tour_steps` VALUES (1,1,0,NULL,NULL,'Welcome to VetOne 👋','This quick tour walks you through the whole clinic — appointments, consultations, prescriptions, your pet-owner app and settings. You can replay it any time with the <b>▶ Tour</b> button, bottom-right.',NULL,'auto','2026-07-10 06:48:43','2026-07-10 06:48:43'),(2,1,1,'/home',NULL,'Your dashboard','Everything starts here: today\'s appointments, quick stats and shortcuts to every part of the clinic.',NULL,'auto','2026-07-10 06:48:43','2026-07-10 06:48:43'),(3,1,2,'/vet-clinic/appointments',NULL,'Appointments &amp; doctor schedules','Book and manage appointments on the calendar. Each of your doctors has their own weekly schedule and slot length, so the grid only offers times they actually work.',NULL,'auto','2026-07-10 06:48:43','2026-07-10 06:48:43'),(4,1,3,'/vet-clinic/pets',NULL,'Pets &amp; owners','Every pet has a full clinical history linked to its owner — species, breed, vaccinations, weight trend and past visits.',NULL,'auto','2026-07-10 06:48:43','2026-07-10 06:48:43'),(5,1,4,NULL,NULL,'The SOAP consultation','Open an appointment to run a <b>SOAP</b> consultation — Subjective, Objective, Assessment, Plan. Chief-complaint chips, lab tests and exam panels are all pre-loaded for you.',NULL,'auto','2026-07-10 06:48:43','2026-07-10 06:48:43'),(6,1,5,NULL,NULL,'AI scribe &amp; suggestions','Dictate your notes and the AI scribe cleans them, structures them into SOAP, extracts findings and suggests exam panels. (Add a free Groq key in AI settings to switch this on.)',NULL,'auto','2026-07-10 06:48:43','2026-07-10 06:48:43'),(7,1,6,'/vet-clinic/prescriptions',NULL,'Prescriptions &amp; medicines','Prescribe from a ready-made veterinary formulary — dosages, frequencies and dispensing all in one place.',NULL,'auto','2026-07-10 06:48:43','2026-07-10 06:48:43'),(8,1,7,NULL,NULL,'Your pet-owner app','Every clinic gets a branded pet-owner PWA — your logo, your colours. Owners book appointments, see reminders and their pet\'s records from their phone.',NULL,'auto','2026-07-10 06:48:43','2026-07-10 06:48:43'),(9,1,8,'/whatsapp/channels',NULL,'WhatsApp &amp; AI setup','Connect a WhatsApp number by scanning a QR code to send reminders and let the AI auto-reply. Both WhatsApp and AI are optional.',NULL,'auto','2026-07-10 06:48:43','2026-07-10 06:48:43'),(10,1,9,'/ai-core/settings',NULL,'Settings','Fine-tune everything here — AI provider keys, editable AI prompts, clinic preferences and staff roles.',NULL,'auto','2026-07-10 06:48:43','2026-07-10 06:48:43'),(11,1,10,NULL,NULL,'That\'s the tour! 🎉','Your demo is active for <b>48 hours</b>. Explore freely — and when you\'re ready to keep your clinic, contact TPS. Replay this tour any time from the <b>▶ Tour</b> button.',NULL,'auto','2026-07-10 06:48:43','2026-07-10 06:48:43');
CREATE TABLE `transaction_payments` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `transaction_id` int(11) unsigned DEFAULT NULL,
  `business_id` int(11) DEFAULT NULL,
  `is_return` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Used during sales to return the change',
  `amount` decimal(22,4) NOT NULL DEFAULT 0.0000,
  `method` varchar(191) DEFAULT NULL,
  `payment_type` varchar(191) DEFAULT NULL,
  `transaction_no` varchar(191) DEFAULT NULL,
  `card_transaction_number` varchar(191) DEFAULT NULL,
  `card_number` varchar(191) DEFAULT NULL,
  `card_type` varchar(191) DEFAULT NULL,
  `card_holder_name` varchar(191) DEFAULT NULL,
  `card_month` varchar(191) DEFAULT NULL,
  `card_year` varchar(191) DEFAULT NULL,
  `card_security` varchar(5) DEFAULT NULL,
  `cheque_number` varchar(191) DEFAULT NULL,
  `bank_account_number` varchar(191) DEFAULT NULL,
  `paid_on` datetime DEFAULT NULL,
  `created_by` int(11) DEFAULT NULL,
  `paid_through_link` tinyint(1) NOT NULL DEFAULT 0,
  `gateway` varchar(191) DEFAULT NULL,
  `is_advance` tinyint(1) NOT NULL DEFAULT 0,
  `payment_for` int(11) DEFAULT NULL,
  `parent_id` int(11) DEFAULT NULL,
  `note` varchar(191) DEFAULT NULL,
  `document` varchar(191) DEFAULT NULL,
  `payment_ref_no` varchar(191) DEFAULT NULL,
  `account_id` int(11) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `transaction_payments_transaction_id_foreign` (`transaction_id`),
  KEY `transaction_payments_created_by_index` (`created_by`),
  KEY `transaction_payments_parent_id_index` (`parent_id`),
  KEY `transaction_payments_payment_type_index` (`payment_type`),
  CONSTRAINT `transaction_payments_transaction_id_foreign` FOREIGN KEY (`transaction_id`) REFERENCES `transactions` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=265977 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `transaction_payments` VALUES (265952,295330,5,0,550.0000,'cash',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2026-06-12 20:18:45',164,0,NULL,0,NULL,NULL,NULL,NULL,'VP-1',NULL,'2026-06-12 17:18:45','2026-06-12 17:18:45'),(265953,295331,5,0,300.0000,'cash',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2026-06-09 20:18:45',164,0,NULL,0,NULL,NULL,NULL,NULL,'VP-2',NULL,'2026-06-09 17:18:45','2026-06-09 17:18:45'),(265954,295332,5,0,2800.0000,'cash',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2026-06-06 20:18:45',164,0,NULL,0,NULL,NULL,NULL,NULL,'VP-3',NULL,'2026-06-06 17:18:45','2026-06-06 17:18:45'),(265955,295333,5,0,1850.0000,'cash',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2026-06-03 20:18:45',164,0,NULL,0,NULL,NULL,NULL,NULL,'VP-4',NULL,'2026-06-03 17:18:45','2026-06-03 17:18:45'),(265956,295335,5,0,26750.0000,'bank_transfer',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2026-05-26 20:18:45',164,0,NULL,0,NULL,NULL,NULL,NULL,'VPP-1',NULL,'2026-05-26 17:18:45','2026-05-26 17:18:45'),(265957,295336,7,0,550.0000,'cash',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2026-06-14 23:55:46',177,0,NULL,0,NULL,NULL,NULL,NULL,'VP-1',NULL,'2026-06-14 20:55:46','2026-06-14 20:55:46'),(265958,295337,7,0,300.0000,'cash',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2026-06-11 23:55:46',177,0,NULL,0,NULL,NULL,NULL,NULL,'VP-2',NULL,'2026-06-11 20:55:46','2026-06-11 20:55:46'),(265959,295338,7,0,3100.0000,'cash',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2026-06-08 23:55:46',177,0,NULL,0,NULL,NULL,NULL,NULL,'VP-3',NULL,'2026-06-08 20:55:46','2026-06-08 20:55:46'),(265960,295339,7,0,1550.0000,'cash',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2026-06-05 23:55:46',177,0,NULL,0,NULL,NULL,NULL,NULL,'VP-4',NULL,'2026-06-05 20:55:46','2026-06-05 20:55:46'),(265961,295341,7,0,33000.0000,'bank_transfer',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2026-05-28 23:55:46',177,0,NULL,0,NULL,NULL,NULL,NULL,'VPP-1',NULL,'2026-05-28 20:55:46','2026-05-28 20:55:46'),(265962,295342,8,0,550.0000,'cash',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2026-06-14 23:58:12',183,0,NULL,0,NULL,NULL,NULL,NULL,'VP-1',NULL,'2026-06-14 20:58:12','2026-06-14 20:58:12'),(265963,295343,8,0,300.0000,'cash',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2026-06-11 23:58:12',183,0,NULL,0,NULL,NULL,NULL,NULL,'VP-2',NULL,'2026-06-11 20:58:12','2026-06-11 20:58:12'),(265964,295344,8,0,3100.0000,'cash',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2026-06-08 23:58:12',183,0,NULL,0,NULL,NULL,NULL,NULL,'VP-3',NULL,'2026-06-08 20:58:12','2026-06-08 20:58:12'),(265965,295345,8,0,1550.0000,'cash',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2026-06-05 23:58:12',183,0,NULL,0,NULL,NULL,NULL,NULL,'VP-4',NULL,'2026-06-05 20:58:12','2026-06-05 20:58:12'),(265966,295347,8,0,33000.0000,'bank_transfer',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2026-05-28 23:58:13',183,0,NULL,0,NULL,NULL,NULL,NULL,'VPP-1',NULL,'2026-05-28 20:58:13','2026-05-28 20:58:13'),(265967,295349,9,0,550.0000,'cash',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2026-06-15 00:00:04',189,0,NULL,0,NULL,NULL,NULL,NULL,'VP-1',NULL,'2026-06-14 21:00:04','2026-06-14 21:00:04'),(265968,295350,9,0,300.0000,'cash',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2026-06-12 00:00:04',189,0,NULL,0,NULL,NULL,NULL,NULL,'VP-2',NULL,'2026-06-11 21:00:04','2026-06-11 21:00:04'),(265969,295351,9,0,3100.0000,'cash',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2026-06-09 00:00:04',189,0,NULL,0,NULL,NULL,NULL,NULL,'VP-3',NULL,'2026-06-08 21:00:04','2026-06-08 21:00:04'),(265970,295352,9,0,1550.0000,'cash',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2026-06-06 00:00:04',189,0,NULL,0,NULL,NULL,NULL,NULL,'VP-4',NULL,'2026-06-05 21:00:04','2026-06-05 21:00:04'),(265971,295354,9,0,33000.0000,'bank_transfer',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2026-05-29 00:00:04',189,0,NULL,0,NULL,NULL,NULL,NULL,'VPP-1',NULL,'2026-05-28 21:00:04','2026-05-28 21:00:04'),(265972,295355,10,0,550.0000,'cash',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2026-06-15 00:11:55',195,0,NULL,0,NULL,NULL,NULL,NULL,'VP-1',NULL,'2026-06-14 21:11:55','2026-06-14 21:11:55'),(265973,295356,10,0,300.0000,'cash',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2026-06-12 00:11:55',195,0,NULL,0,NULL,NULL,NULL,NULL,'VP-2',NULL,'2026-06-11 21:11:55','2026-06-11 21:11:55'),(265974,295357,10,0,3100.0000,'cash',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2026-06-09 00:11:55',195,0,NULL,0,NULL,NULL,NULL,NULL,'VP-3',NULL,'2026-06-08 21:11:55','2026-06-08 21:11:55'),(265975,295358,10,0,1550.0000,'cash',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2026-06-06 00:11:55',195,0,NULL,0,NULL,NULL,NULL,NULL,'VP-4',NULL,'2026-06-05 21:11:55','2026-06-05 21:11:55'),(265976,295360,10,0,33000.0000,'bank_transfer',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2026-05-29 00:11:55',195,0,NULL,0,NULL,NULL,NULL,NULL,'VPP-1',NULL,'2026-05-28 21:11:55','2026-05-28 21:11:55');
CREATE TABLE `transaction_sell_lines` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `transaction_id` int(10) unsigned NOT NULL,
  `product_id` int(10) unsigned NOT NULL,
  `variation_id` int(10) unsigned NOT NULL,
  `quantity` decimal(22,4) NOT NULL DEFAULT 0.0000,
  `secondary_unit_quantity` decimal(22,4) NOT NULL DEFAULT 0.0000,
  `quantity_returned` decimal(20,4) NOT NULL DEFAULT 0.0000,
  `unit_price_before_discount` decimal(22,4) NOT NULL DEFAULT 0.0000,
  `unit_price` decimal(22,4) DEFAULT NULL COMMENT 'Sell price excluding tax',
  `line_discount_type` enum('fixed','percentage') DEFAULT NULL,
  `line_discount_amount` decimal(22,4) NOT NULL DEFAULT 0.0000,
  `unit_price_inc_tax` decimal(22,4) DEFAULT NULL COMMENT 'Sell price including tax',
  `item_tax` decimal(22,4) NOT NULL COMMENT 'Tax for one quantity',
  `tax_id` int(10) unsigned DEFAULT NULL,
  `discount_id` int(11) DEFAULT NULL,
  `lot_no_line_id` int(11) DEFAULT NULL,
  `sell_line_note` text DEFAULT NULL,
  `so_line_id` int(11) DEFAULT NULL,
  `so_quantity_invoiced` decimal(22,4) NOT NULL DEFAULT 0.0000,
  `res_service_staff_id` int(11) DEFAULT NULL,
  `res_line_order_status` varchar(191) DEFAULT NULL,
  `parent_sell_line_id` int(11) DEFAULT NULL,
  `children_type` varchar(191) NOT NULL DEFAULT '' COMMENT 'Type of children for the parent, like modifier or combo',
  `sub_unit_id` int(11) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `transaction_sell_lines_transaction_id_foreign` (`transaction_id`),
  KEY `transaction_sell_lines_product_id_foreign` (`product_id`),
  KEY `transaction_sell_lines_variation_id_foreign` (`variation_id`),
  KEY `transaction_sell_lines_tax_id_foreign` (`tax_id`),
  KEY `transaction_sell_lines_children_type_index` (`children_type`),
  KEY `transaction_sell_lines_parent_sell_line_id_index` (`parent_sell_line_id`),
  KEY `transaction_sell_lines_line_discount_type_index` (`line_discount_type`),
  KEY `transaction_sell_lines_discount_id_index` (`discount_id`),
  KEY `transaction_sell_lines_lot_no_line_id_index` (`lot_no_line_id`),
  KEY `transaction_sell_lines_sub_unit_id_index` (`sub_unit_id`),
  CONSTRAINT `transaction_sell_lines_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE,
  CONSTRAINT `transaction_sell_lines_tax_id_foreign` FOREIGN KEY (`tax_id`) REFERENCES `tax_rates` (`id`) ON DELETE CASCADE,
  CONSTRAINT `transaction_sell_lines_transaction_id_foreign` FOREIGN KEY (`transaction_id`) REFERENCES `transactions` (`id`) ON DELETE CASCADE,
  CONSTRAINT `transaction_sell_lines_variation_id_foreign` FOREIGN KEY (`variation_id`) REFERENCES `variations` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=366928 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `transaction_sell_lines` VALUES (366883,295330,15662,15646,1.0000,0.0000,0.0000,200.0000,200.0000,NULL,0.0000,200.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-12 17:18:45','2026-06-12 17:18:45'),(366884,295330,15666,15650,1.0000,0.0000,0.0000,350.0000,350.0000,NULL,0.0000,350.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-12 17:18:45','2026-06-12 17:18:45'),(366885,295331,15663,15647,2.0000,0.0000,0.0000,150.0000,150.0000,NULL,0.0000,150.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-09 17:18:45','2026-06-09 17:18:45'),(366886,295332,15650,15634,1.0000,0.0000,0.0000,400.0000,400.0000,NULL,0.0000,400.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-06 17:18:45','2026-06-06 17:18:45'),(366887,295332,15665,15649,2.0000,0.0000,0.0000,1200.0000,1200.0000,NULL,0.0000,1200.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-06 17:18:45','2026-06-06 17:18:45'),(366888,295333,15664,15648,1.0000,0.0000,0.0000,2500.0000,2500.0000,NULL,0.0000,2500.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-03 17:18:45','2026-06-03 17:18:45'),(366889,295333,15667,15651,2.0000,0.0000,0.0000,600.0000,600.0000,NULL,0.0000,600.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-03 17:18:45','2026-06-03 17:18:45'),(366890,295334,15668,15652,1.0000,0.0000,0.0000,300.0000,300.0000,NULL,0.0000,300.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-05-31 17:18:45','2026-05-31 17:18:45'),(366891,295336,15751,15735,1.0000,0.0000,0.0000,200.0000,200.0000,NULL,0.0000,200.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-14 20:55:46','2026-06-14 20:55:46'),(366892,295336,15755,15739,1.0000,0.0000,0.0000,350.0000,350.0000,NULL,0.0000,350.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-14 20:55:46','2026-06-14 20:55:46'),(366893,295337,15752,15736,2.0000,0.0000,0.0000,150.0000,150.0000,NULL,0.0000,150.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-11 20:55:46','2026-06-11 20:55:46'),(366894,295338,15761,15745,1.0000,0.0000,0.0000,700.0000,700.0000,NULL,0.0000,700.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-08 20:55:46','2026-06-08 20:55:46'),(366895,295338,15754,15738,2.0000,0.0000,0.0000,1200.0000,1200.0000,NULL,0.0000,1200.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-08 20:55:46','2026-06-08 20:55:46'),(366896,295339,15753,15737,1.0000,0.0000,0.0000,2500.0000,2500.0000,NULL,0.0000,2500.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-05 20:55:46','2026-06-05 20:55:46'),(366897,295339,15756,15740,2.0000,0.0000,0.0000,300.0000,300.0000,NULL,0.0000,300.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-05 20:55:46','2026-06-05 20:55:46'),(366898,295340,15757,15741,1.0000,0.0000,0.0000,450.0000,450.0000,NULL,0.0000,450.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-02 20:55:46','2026-06-02 20:55:46'),(366899,295342,15804,15788,1.0000,0.0000,0.0000,200.0000,200.0000,NULL,0.0000,200.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-14 20:58:12','2026-06-14 20:58:12'),(366900,295342,15808,15792,1.0000,0.0000,0.0000,350.0000,350.0000,NULL,0.0000,350.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-14 20:58:12','2026-06-14 20:58:12'),(366901,295343,15805,15789,2.0000,0.0000,0.0000,150.0000,150.0000,NULL,0.0000,150.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-11 20:58:12','2026-06-11 20:58:12'),(366902,295344,15814,15798,1.0000,0.0000,0.0000,700.0000,700.0000,NULL,0.0000,700.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-08 20:58:12','2026-06-08 20:58:12'),(366903,295344,15807,15791,2.0000,0.0000,0.0000,1200.0000,1200.0000,NULL,0.0000,1200.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-08 20:58:12','2026-06-08 20:58:12'),(366904,295345,15806,15790,1.0000,0.0000,0.0000,2500.0000,2500.0000,NULL,0.0000,2500.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-05 20:58:12','2026-06-05 20:58:12'),(366905,295345,15809,15793,2.0000,0.0000,0.0000,300.0000,300.0000,NULL,0.0000,300.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-05 20:58:12','2026-06-05 20:58:12'),(366906,295346,15810,15794,1.0000,0.0000,0.0000,450.0000,450.0000,NULL,0.0000,450.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-02 20:58:13','2026-06-02 20:58:13'),(366907,295348,15809,15793,1.0000,0.0000,0.0000,0.0000,300.0000,NULL,0.0000,300.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-17 20:59:49','2026-06-17 20:59:49'),(366908,295348,15809,15793,1.0000,0.0000,0.0000,0.0000,300.0000,NULL,0.0000,300.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-17 20:59:49','2026-06-17 20:59:49'),(366909,295349,15857,15841,1.0000,0.0000,0.0000,200.0000,200.0000,NULL,0.0000,200.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-14 21:00:04','2026-06-14 21:00:04'),(366910,295349,15861,15845,1.0000,0.0000,0.0000,350.0000,350.0000,NULL,0.0000,350.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-14 21:00:04','2026-06-14 21:00:04'),(366911,295350,15858,15842,2.0000,0.0000,0.0000,150.0000,150.0000,NULL,0.0000,150.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-11 21:00:04','2026-06-11 21:00:04'),(366912,295351,15867,15851,1.0000,0.0000,0.0000,700.0000,700.0000,NULL,0.0000,700.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-08 21:00:04','2026-06-08 21:00:04'),(366913,295351,15860,15844,2.0000,0.0000,0.0000,1200.0000,1200.0000,NULL,0.0000,1200.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-08 21:00:04','2026-06-08 21:00:04'),(366914,295352,15859,15843,1.0000,0.0000,0.0000,2500.0000,2500.0000,NULL,0.0000,2500.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-05 21:00:04','2026-06-05 21:00:04'),(366915,295352,15862,15846,2.0000,0.0000,0.0000,300.0000,300.0000,NULL,0.0000,300.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-05 21:00:04','2026-06-05 21:00:04'),(366916,295353,15863,15847,1.0000,0.0000,0.0000,450.0000,450.0000,NULL,0.0000,450.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-02 21:00:04','2026-06-02 21:00:04'),(366917,295355,15910,15894,1.0000,0.0000,0.0000,200.0000,200.0000,NULL,0.0000,200.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-14 21:11:55','2026-06-14 21:11:55'),(366918,295355,15914,15898,1.0000,0.0000,0.0000,350.0000,350.0000,NULL,0.0000,350.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-14 21:11:55','2026-06-14 21:11:55'),(366919,295356,15911,15895,2.0000,0.0000,0.0000,150.0000,150.0000,NULL,0.0000,150.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-11 21:11:55','2026-06-11 21:11:55'),(366920,295357,15920,15904,1.0000,0.0000,0.0000,700.0000,700.0000,NULL,0.0000,700.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-08 21:11:55','2026-06-08 21:11:55'),(366921,295357,15913,15897,2.0000,0.0000,0.0000,1200.0000,1200.0000,NULL,0.0000,1200.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-08 21:11:55','2026-06-08 21:11:55'),(366922,295358,15912,15896,1.0000,0.0000,0.0000,2500.0000,2500.0000,NULL,0.0000,2500.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-05 21:11:55','2026-06-05 21:11:55'),(366923,295358,15915,15899,2.0000,0.0000,0.0000,300.0000,300.0000,NULL,0.0000,300.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-05 21:11:55','2026-06-05 21:11:55'),(366924,295359,15916,15900,1.0000,0.0000,0.0000,450.0000,450.0000,NULL,0.0000,450.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-02 21:11:55','2026-06-02 21:11:55'),(366925,295361,15915,15899,1.0000,0.0000,0.0000,0.0000,300.0000,NULL,0.0000,300.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-18 21:44:29','2026-06-18 21:44:29'),(366926,295361,15915,15899,1.0000,0.0000,0.0000,0.0000,300.0000,NULL,0.0000,300.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-18 21:44:29','2026-06-18 21:44:29'),(366927,295361,15915,15899,1.0000,0.0000,0.0000,0.0000,300.0000,NULL,0.0000,300.0000,0.0000,NULL,NULL,NULL,NULL,NULL,0.0000,NULL,NULL,NULL,'',NULL,'2026-06-18 21:44:29','2026-06-18 21:44:29');
CREATE TABLE `transaction_sell_lines_purchase_lines` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `sell_line_id` int(10) unsigned DEFAULT NULL COMMENT 'id from transaction_sell_lines',
  `stock_adjustment_line_id` int(10) unsigned DEFAULT NULL COMMENT 'id from stock_adjustment_lines',
  `purchase_line_id` int(10) unsigned NOT NULL COMMENT 'id from purchase_lines',
  `quantity` decimal(22,4) NOT NULL,
  `qty_returned` decimal(22,4) NOT NULL DEFAULT 0.0000,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `sell_line_id` (`sell_line_id`),
  KEY `stock_adjustment_line_id` (`stock_adjustment_line_id`),
  KEY `purchase_line_id` (`purchase_line_id`)
) ENGINE=InnoDB AUTO_INCREMENT=45859681 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

