From b7091391c5d50d77ee1e277a0b7b868b0c28c03b Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Thu, 6 Aug 2015 00:00:55 -0500 Subject: [PATCH] upgrade: Fix error emails from upgrade, actually drop fields --- .../streams/core/0d6099a6-98ad7d55.cleanup.sql | 8 ++++---- .../streams/core/36f6b328-5cd0a25a.cleanup.sql | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/include/upgrader/streams/core/0d6099a6-98ad7d55.cleanup.sql b/include/upgrader/streams/core/0d6099a6-98ad7d55.cleanup.sql index 87d968fc0..dcc52a014 100644 --- a/include/upgrader/streams/core/0d6099a6-98ad7d55.cleanup.sql +++ b/include/upgrader/streams/core/0d6099a6-98ad7d55.cleanup.sql @@ -17,8 +17,8 @@ SET @s = (SELECT IF( AND table_schema = DATABASE() AND column_name = 'updated' ) > 0, - "SELECT 1", - "ALTER TABLE `%TABLE_PREFIX%team_member` DROP `updated`" + "ALTER TABLE `%TABLE_PREFIX%team_member` DROP `updated`", + "SELECT 1" )); PREPARE stmt FROM @s; EXECUTE stmt; @@ -31,8 +31,8 @@ SET @s = (SELECT IF( AND table_schema = DATABASE() AND column_name = 'views' ) > 0, - "SELECT 1", - "ALTER TABLE `%TABLE_PREFIX%faq` DROP `views`, DROP `score`" + "ALTER TABLE `%TABLE_PREFIX%faq` DROP `views`, DROP `score`", + "SELECT 1" )); PREPARE stmt FROM @s; EXECUTE stmt; diff --git a/include/upgrader/streams/core/36f6b328-5cd0a25a.cleanup.sql b/include/upgrader/streams/core/36f6b328-5cd0a25a.cleanup.sql index 800c81276..533991fb4 100644 --- a/include/upgrader/streams/core/36f6b328-5cd0a25a.cleanup.sql +++ b/include/upgrader/streams/core/36f6b328-5cd0a25a.cleanup.sql @@ -1,5 +1,16 @@ -ALTER TABLE `%TABLE_PREFIX%thread` - DROP COLUMN `tid`; +-- Drop `tid` from thread (if it exists) +SET @s = (SELECT IF( + (SELECT COUNT(*) + FROM INFORMATION_SCHEMA.COLUMNS + WHERE table_name = '%TABLE_PREFIX%thread' + AND table_schema = DATABASE() + AND column_name = 'tid' + ) > 0, + "ALTER TABLE `%TABLE_PREFIX%thread` DROP COLUMN `tid`", + "SELECT 1" +)); +PREPARE stmt FROM @s; +EXECUTE stmt; ALTER TABLE `%TABLE_PREFIX%thread_entry` DROP COLUMN `ticket_id`; -- GitLab