From a0455cc296816f2e95312a49c687a3c64704cfbe Mon Sep 17 00:00:00 2001 From: johnnyq Date: Mon, 9 Jan 2023 19:15:23 -0500 Subject: [PATCH] DB Structure for Asset Network Interfaces ex switch ports, routers etc --- database_updates.php | 27 ++++++++++++++++++++++++--- database_version.php | 2 +- db.sql | 26 +++++++++++++++++++++++++- 3 files changed, 50 insertions(+), 5 deletions(-) diff --git a/database_updates.php b/database_updates.php index 62ceca03..69e2c311 100644 --- a/database_updates.php +++ b/database_updates.php @@ -392,11 +392,32 @@ if(LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION){ mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.2.3'"); } - //if(CURRENT_DATABASE_VERSION == '0.2.3'){ - // Insert queries here required to update to DB version 0.2.4 + if(CURRENT_DATABASE_VERSION == '0.2.3'){ + + //Create New interfaces Table + mysqli_query($mysqli, "CREATE TABLE `interfaces` (`interface_id` int(11) AUTO_INCREMENT PRIMARY KEY, + `interface_number` int(11) NULL DEFAULT NULL, + `interface_description` varchar(200) NULL DEFAULT NULL, + `interface_connected_asset` varchar(200) NULL DEFAULT NULL, + `interface_ip` varchar(200) NULL DEFAULT NULL, + `interface_created_at` datetime DEFAULT CURRENT_TIMESTAMP, + `interface_updated_at` datetime NULL ON UPDATE CURRENT_TIMESTAMP, + `interface_archived_at` datetime NULL DEFAULT NULL, + `interface_connected_asset_id` int(11) NOT NULL DEFAULT 0, + `interface_network_id` int(11) NOT NULL DEFAULT 0, + `interface_asset_id` int(11) NOT NULL, + `company_id` int(11) NOT NULL + )"); + + mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.2.4'"); + + } + + //if(CURRENT_DATABASE_VERSION == '0.2.4'){ + // Insert queries here required to update to DB version 0.2.5 // Then, update the database to the next sequential version - // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.2.4'"); + // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.2.5'"); //} diff --git a/database_version.php b/database_version.php index 5778d714..dfbdf1e6 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.2.3"); \ No newline at end of file +DEFINE("LATEST_DATABASE_VERSION", "0.2.4"); \ No newline at end of file diff --git a/db.sql b/db.sql index 6a5cd96b..645556cb 100644 --- a/db.sql +++ b/db.sql @@ -502,6 +502,30 @@ CREATE TABLE `history` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `interfaces` +-- + +DROP TABLE IF EXISTS `interfaces`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `interfaces` ( + `interface_id` int(11) NOT NULL AUTO_INCREMENT, + `interface_number` int(11) DEFAULT NULL, + `interface_description` varchar(200) DEFAULT NULL, + `interface_connected_asset` varchar(200) DEFAULT NULL, + `interface_ip` varchar(200) DEFAULT NULL, + `interface_created_at` datetime DEFAULT current_timestamp(), + `interface_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), + `interface_archived_at` datetime DEFAULT NULL, + `interface_connected_asset_id` int(11) NOT NULL DEFAULT 0, + `interface_network_id` int(11) NOT NULL DEFAULT 0, + `interface_asset_id` int(11) NOT NULL, + `company_id` int(11) NOT NULL, + PRIMARY KEY (`interface_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `invoice_items` -- @@ -1498,4 +1522,4 @@ CREATE TABLE `vendors` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2022-12-19 11:42:40 +-- Dump completed on 2023-01-09 19:14:30