From a91352229e262779a14ab0c5148740616227f1fe Mon Sep 17 00:00:00 2001 From: johnnyq Date: Sun, 3 Mar 2024 13:40:50 -0500 Subject: [PATCH] Drop asset_login_id as we have login_asset_id to allow 1 asset many logins, also drop the unused many to many asset login table --- database_updates.php | 15 ++++++++++++--- database_version.php | 2 +- db.sql | 17 +---------------- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/database_updates.php b/database_updates.php index 30527bcc..d8ca049f 100644 --- a/database_updates.php +++ b/database_updates.php @@ -1621,10 +1621,19 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) { mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.0.8'"); } - // if (CURRENT_DATABASE_VERSION == '1.0.8') { - // // Insert queries here required to update to DB version 1.0.9 + if (CURRENT_DATABASE_VERSION == '1.0.8') { + // Removed this as login_asset_id is present in the logins table and allow 1 asset to have many logins. + mysqli_query($mysqli, "ALTER TABLE `assets` DROP `asset_login_id`"); + // Dropped this unused Table as we don't need many to many relationship between assets and logins + mysqli_query($mysqli, "DROP TABLE asset_logins"); + + mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.0.9'"); + } + + // if (CURRENT_DATABASE_VERSION == '1.0.9') { + // // Insert queries here required to update to DB version 1.1.0 // // Then, update the database to the next sequential version - // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.0.9'"); + // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.1.0'"); // } } else { diff --git a/database_version.php b/database_version.php index eb2233d5..c2981735 100644 --- a/database_version.php +++ b/database_version.php @@ -5,5 +5,5 @@ * It is used in conjunction with database_updates.php */ -DEFINE("LATEST_DATABASE_VERSION", "1.0.8"); +DEFINE("LATEST_DATABASE_VERSION", "1.0.9"); diff --git a/db.sql b/db.sql index 2a6a57ea..f5aa8fcc 100644 --- a/db.sql +++ b/db.sql @@ -117,20 +117,6 @@ CREATE TABLE `asset_files` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `asset_logins` --- - -DROP TABLE IF EXISTS `asset_logins`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `asset_logins` ( - `asset_id` int(11) NOT NULL, - `login_id` int(11) NOT NULL, - PRIMARY KEY (`asset_id`,`login_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `assets` -- @@ -161,7 +147,6 @@ CREATE TABLE `assets` ( `asset_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), `asset_archived_at` datetime DEFAULT NULL, `asset_accessed_at` datetime DEFAULT NULL, - `asset_login_id` int(11) NOT NULL DEFAULT 0, `asset_vendor_id` int(11) NOT NULL DEFAULT 0, `asset_location_id` int(11) NOT NULL DEFAULT 0, `asset_contact_id` int(11) NOT NULL DEFAULT 0, @@ -1783,4 +1768,4 @@ CREATE TABLE `vendors` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2024-02-29 15:50:30 +-- Dump completed on 2024-03-03 13:39:52