diff --git a/include/upgrader/streams/core/d51f303a-dad45ca2.patch.sql b/include/upgrader/streams/core/d51f303a-dad45ca2.patch.sql
index 19ddac83bf11b1d262c167e6f73b190db63babb7..936b3b0c2273a18e9a9bdd9410cd321121cb1ed1 100644
--- a/include/upgrader/streams/core/d51f303a-dad45ca2.patch.sql
+++ b/include/upgrader/streams/core/d51f303a-dad45ca2.patch.sql
@@ -156,21 +156,9 @@ UPDATE `%TABLE_PREFIX%canned_response`
         '>', '>'),
         '\n', '<br/>');
 
--- Migrate ticket-thread to HTML
--- XXX: Migrate & -> &amp; ? -- the problem is that there's a fix in 1.7.1
--- that properly encodes these characters, so encoding & would mean possible
--- double encoding.
-UPDATE `%TABLE_PREFIX%ticket_thread`
-    SET `body` = REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
-        `body`,
-        '\r', ''),
-        '\n ', '\n'),
-        '\n\n\n', '\n\n'),
-        '\n\n\n', '\n\n'),
-        '\n\n\n', '\n\n'),
-        '<', '&lt;'),
-        '>', '&gt;'),
-        '\n', '<br/>');
+-- Mark all thread entries as text
+ALTER TABLE `%TABLE_PREFIX%ticket_thread`
+  ADD `format` varchar(16) NOT NULL default 'text' AFTER `body`;
 
 -- Finished with patch
 UPDATE `%TABLE_PREFIX%config`
diff --git a/include/upgrader/streams/core/f5692e24-4323a6a8.patch.sql b/include/upgrader/streams/core/f5692e24-4323a6a8.patch.sql
index ee2296eb5754404acf176b006b250529554a3f55..a75a8372d3bbf205d9d85446a59ae923076f0075 100644
--- a/include/upgrader/streams/core/f5692e24-4323a6a8.patch.sql
+++ b/include/upgrader/streams/core/f5692e24-4323a6a8.patch.sql
@@ -136,6 +136,25 @@ UPDATE `%TABLE_PREFIX%content` SET `content_id` = LAST_INSERT_ID()
 DELETE FROM `%TABLE_PREFIX%email_template`
     WHERE `code_name` IN ('staff.pwreset', 'user.accesslink');
 
+-- The original patch for d51f303a-dad45ca2.patch.sql migrated all the
+-- thread entries from text to html. Now that the format column exists in
+-- the ticket_thread table, we opted to retroactively add the format column
+-- to the dad45ca2 patch. Therefore, anyone upgrading from osTicket < 1.8.0
+-- to v1.8.2 and further will alreay have a `format` column when they arrive
+-- at this patch. In such a case, we'll just change the default to 'html'
+SET @s = (SELECT IF(
+    (SELECT COUNT(*)
+        FROM INFORMATION_SCHEMA.COLUMNS
+        WHERE table_name = '%TABLE_PREFIX%ticket_thread'
+        AND table_schema = DATABASE()
+        AND column_name = 'format'
+    ) > 0,
+    "ALTER TABLE `%TABLE_PREFIX%ticket_thread` CHANGE `format` `format` varchar(16) NOT NULL default 'html'",
+    "ALTER TABLE `%TABLE_PREFIX%ticket_thread` ADD `format` varchar(16) NOT NULL default 'html' AFTER `body`"
+));
+PREPARE stmt FROM @s;
+EXECUTE stmt;
+
 -- Finished with patch
 UPDATE `%TABLE_PREFIX%config`
     SET `value` = '4323a6a81c35efbf7722b7fc4e475440'