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

This commit is contained in:
johnnyq 2023-07-03 16:40:45 -04:00
parent 66ec189fae
commit b12e3677bd
3 changed files with 14 additions and 5 deletions

View File

@ -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 {

View File

@ -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");

4
db.sql
View File

@ -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