Update to change the client tag to singular as it references one record the table name should remain plural

This commit is contained in:
johnnyq 2023-02-25 15:27:23 -05:00
parent 11501d8e0b
commit 75b14b4f6f
5 changed files with 23 additions and 15 deletions

View File

@ -869,11 +869,19 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) {
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.4.4'");
}
//if (CURRENT_DATABASE_VERSION == '0.4.4') {
if (CURRENT_DATABASE_VERSION == '0.4.4') {
// Insert queries here required to update to DB version 0.4.5
mysqli_query($mysqli, "ALTER TABLE `client_tags` CHANGE `client_tags_client_id` `client_tag_client_id` INT NOT NULL");
mysqli_query($mysqli, "ALTER TABLE `client_tags` CHANGE `client_tags_tag_id` `client_tag_tag_id` INT NOT NULL");
// Then, update the database to the next sequential version
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.4.5'");
}
//if (CURRENT_DATABASE_VERSION == '0.4.5') {
// Insert queries here required to update to DB version 0.4.6
// Then, update the database to the next sequential version
// mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.4.5'");
// mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.4.6'");
//}
} else {

View File

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

12
db.sql
View File

@ -1,8 +1,8 @@
-- MariaDB dump 10.19 Distrib 10.5.18-MariaDB, for debian-linux-gnu (x86_64)
-- MariaDB dump 10.19 Distrib 10.5.19-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: localhost Database: itflow_dev
-- ------------------------------------------------------
-- Server version 10.5.18-MariaDB-1:10.5.18+maria~ubu2004
-- Server version 10.5.19-MariaDB-1:10.5.19+maria~ubu2004
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@ -207,9 +207,9 @@ DROP TABLE IF EXISTS `client_tags`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `client_tags` (
`client_tags_client_id` int(11) NOT NULL,
`client_tags_tag_id` int(11) NOT NULL,
PRIMARY KEY (`client_tags_client_id`,`client_tags_tag_id`)
`client_tag_client_id` int(11) NOT NULL,
`client_tag_tag_id` int(11) NOT NULL,
PRIMARY KEY (`client_tag_client_id`,`client_tag_tag_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@ -1538,4 +1538,4 @@ CREATE TABLE `vendors` (
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2023-02-09 14:35:51
-- Dump completed on 2023-02-25 15:25:59

View File

@ -674,7 +674,7 @@ if(isset($_GET['delete_company'])){
$sql = mysqli_query($mysqli,"SELECT client_id FROM clients WHERE company_id = $company_id");
while($row = mysqli_fetch_array($sql)){
$client_id = $row['client_id'];
mysqli_query($mysqli,"DELETE FROM client_tags WHERE client_tags_client_id = $client_id");
mysqli_query($mysqli,"DELETE FROM client_tags WHERE client_tag_client_id = $client_id");
mysqli_query($mysqli,"DELETE FROM shared_items WHERE item_client_id = $client_id");
}
mysqli_query($mysqli,"DELETE FROM clients WHERE company_id = $company_id");
@ -1835,7 +1835,7 @@ if(isset($_POST['add_client'])){
if(isset($_POST['tags'])){
foreach($_POST['tags'] as $tag){
$tag = intval($tag);
mysqli_query($mysqli,"INSERT INTO client_tags SET client_tags_client_id = $client_id, client_tags_tag_id = $tag");
mysqli_query($mysqli,"INSERT INTO client_tags SET client_tag_client_id = $client_id, client_tag_tag_id = $tag");
}
}
@ -1897,12 +1897,12 @@ if(isset($_POST['edit_client'])){
//Tags
//Delete existing tags
mysqli_query($mysqli,"DELETE FROM client_tags WHERE client_tags_client_id = $client_id");
mysqli_query($mysqli,"DELETE FROM client_tags WHERE client_tag_client_id = $client_id");
//Add new tags
foreach($_POST['tags'] as $tag){
$tag = intval($tag);
mysqli_query($mysqli,"INSERT INTO client_tags SET client_tags_client_id = $client_id, client_tags_tag_id = $tag");
mysqli_query($mysqli,"INSERT INTO client_tags SET client_tag_client_id = $client_id, client_tag_tag_id = $tag");
}
//Logging
@ -1972,7 +1972,7 @@ if(isset($_GET['delete_client'])){
mysqli_query($mysqli,"DELETE FROM api_keys WHERE api_key_client_id = $client_id");
mysqli_query($mysqli,"DELETE FROM assets WHERE asset_client_id = $client_id");
mysqli_query($mysqli,"DELETE FROM certificates WHERE certificate_client_id = $client_id");
mysqli_query($mysqli,"DELETE FROM client_tags WHERE client_tags_client_id = $client_id");
mysqli_query($mysqli,"DELETE FROM client_tags WHERE client_tag_client_id = $client_id");
mysqli_query($mysqli,"DELETE FROM contacts WHERE contact_client_id = $client_id");
mysqli_query($mysqli,"DELETE FROM documents WHERE document_client_id = $client_id");

View File

@ -141,7 +141,7 @@ if (isset($_GET['ticket_id'])) {
//Client Tags
$client_tag_name_display_array = array();
$client_tag_id_array = array();
$sql_client_tags = mysqli_query($mysqli, "SELECT * FROM client_tags LEFT JOIN tags ON client_tags.client_tags_tag_id = tags.tag_id WHERE client_tags.client_tags_client_id = $client_id");
$sql_client_tags = mysqli_query($mysqli, "SELECT * FROM client_tags LEFT JOIN tags ON client_tags.client_tag_tag_id = tags.tag_id WHERE client_tags.client_tag_client_id = $client_id");
while ($row = mysqli_fetch_array($sql_client_tags)) {
$client_tag_id = intval($row['tag_id']);