Bug 31028: Add `tickets` and `ticket_updates` tables
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Tue, 25 Oct 2022 11:59:10 +0000 (12:59 +0100)
committerTomas Cohen Arazi <tomascohen@theke.io>
Mon, 6 Mar 2023 14:20:09 +0000 (11:20 -0300)
This patch adds the new `tickets` and `ticket_updates` tables for
tracking catalog concern tickets.

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Helen Oliver <HOliver@tavi-port.ac.uk>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
installer/data/mysql/atomicupdate/bug_31028.pl [new file with mode: 0644]
installer/data/mysql/kohastructure.sql

diff --git a/installer/data/mysql/atomicupdate/bug_31028.pl b/installer/data/mysql/atomicupdate/bug_31028.pl
new file mode 100644 (file)
index 0000000..79f6ccd
--- /dev/null
@@ -0,0 +1,48 @@
+use Modern::Perl;
+
+return {
+    bug_number => "31028",
+    description => "Add a way to record users concerns about catalog records",
+    up => sub {
+        my ($args) = @_;
+        my ($dbh, $out) = @$args{qw(dbh out)};
+        unless ( TableExists('tickets') ) {
+            $dbh->do(q{
+                CREATE TABLE IF NOT EXISTS `tickets` (
+                  `id` int(11) NOT NULL auto_increment COMMENT 'primary key',
+                  `reporter_id` int(11) NOT NULL DEFAULT 0 COMMENT 'id of the patron who reported the ticket',
+                  `reported_date` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'date and time this ticket was reported',
+                  `title` text NOT NULL COMMENT 'ticket title',
+                  `body` text NOT NULL COMMENT 'ticket details',
+                  `resolver_id` int(11) DEFAULT NULL COMMENT 'id of the user who resolved the ticket',
+                  `resolved_date` datetime DEFAULT NULL COMMENT 'date and time this ticket was resolved',
+                  `biblio_id` int(11) DEFAULT NULL COMMENT 'id of biblio linked',
+                  PRIMARY KEY(`id`),
+                  CONSTRAINT `tickets_ibfk_1` FOREIGN KEY (`reporter_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
+                  CONSTRAINT `tickets_ibfk_2` FOREIGN KEY (`resolver_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
+                  CONSTRAINT `tickets_ibfk_3` FOREIGN KEY (`biblio_id`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
+                ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+            });
+
+            say $out "Added new table 'tickets'";
+        }
+
+        unless ( TableExists('ticket_updates') ) {
+            $dbh->do(q{
+                CREATE TABLE IF NOT EXISTS `ticket_updates` (
+                  `id` int(11) NOT NULL auto_increment COMMENT 'primary key',
+                  `ticket_id` int(11) NOT NULL COMMENT 'id of catalog ticket the update relates to',
+                  `user_id` int(11) NOT NULL DEFAULT 0 COMMENT 'id of the user who logged the update',
+                  `public` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'boolean flag to denote whether this update is public',
+                  `date` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'date and time this update was logged',
+                  `message` text NOT NULL COMMENT 'update message content',
+                  PRIMARY KEY(`id`),
+                  CONSTRAINT `ticket_updates_ibfk_1` FOREIGN KEY (`ticket_id`) REFERENCES `tickets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
+                  CONSTRAINT `ticket_updates_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
+                ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+            });
+
+            say $out "Added new table 'ticket_updates'";
+        }
+    }
+}
index 03dd476..d87b9e9 100644 (file)
@@ -5736,6 +5736,49 @@ CREATE TABLE `tags_index` (
 /*!40101 SET character_set_client = @saved_cs_client */;
 
 --
+-- Table structure for table `tickets`
+--
+
+DROP TABLE IF EXISTS `tickets`;
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE IF NOT EXISTS `tickets` (
+  `id` int(11) NOT NULL auto_increment COMMENT 'primary key',
+  `reporter_id` int(11) NOT NULL DEFAULT 0 COMMENT 'id of the patron who reported the ticket',
+  `reported_date` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'date and time this ticket was reported',
+  `title` text NOT NULL COMMENT 'ticket title',
+  `body` text NOT NULL COMMENT 'ticket details',
+  `resolver_id` int(11) DEFAULT NULL COMMENT 'id of the user who resolved the ticket',
+  `resolved_date` datetime DEFAULT NULL COMMENT 'date and time this ticket was resolved',
+  `biblio_id` int(11) DEFAULT NULL COMMENT 'id of biblio linked',
+  PRIMARY KEY(`id`),
+  CONSTRAINT `tickets_ibfk_1` FOREIGN KEY (`reporter_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
+  CONSTRAINT `tickets_ibfk_2` FOREIGN KEY (`resolver_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
+  CONSTRAINT `tickets_ibfk_3` FOREIGN KEY (`biblio_id`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Table structure for table `ticket_updates`
+--
+
+DROP TABLE IF EXISTS `ticket_updates`;
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE IF NOT EXISTS `ticket_updates` (
+  `id` int(11) NOT NULL auto_increment COMMENT 'primary key',
+  `ticket_id` int(11) NOT NULL COMMENT 'id of catalog ticket the update relates to',
+  `user_id` int(11) NOT NULL DEFAULT 0 COMMENT 'id of the user who logged the update',
+  `public` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'boolean flag to denote whether this update is public',
+  `date` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'date and time this update was logged',
+  `message` text NOT NULL COMMENT 'update message content',
+  PRIMARY KEY(`id`),
+  CONSTRAINT `ticket_updates_ibfk_1` FOREIGN KEY (`ticket_id`) REFERENCES `tickets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
+  CONSTRAINT `ticket_updates_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
 -- Table structure for table `tmp_holdsqueue`
 --