Copy primary_contact and primary_location enties over to thier respecting tables through a DB update

This commit is contained in:
johnnyq 2023-07-03 17:59:12 -04:00
parent 957b5b583c
commit 86ef22dfc9
2 changed files with 25 additions and 4 deletions

View File

@ -1104,11 +1104,32 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) {
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
if (CURRENT_DATABASE_VERSION == '0.5.9') {
// Copy primary_location and primary_contact to their new vars in their own respecting tables
$sql = mysqli_query($mysqli, "SELECT * FROM clients");
while($row = mysqli_fetch_array($sql)) {
$primary_contact = $row['primary_contact'];
$primary_location = $row['primary_location'];
if($primary_contact > 0){
mysqli_query($mysqli, "UPDATE contacts SET contact_primary = 1, contact_important = 1 WHERE contact_id = $primary_contact");
}
if($primary_location > 0){
mysqli_query($mysqli, "UPDATE locations SET location_primary = 1 WHERE location_id = $primary_location");
}
}
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.6.0'");
}
//if (CURRENT_DATABASE_VERSION == '0.6.0') {
//Insert queries here required to update to DB version 0.6.1
// Then, update the database to the next sequential version
//mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.6.0'");
//mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.6.1'");
//}
} else {

View File

@ -5,4 +5,4 @@
* It is used in conjunction with database_updates.php
*/
DEFINE("LATEST_DATABASE_VERSION", "0.5.9");
DEFINE("LATEST_DATABASE_VERSION", "0.6.0");