Initial DB Structure for Projects and Tasks with Ticket and Client Linkage

This commit is contained in:
johnnyq 2023-05-07 21:43:20 -04:00
parent 93d4f3ebce
commit 03e0dd8f5e
3 changed files with 82 additions and 4 deletions

View File

@ -1020,11 +1020,45 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) {
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.5.4'");
}
//if (CURRENT_DATABASE_VERSION == '0.5.4') {
if (CURRENT_DATABASE_VERSION == '0.5.4') {
//Insert queries here required to update to DB version 0.5.5
mysqli_query($mysqli, "CREATE TABLE `projects` (
`project_id` int(11) NOT NULL AUTO_INCREMENT,
`project_template` tinyint(1) NOT NULL DEFAULT 0,
`project_name` varchar(255) NOT NULL,
`project_description` text NULL DEFAULT NULL,
`project_created_at` datetime NOT NULL DEFAULT current_timestamp(),
`project_updated_at` datetime NULL DEFAULT NULL on update CURRENT_TIMESTAMP,
`project_archived_at` datetime NULL DEFAULT NULL,
`project_client_id` int(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`project_id`)
)");
mysqli_query($mysqli, "CREATE TABLE `tasks` (
`task_id` int(11) NOT NULL AUTO_INCREMENT,
`task_template` tinyint(1) NOT NULL DEFAULT 0,
`task_name` varchar(255) NOT NULL,
`task_description` text NULL DEFAULT NULL,
`task_finish_date` date NULL DEFAULT NULL,
`task_status` varchar(255) NULL DEFAULT NULL,
`task_completed_at` datetime NULL DEFAULT NULL,
`task_completed_by` int(11) NULL DEFAULT NULL,
`task_created_at` datetime NOT NULL DEFAULT current_timestamp(),
`task_updated_at` datetime NULL DEFAULT NULL on update CURRENT_TIMESTAMP,
`task_ticket_id` int(11) NULL DEFAULT NULL,
`task_project_id` int(11) NULL DEFAULT NULL,
PRIMARY KEY (`task_id`)
)");
// Then, update the database to the next sequential version
//mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.5.5'");
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.5.5'");
}
//if (CURRENT_DATABASE_VERSION == '0.5.5') {
//Insert queries here required to update to DB version 0.5.6
// Then, update the database to the next sequential version
//mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.5.6'");
//}
} else {

View File

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

46
db.sql
View File

@ -810,6 +810,26 @@ CREATE TABLE `products` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `projects`
--
DROP TABLE IF EXISTS `projects`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `projects` (
`project_id` int(11) NOT NULL AUTO_INCREMENT,
`project_template` tinyint(1) NOT NULL DEFAULT 0,
`project_name` varchar(255) NOT NULL,
`project_description` text DEFAULT NULL,
`project_created_at` datetime NOT NULL DEFAULT current_timestamp(),
`project_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(),
`project_archived_at` datetime DEFAULT NULL,
`project_client_id` int(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`project_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `quotes`
--
@ -1267,6 +1287,30 @@ CREATE TABLE `tags` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `tasks`
--
DROP TABLE IF EXISTS `tasks`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `tasks` (
`task_id` int(11) NOT NULL AUTO_INCREMENT,
`task_template` tinyint(1) NOT NULL DEFAULT 0,
`task_name` varchar(255) NOT NULL,
`task_description` text DEFAULT NULL,
`task_finish_date` date DEFAULT NULL,
`task_status` varchar(255) DEFAULT NULL,
`task_completed_at` datetime DEFAULT NULL,
`task_completed_by` int(11) DEFAULT NULL,
`task_created_at` datetime NOT NULL DEFAULT current_timestamp(),
`task_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(),
`task_ticket_id` int(11) DEFAULT NULL,
`task_project_id` int(11) DEFAULT NULL,
PRIMARY KEY (`task_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `taxes`
--
@ -1541,4 +1585,4 @@ CREATE TABLE `vendors` (
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2023-05-07 21:08:34
-- Dump completed on 2023-05-07 21:42:46