From 1e24585c7b1385724e860d34e3c617e3bb852244 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Mon, 31 Mar 2014 10:55:57 -0500
Subject: [PATCH] Add database migration for custom list properties

---
 include/class.dynamic_forms.php                        |  4 ++--
 include/upgrader/streams/core.sig                      |  2 +-
 ...-4323a6a8.patch.sql => f5692e24-0217a429.patch.sql} | 10 ++++++++--
 ...24-4323a6a8.task.php => f5692e24-0217a429.task.sql} |  0
 setup/inc/streams/core/install-mysql.sql               |  3 ++-
 5 files changed, 13 insertions(+), 6 deletions(-)
 rename include/upgrader/streams/core/{f5692e24-4323a6a8.patch.sql => f5692e24-0217a429.patch.sql} (94%)
 rename include/upgrader/streams/core/{f5692e24-4323a6a8.task.php => f5692e24-0217a429.task.sql} (100%)

diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php
index d9914e51d..45fb90e21 100644
--- a/include/class.dynamic_forms.php
+++ b/include/class.dynamic_forms.php
@@ -906,7 +906,7 @@ class DynamicListItem extends VerySimpleModel {
 
     function getConfiguration() {
         if (!$this->_config) {
-            $this->_config = $this->get('configuration');
+            $this->_config = $this->get('properties');
             if (is_string($this->_config))
                 $this->_config = JsonDataParser::parse($this->_config);
             elseif (!$this->_config)
@@ -922,7 +922,7 @@ class DynamicListItem extends VerySimpleModel {
             $errors = array_merge($errors, $field->errors());
         }
         if (count($errors) === 0)
-            $this->set('configuration', JsonDataEncoder::encode($config));
+            $this->set('properties', JsonDataEncoder::encode($config));
 
         return count($errors) === 0;
     }
diff --git a/include/upgrader/streams/core.sig b/include/upgrader/streams/core.sig
index 19fc2a074..e230066fc 100644
--- a/include/upgrader/streams/core.sig
+++ b/include/upgrader/streams/core.sig
@@ -1 +1 @@
-4323a6a81c35efbf7722b7fc4e475440
+0217a4299f37124fb4fb352635bae1b4
diff --git a/include/upgrader/streams/core/f5692e24-4323a6a8.patch.sql b/include/upgrader/streams/core/f5692e24-0217a429.patch.sql
similarity index 94%
rename from include/upgrader/streams/core/f5692e24-4323a6a8.patch.sql
rename to include/upgrader/streams/core/f5692e24-0217a429.patch.sql
index c3bc8ccc3..8625f64ca 100644
--- a/include/upgrader/streams/core/f5692e24-4323a6a8.patch.sql
+++ b/include/upgrader/streams/core/f5692e24-0217a429.patch.sql
@@ -1,6 +1,6 @@
 /**
  * @version v1.8.2
- * @signature 4323a6a81c35efbf7722b7fc4e475440
+ * @signature 0217a4299f37124fb4fb352635bae1b4
  * @title Add client login feature
  *
  */
@@ -116,7 +116,13 @@ UPDATE `%TABLE_PREFIX%content` SET `content_id` = LAST_INSERT_ID()
 DELETE FROM `%TABLE_PREFIX%email_template`
     WHERE `code_name` IN ('staff.pwreset', 'user.accesslink');
 
+ALTER TABLE `%TABLE_PREFIX%form`
+    CHANGE `type` `type` varchar(8) NOT NULL DEFAULT 'G';
+
+ALTER TABLE `%TABLE_PREFIX%list_items`
+    ADD `properties` text AFTER `sort`;
+
 -- Finished with patch
 UPDATE `%TABLE_PREFIX%config`
-    SET `value` = '4323a6a81c35efbf7722b7fc4e475440'
+    SET `value` = '0217a4299f37124fb4fb352635bae1b4'
     WHERE `key` = 'schema_signature' AND `namespace` = 'core';
diff --git a/include/upgrader/streams/core/f5692e24-4323a6a8.task.php b/include/upgrader/streams/core/f5692e24-0217a429.task.sql
similarity index 100%
rename from include/upgrader/streams/core/f5692e24-4323a6a8.task.php
rename to include/upgrader/streams/core/f5692e24-0217a429.task.sql
diff --git a/setup/inc/streams/core/install-mysql.sql b/setup/inc/streams/core/install-mysql.sql
index c15a946a6..e330bf7ff 100644
--- a/setup/inc/streams/core/install-mysql.sql
+++ b/setup/inc/streams/core/install-mysql.sql
@@ -96,7 +96,7 @@ INSERT INTO `%TABLE_PREFIX%config` (`namespace`, `key`, `value`) VALUES
 DROP TABLE IF EXISTS `%TABLE_PREFIX%form`;
 CREATE TABLE `%TABLE_PREFIX%form` (
     `id` int(11) unsigned NOT NULL auto_increment,
-    `type` char(1) NOT NULL DEFAULT 'G',
+    `type` varchar(8) NOT NULL DEFAULT 'G',
     `deletable` tinyint(1) NOT NULL DEFAULT 1,
     `title` varchar(255) NOT NULL,
     `instructions` varchar(512),
@@ -167,6 +167,7 @@ CREATE TABLE `%TABLE_PREFIX%list_items` (
     -- extra value such as abbreviation
     `extra` varchar(255),
     `sort` int(11) NOT NULL DEFAULT 1,
+    `properties` text,
     PRIMARY KEY (`id`),
     KEY `list_item_lookup` (`list_id`)
 ) DEFAULT CHARSET=utf8;
-- 
GitLab