From 92ad0b9ff4103c82f14230683f1d20d5fe354aec Mon Sep 17 00:00:00 2001
From: Peter Rotich <peter@osticket.com>
Date: Mon, 13 Aug 2012 17:24:12 -0400
Subject: [PATCH] Database patch for nested help topics

---
 include/upgrader/sql/2e7531a2-d0e37dca.patch.sql | 14 ++++++++++++++
 main.inc.php                                     |  2 +-
 setup/inc/sql/osTicket-mysql.sql                 |  2 ++
 setup/inc/sql/osTicket-mysql.sql.md5             |  2 +-
 4 files changed, 18 insertions(+), 2 deletions(-)
 create mode 100644 include/upgrader/sql/2e7531a2-d0e37dca.patch.sql

diff --git a/include/upgrader/sql/2e7531a2-d0e37dca.patch.sql b/include/upgrader/sql/2e7531a2-d0e37dca.patch.sql
new file mode 100644
index 000000000..7864eb331
--- /dev/null
+++ b/include/upgrader/sql/2e7531a2-d0e37dca.patch.sql
@@ -0,0 +1,14 @@
+/**
+ *  Add help topic nesting support.
+ *
+ * @version 1.7-rc2 - nested help topics.
+ */
+
+-- Add help topic parent id.
+ALTER TABLE  `%TABLE_PREFIX%help_topic` 
+    ADD  `topic_pid` INT UNSIGNED NOT NULL DEFAULT  '0' AFTER  `topic_id` ,
+    ADD INDEX (  `topic_pid` );
+
+-- Finished with patch
+UPDATE `%TABLE_PREFIX%config`
+    SET `schema_signature`='d0e37dca324648f1ce2d10528a6026d4';
diff --git a/main.inc.php b/main.inc.php
index 6fd31bbbd..f668cdf44 100644
--- a/main.inc.php
+++ b/main.inc.php
@@ -63,7 +63,7 @@
 
     #Current version && schema signature (Changes from version to version)
     define('THIS_VERSION','1.7-RC1'); //Shown on admin panel
-    define('SCHEMA_SIGNATURE','2e7531a201b5b8650dcd43681a832ebd'); //MD5 signature of the db schema. (used to trigger upgrades)
+    define('SCHEMA_SIGNATURE','d0e37dca324648f1ce2d10528a6026d4'); //MD5 signature of the db schema. (used to trigger upgrades)
 
     #load config info
     $configfile='';
diff --git a/setup/inc/sql/osTicket-mysql.sql b/setup/inc/sql/osTicket-mysql.sql
index 21acfcfe8..5cfba00d6 100644
--- a/setup/inc/sql/osTicket-mysql.sql
+++ b/setup/inc/sql/osTicket-mysql.sql
@@ -375,6 +375,7 @@ INSERT INTO `%TABLE_PREFIX%group_dept_access` (`group_id`, `dept_id`) VALUES
 DROP TABLE IF EXISTS `%TABLE_PREFIX%help_topic`;
 CREATE TABLE `%TABLE_PREFIX%help_topic` (
   `topic_id` int(11) unsigned NOT NULL auto_increment,
+  `topic_pid` int(10) unsigned NOT NULL default '0',
   `isactive` tinyint(1) unsigned NOT NULL default '1',
   `ispublic` tinyint(1) unsigned NOT NULL default '1',
   `noautoresp` tinyint(3) unsigned NOT NULL default '0',
@@ -389,6 +390,7 @@ CREATE TABLE `%TABLE_PREFIX%help_topic` (
   `updated` datetime NOT NULL,
   PRIMARY KEY  (`topic_id`),
   UNIQUE KEY `topic` (`topic`),
+  KEY `topic_pid` (`topic_pid`),
   KEY `priority_id` (`priority_id`),
   KEY `dept_id` (`dept_id`),
   KEY `staff_id` (`staff_id`,`team_id`),
diff --git a/setup/inc/sql/osTicket-mysql.sql.md5 b/setup/inc/sql/osTicket-mysql.sql.md5
index ad088e947..63d2ce443 100644
--- a/setup/inc/sql/osTicket-mysql.sql.md5
+++ b/setup/inc/sql/osTicket-mysql.sql.md5
@@ -1 +1 @@
-2e7531a201b5b8650dcd43681a832ebd
+d0e37dca324648f1ce2d10528a6026d4
-- 
GitLab