From 63015ab22db9c4ee0d46c408a4a807d103a55cea Mon Sep 17 00:00:00 2001 From: johnnyq Date: Sat, 21 Dec 2024 16:46:21 -0500 Subject: [PATCH] Feature: Recurring Payments created DB Structure --- database_updates.php | 26 +++++++++++++++++++++++--- database_version.php | 2 +- db.sql | 24 +++++++++++++++++++++++- 3 files changed, 47 insertions(+), 5 deletions(-) diff --git a/database_updates.php b/database_updates.php index 0b5925cc..3a7fac23 100644 --- a/database_updates.php +++ b/database_updates.php @@ -2376,10 +2376,30 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) { mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.7.3'"); } - // if (CURRENT_DATABASE_VERSION == '1.7.3') { - // // Insert queries here required to update to DB version 1.7.4 + if (CURRENT_DATABASE_VERSION == '1.7.3') { + + // Add Recurring Payments + mysqli_query($mysqli, "CREATE TABLE `recurring_payments` ( + `recurring_payment_id` INT(11) NOT NULL AUTO_INCREMENT, + `recurring_payment_amount` DECIMAL(15,2) NOT NULL, + `recurring_payment_currency_code` VARCHAR(10) NOT NULL, + `recurring_payment_method` VARCHAR(200) NOT NULL, + `recurring_payment_created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP(), + `recurring_payment_updated_at` DATETIME DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, + `recurring_payment_archived_at` DATETIME DEFAULT NULL, + `recurring_payment_account_id` INT(11) NOT NULL, + `recurring_payment_recurring_expense_id` INT(11) NOT NULL DEFAULT 0, + `recurring_payment_recurring_invoice_id` INT(11) NOT NULL, + PRIMARY KEY (`recurring_payment_id`) + )"); + + mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.7.4'"); + } + + // if (CURRENT_DATABASE_VERSION == '1.7.4') { + // // Insert queries here required to update to DB version 1.7.5 // // Then, update the database to the next sequential version - // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.7.4'"); + // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.7.5'"); // } } else { diff --git a/database_version.php b/database_version.php index d959034c..1d0be201 100644 --- a/database_version.php +++ b/database_version.php @@ -5,4 +5,4 @@ * It is used in conjunction with database_updates.php */ -DEFINE("LATEST_DATABASE_VERSION", "1.7.3"); +DEFINE("LATEST_DATABASE_VERSION", "1.7.4"); diff --git a/db.sql b/db.sql index 3675dc53..9e340da1 100644 --- a/db.sql +++ b/db.sql @@ -1383,6 +1383,28 @@ CREATE TABLE `recurring_expenses` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `recurring_payments` +-- + +DROP TABLE IF EXISTS `recurring_payments`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `recurring_payments` ( + `recurring_payment_id` int(11) NOT NULL AUTO_INCREMENT, + `recurring_payment_amount` decimal(15,2) NOT NULL, + `recurring_payment_currency_code` varchar(10) NOT NULL, + `recurring_payment_method` varchar(200) NOT NULL, + `recurring_payment_created_at` datetime NOT NULL DEFAULT current_timestamp(), + `recurring_payment_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), + `recurring_payment_archived_at` datetime DEFAULT NULL, + `recurring_payment_account_id` int(11) NOT NULL, + `recurring_payment_recurring_expense_id` int(11) NOT NULL DEFAULT 0, + `recurring_payment_recurring_invoice_id` int(11) NOT NULL, + PRIMARY KEY (`recurring_payment_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `remember_tokens` -- @@ -2266,4 +2288,4 @@ CREATE TABLE `vendors` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2024-12-13 15:11:31 +-- Dump completed on 2024-12-21 16:44:59