From b12e3677bd7a8a7d85038767aff01b916fb2ab99 Mon Sep 17 00:00:00 2001 From: johnnyq Date: Mon, 3 Jul 2023 16:40:45 -0400 Subject: [PATCH] DB Structure Update This is the beginnings to move primary_contact and primary_location fields out of the clients table and into their respectable table. Created the fields in contacts and locations, next is to write SQL query to migrate and then update pieces of the codes in the App --- database_updates.php | 13 ++++++++++--- database_version.php | 2 +- db.sql | 4 +++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/database_updates.php b/database_updates.php index e844d20b..4805b338 100644 --- a/database_updates.php +++ b/database_updates.php @@ -1097,11 +1097,18 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) { mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.5.8'"); } - //if (CURRENT_DATABASE_VERSION == '0.5.8') { - //Insert queries here required to update to DB version 0.5.9 + if (CURRENT_DATABASE_VERSION == '0.5.8') { + mysqli_query($mysqli, "ALTER TABLE `contacts` ADD `contact_primary` TINYINT(1) NOT NULL DEFAULT 0 AFTER `contact_token_expire`"); + mysqli_query($mysqli, "ALTER TABLE `locations` ADD `location_primary` TINYINT(1) NOT NULL DEFAULT 0 AFTER `location_photo`"); + + mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.5.9'"); + } + + //if (CURRENT_DATABASE_VERSION == '0.5.9') { + //Insert queries here required to update to DB version 0.6.0 // Then, update the database to the next sequential version - //mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.5.9'"); + //mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.6.0'"); //} } else { diff --git a/database_version.php b/database_version.php index 14eeb315..5b4a09ed 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", "0.5.8"); +DEFINE("LATEST_DATABASE_VERSION", "0.5.9"); diff --git a/db.sql b/db.sql index 9b4126c7..bbe07477 100644 --- a/db.sql +++ b/db.sql @@ -357,6 +357,7 @@ CREATE TABLE `contacts` ( `contact_password_hash` varchar(200) DEFAULT NULL, `contact_password_reset_token` varchar(200) DEFAULT NULL, `contact_token_expire` datetime DEFAULT NULL, + `contact_primary` tinyint(1) NOT NULL DEFAULT 0, `contact_important` tinyint(1) NOT NULL DEFAULT 0, `contact_billing` tinyint(1) DEFAULT 0, `contact_technical` tinyint(1) DEFAULT 0, @@ -682,6 +683,7 @@ CREATE TABLE `locations` ( `location_phone` varchar(200) DEFAULT NULL, `location_hours` varchar(200) DEFAULT NULL, `location_photo` varchar(200) DEFAULT NULL, + `location_primary` tinyint(1) NOT NULL DEFAULT 0, `location_notes` text DEFAULT NULL, `location_created_at` datetime NOT NULL DEFAULT current_timestamp(), `location_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), @@ -1616,4 +1618,4 @@ CREATE TABLE `vendors` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2023-06-20 19:53:31 +-- Dump completed on 2023-07-03 16:38:34