Move Document Versions to a seperate table much more efficient and allow to reference same document using a link Note this update will delete previous document versions

This commit is contained in:
johnnyq
2025-06-17 17:58:20 -04:00
parent 84437a2732
commit 85e1515080
8 changed files with 176 additions and 104 deletions

22
db.sql
View File

@@ -830,6 +830,25 @@ CREATE TABLE `document_files` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `document_versions`
--
DROP TABLE IF EXISTS `document_versions`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `document_versions` (
`document_version_id` int(11) NOT NULL AUTO_INCREMENT,
`document_version_name` varchar(200) NOT NULL,
`document_version_description` text DEFAULT NULL,
`document_version_content` longtext NOT NULL,
`document_version_created_by` int(11) DEFAULT 0,
`document_version_created_at` datetime NOT NULL,
`document_version_document_id` int(11) NOT NULL,
PRIMARY KEY (`document_version_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `documents`
--
@@ -844,7 +863,6 @@ CREATE TABLE `documents` (
`document_content` longtext NOT NULL,
`document_content_raw` longtext NOT NULL,
`document_important` tinyint(1) NOT NULL DEFAULT 0,
`document_parent` int(11) NOT NULL DEFAULT 0,
`document_client_visible` int(11) NOT NULL DEFAULT 1,
`document_created_at` datetime NOT NULL DEFAULT current_timestamp(),
`document_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(),
@@ -2504,4 +2522,4 @@ CREATE TABLE `vendors` (
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2025-06-13 15:50:44
-- Dump completed on 2025-06-17 17:56:40