From 2f4a7efd027090f9ddff09f8e891a0ddb0d7fb4a Mon Sep 17 00:00:00 2001
From: Jared Hancock <gravydish@gmail.com>
Date: Fri, 22 Jun 2012 21:54:41 -0500
Subject: [PATCH] Make sure ip address fields support IPv6

---
 main.inc.php                              |  2 +-
 setup/inc/sql/aa4664af-b19dc97d.patch.sql | 23 +++++++++++++++++++++++
 setup/inc/sql/osticket-v1.7-mysql.sql     | 11 +++++------
 setup/inc/sql/osticket-v1.7-mysql.sql.md5 |  2 +-
 4 files changed, 30 insertions(+), 8 deletions(-)
 create mode 100644 setup/inc/sql/aa4664af-b19dc97d.patch.sql

diff --git a/main.inc.php b/main.inc.php
index 3660625d6..5184b250e 100644
--- a/main.inc.php
+++ b/main.inc.php
@@ -60,7 +60,7 @@
 
     #Current version && schema signature (Changes from version to version)
     define('THIS_VERSION','1.7-DPR4'); //Shown on admin panel
-    define('SCHEMA_SIGNATURE','aa4664afc3b43d4068eb2e82684fc28e'); //MD5 signature of the db schema. (used to trigger upgrades)
+    define('SCHEMA_SIGNATURE','b19dc97d19f7a30f59663c812d1f3ddc'); //MD5 signature of the db schema. (used to trigger upgrades)
 
     #load config info
     $configfile='';
diff --git a/setup/inc/sql/aa4664af-b19dc97d.patch.sql b/setup/inc/sql/aa4664af-b19dc97d.patch.sql
new file mode 100644
index 000000000..8b5ce9eb3
--- /dev/null
+++ b/setup/inc/sql/aa4664af-b19dc97d.patch.sql
@@ -0,0 +1,23 @@
+/**
+ * Change IP address columns to have sufficient room to store IPv6 address
+ *
+ * @version 1.7-rc1 ipv6-addresses
+ */
+
+ALTER TABLE `%TABLE_PREFIX%api_key`
+    CHANGE `ipaddr` `ipaddr` varchar(64) NOT NULL;
+
+ALTER TABLE `%TABLE_PREFIX%session`
+    CHANGE `user_id` `user_id` int(10) unsigned NOT NULL default '0'
+        COMMENT 'osTicket staff ID',
+    CHANGE `user_ip` `user_ip` varchar(64) NOT NULL;
+
+ALTER TABLE `%TABLE_PREFIX%syslog`
+    CHANGE `ip_address` `ip_address` varchar(64) NOT NULL;
+
+ALTER TABLE `%TABLE_PREFIX%ticket`
+    CHANGE `ip_address` `ip_address` varchar(64) NOT NULL default '';
+
+-- Finished with patch
+UPDATE `%TABLE_PREFIX%config`
+    SET `schema_signature`='b19dc97d19f7a30f59663c812d1f3ddc';
diff --git a/setup/inc/sql/osticket-v1.7-mysql.sql b/setup/inc/sql/osticket-v1.7-mysql.sql
index b8bb7ce26..7f29d024f 100644
--- a/setup/inc/sql/osticket-v1.7-mysql.sql
+++ b/setup/inc/sql/osticket-v1.7-mysql.sql
@@ -3,7 +3,7 @@ DROP TABLE IF EXISTS `%TABLE_PREFIX%api_key`;
 CREATE TABLE `%TABLE_PREFIX%api_key` (
   `id` int(10) unsigned NOT NULL auto_increment,
   `isactive` tinyint(1) NOT NULL default '1',
-  `ipaddr` varchar(16) NOT NULL,
+  `ipaddr` varchar(64) NOT NULL,
   `apikey` varchar(255) NOT NULL,
   `notes` text,
   `updated` datetime NOT NULL,
@@ -423,9 +423,8 @@ CREATE TABLE `%TABLE_PREFIX%session` (
   `session_data` longtext collate utf8_unicode_ci,
   `session_expire` datetime default NULL,
   `session_updated` datetime default NULL,
-  `user_id` int(10) unsigned NOT NULL default '0' COMMENT 'osTicket staff
-ID',
-  `user_ip` varchar(32) collate utf8_unicode_ci NOT NULL,
+  `user_id` int(10) unsigned NOT NULL default '0' COMMENT 'osTicket staff ID',
+  `user_ip` varchar(64) NOT NULL,
   `user_agent` varchar(255) collate utf8_unicode_ci NOT NULL,
   PRIMARY KEY  (`session_id`),
   KEY `updated` (`session_updated`),
@@ -497,7 +496,7 @@ CREATE TABLE `%TABLE_PREFIX%syslog` (
   `title` varchar(255) NOT NULL,
   `log` text NOT NULL,
   `logger` varchar(64) NOT NULL,
-  `ip_address` varchar(16) NOT NULL,
+  `ip_address` varchar(64) NOT NULL,
   `created` datetime NOT NULL,
   `updated` datetime NOT NULL,
   PRIMARY KEY  (`log_id`),
@@ -546,7 +545,7 @@ CREATE TABLE `%TABLE_PREFIX%ticket` (
   `subject` varchar(64) NOT NULL default '[no subject]',
   `phone` varchar(16) default NULL,
   `phone_ext` varchar(8) default NULL,
-  `ip_address` varchar(16) NOT NULL default '',
+  `ip_address` varchar(64) NOT NULL default '',
   `status` enum('open','closed') NOT NULL default 'open',
   `source` enum('Web','Email','Phone','API','Other') NOT NULL default
 'Other',
diff --git a/setup/inc/sql/osticket-v1.7-mysql.sql.md5 b/setup/inc/sql/osticket-v1.7-mysql.sql.md5
index 4bdfcd1ce..a1d99aa52 100644
--- a/setup/inc/sql/osticket-v1.7-mysql.sql.md5
+++ b/setup/inc/sql/osticket-v1.7-mysql.sql.md5
@@ -1 +1 @@
-aa4664afc3b43d4068eb2e82684fc28e
+b19dc97d19f7a30f59663c812d1f3ddc
-- 
GitLab