DB Structure Update: Remove Account Types, Add Account Description Field, Change is admin from INT to TINYINT for performance

This commit is contained in:
johnnyq 2024-09-18 16:30:55 -04:00
parent 62a2ed7430
commit 415f536cd7
3 changed files with 44 additions and 42 deletions

View File

@ -2209,10 +2209,23 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) {
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.5.0'");
}
// if (CURRENT_DATABASE_VERSION == '1.5.0') {
// // Insert queries here required to update to DB version 1.5.1
if (CURRENT_DATABASE_VERSION == '1.5.0') {
mysqli_query($mysqli, "DROP TABLE `account_types`");
mysqli_query($mysqli, "ALTER TABLE `accounts` ADD `account_description` VARCHAR(250) DEFAULT NULL AFTER `account_name`");
mysqli_query($mysqli, "ALTER TABLE `user_roles` MODIFY `user_role_is_admin` TINYINT(1) NOT NULL DEFAULT '0'");
mysqli_query($mysqli, "ALTER TABLE `shared_items` ADD `item_recipient` VARCHAR(250) DEFAULT NULL AFTER `item_note`");
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.5.1'");
}
// if (CURRENT_DATABASE_VERSION == '1.5.1') {
// // Insert queries here required to update to DB version 1.5.2
// // Then, update the database to the next sequential version
// mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.5.1'");
// mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.5.2'");
// }
} else {

View File

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

65
db.sql
View File

@ -15,25 +15,6 @@
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `account_types`
--
DROP TABLE IF EXISTS `account_types`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `account_types` (
`account_type_id` int(11) NOT NULL AUTO_INCREMENT,
`account_type_parent` int(11) NOT NULL DEFAULT 1,
`account_type_name` varchar(255) NOT NULL,
`account_type_description` text DEFAULT NULL,
`account_type_created_at` datetime NOT NULL DEFAULT current_timestamp(),
`account_type_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(),
`account_type_archived_at` datetime DEFAULT NULL,
PRIMARY KEY (`account_type_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `accounts`
--
@ -44,6 +25,7 @@ DROP TABLE IF EXISTS `accounts`;
CREATE TABLE `accounts` (
`account_id` int(11) NOT NULL AUTO_INCREMENT,
`account_name` varchar(200) NOT NULL,
`account_description` varchar(250) DEFAULT NULL,
`opening_balance` decimal(15,2) NOT NULL DEFAULT 0.00,
`account_currency_code` varchar(200) NOT NULL,
`account_notes` text DEFAULT NULL,
@ -894,12 +876,15 @@ CREATE TABLE `logs` (
--
DROP TABLE IF EXISTS `modules`;
CREATE TABLE IF NOT EXISTS `modules` (
`module_id` int(11) NOT NULL AUTO_INCREMENT,
`module_name` varchar(200) NOT NULL,
`module_description` varchar(200) DEFAULT NULL,
PRIMARY KEY (`module_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `modules` (
`module_id` int(11) NOT NULL AUTO_INCREMENT,
`module_name` varchar(200) NOT NULL,
`module_description` varchar(200) DEFAULT NULL,
PRIMARY KEY (`module_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `networks`
@ -1563,6 +1548,7 @@ CREATE TABLE `shared_items` (
`item_encrypted_username` varchar(255) DEFAULT NULL,
`item_encrypted_credential` varchar(255) DEFAULT NULL,
`item_note` varchar(255) DEFAULT NULL,
`item_recipient` varchar(250) DEFAULT NULL,
`item_views` int(11) NOT NULL,
`item_view_limit` int(11) DEFAULT NULL,
`item_created_at` datetime NOT NULL DEFAULT current_timestamp(),
@ -1960,6 +1946,20 @@ CREATE TABLE `user_permissions` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `user_role_permissions`
--
DROP TABLE IF EXISTS `user_role_permissions`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `user_role_permissions` (
`user_role_id` int(11) NOT NULL,
`module_id` int(11) NOT NULL,
`user_role_permission_level` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `user_roles`
--
@ -1971,7 +1971,7 @@ CREATE TABLE `user_roles` (
`user_role_id` int(11) NOT NULL AUTO_INCREMENT,
`user_role_name` varchar(200) NOT NULL,
`user_role_description` varchar(200) DEFAULT NULL,
`user_role_is_admin` int(11) NOT NULL DEFAULT 0,
`user_role_is_admin` tinyint(1) NOT NULL DEFAULT 0,
`user_role_created_at` datetime NOT NULL DEFAULT current_timestamp(),
`user_role_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(),
`user_role_archived_at` datetime DEFAULT NULL,
@ -1979,17 +1979,6 @@ CREATE TABLE `user_roles` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `user_role_permissions`
--
DROP TABLE IF EXISTS `user_role_permissions`;
CREATE TABLE IF NOT EXISTS `user_role_permissions` (
`user_role_id` int(11) NOT NULL,
`module_id` int(11) NOT NULL,
`user_role_permission_level` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
--
-- Table structure for table `user_settings`
--
@ -2117,4 +2106,4 @@ CREATE TABLE `vendors` (
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2024-09-05 16:21:24
-- Dump completed on 2024-09-18 16:29:56