From 72091670fd5612fc3f36d69a5e841a89f9ecfacc Mon Sep 17 00:00:00 2001 From: johnnyq Date: Sat, 7 Mar 2026 18:23:19 -0500 Subject: [PATCH] Bump DB to to include tables for quote items and recurring invoice item for future splitting of line items --- admin/database_updates.php | 53 +++++++++++++++++++++++++++++++-- db.sql | 56 ++++++++++++++++++++++++++++++++++- includes/database_version.php | 2 +- 3 files changed, 106 insertions(+), 5 deletions(-) diff --git a/admin/database_updates.php b/admin/database_updates.php index 76235b45..80be56c1 100644 --- a/admin/database_updates.php +++ b/admin/database_updates.php @@ -4193,10 +4193,57 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) { mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '2.4.0'"); } - // if (CURRENT_DATABASE_VERSION == '2.4.0') { - // // Insert queries here required to update to DB version 2.4.1 + if (CURRENT_DATABASE_VERSION == '2.4.0') { + + mysqli_query($mysqli, " + CREATE TABLE `quote_items` ( + `item_id` int(11) NOT NULL AUTO_INCREMENT, + `item_name` varchar(200) NOT NULL, + `item_description` text DEFAULT NULL, + `item_quantity` decimal(15,2) NOT NULL DEFAULT 0.00, + `item_price` decimal(15,2) NOT NULL DEFAULT 0.00, + `item_subtotal` decimal(15,2) NOT NULL DEFAULT 0.00, + `item_tax` decimal(15,2) NOT NULL DEFAULT 0.00, + `item_total` decimal(15,2) NOT NULL DEFAULT 0.00, + `item_order` int(11) NOT NULL DEFAULT 0, + `item_created_at` datetime NOT NULL DEFAULT current_timestamp(), + `item_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), + `item_archived_at` datetime DEFAULT NULL, + `item_tax_id` int(11) NOT NULL DEFAULT 0, + `item_product_id` int(11) NOT NULL DEFAULT 0, + `item_quote_id` int(11) NOT NULL, + PRIMARY KEY (`item_id`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + "); + + mysqli_query($mysqli, " + CREATE TABLE `recurring_invoice_items` ( + `item_id` int(11) NOT NULL AUTO_INCREMENT, + `item_name` varchar(200) NOT NULL, + `item_description` text DEFAULT NULL, + `item_quantity` decimal(15,2) NOT NULL DEFAULT 0.00, + `item_price` decimal(15,2) NOT NULL DEFAULT 0.00, + `item_subtotal` decimal(15,2) NOT NULL DEFAULT 0.00, + `item_tax` decimal(15,2) NOT NULL DEFAULT 0.00, + `item_total` decimal(15,2) NOT NULL DEFAULT 0.00, + `item_order` int(11) NOT NULL DEFAULT 0, + `item_created_at` datetime NOT NULL DEFAULT current_timestamp(), + `item_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), + `item_archived_at` datetime DEFAULT NULL, + `item_tax_id` int(11) NOT NULL DEFAULT 0, + `item_product_id` int(11) NOT NULL DEFAULT 0, + `item_recurring_invoice_id` int(11) NOT NULL, + PRIMARY KEY (`item_id`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + "); + + mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '2.4.1'"); + } + + // if (CURRENT_DATABASE_VERSION == '2.4.1') { + // // Insert queries here required to update to DB version 2.4.2 // // Then, update the database to the next sequential version - // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '2.4.1'"); + // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '2.4.2'"); // } } else { diff --git a/db.sql b/db.sql index edef39fd..fbbbf534 100644 --- a/db.sql +++ b/db.sql @@ -1783,6 +1783,33 @@ CREATE TABLE `quote_files` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `quote_items` +-- + +DROP TABLE IF EXISTS `quote_items`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `quote_items` ( + `item_id` int(11) NOT NULL AUTO_INCREMENT, + `item_name` varchar(200) NOT NULL, + `item_description` text DEFAULT NULL, + `item_quantity` decimal(15,2) NOT NULL DEFAULT 0.00, + `item_price` decimal(15,2) NOT NULL DEFAULT 0.00, + `item_subtotal` decimal(15,2) NOT NULL DEFAULT 0.00, + `item_tax` decimal(15,2) NOT NULL DEFAULT 0.00, + `item_total` decimal(15,2) NOT NULL DEFAULT 0.00, + `item_order` int(11) NOT NULL DEFAULT 0, + `item_created_at` datetime NOT NULL DEFAULT current_timestamp(), + `item_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), + `item_archived_at` datetime DEFAULT NULL, + `item_tax_id` int(11) NOT NULL DEFAULT 0, + `item_product_id` int(11) NOT NULL DEFAULT 0, + `item_quote_id` int(11) NOT NULL, + PRIMARY KEY (`item_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `quotes` -- @@ -1915,6 +1942,33 @@ CREATE TABLE `recurring_expenses` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `recurring_invoice_items` +-- + +DROP TABLE IF EXISTS `recurring_invoice_items`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `recurring_invoice_items` ( + `item_id` int(11) NOT NULL AUTO_INCREMENT, + `item_name` varchar(200) NOT NULL, + `item_description` text DEFAULT NULL, + `item_quantity` decimal(15,2) NOT NULL DEFAULT 0.00, + `item_price` decimal(15,2) NOT NULL DEFAULT 0.00, + `item_subtotal` decimal(15,2) NOT NULL DEFAULT 0.00, + `item_tax` decimal(15,2) NOT NULL DEFAULT 0.00, + `item_total` decimal(15,2) NOT NULL DEFAULT 0.00, + `item_order` int(11) NOT NULL DEFAULT 0, + `item_created_at` datetime NOT NULL DEFAULT current_timestamp(), + `item_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), + `item_archived_at` datetime DEFAULT NULL, + `item_tax_id` int(11) NOT NULL DEFAULT 0, + `item_product_id` int(11) NOT NULL DEFAULT 0, + `item_recurring_invoice_id` int(11) NOT NULL, + PRIMARY KEY (`item_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `recurring_invoices` -- @@ -3069,4 +3123,4 @@ CREATE TABLE `vendors` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2026-02-03 22:22:07 +-- Dump completed on 2026-03-07 18:20:44 diff --git a/includes/database_version.php b/includes/database_version.php index 4471201f..0b24573c 100644 --- a/includes/database_version.php +++ b/includes/database_version.php @@ -5,4 +5,4 @@ * It is used in conjunction with database_updates.php */ -DEFINE("LATEST_DATABASE_VERSION", "2.4.0"); +DEFINE("LATEST_DATABASE_VERSION", "2.4.1");