Skip to content
Snippets Groups Projects
Commit 6268c338 authored by Peter Rotich's avatar Peter Rotich
Browse files

bug: Make sure properties field exist

Add ticket status properties field before loading init data.
parent d3fff36b
No related branches found
No related tags found
No related merge requests found
......@@ -4,4 +4,7 @@ DELETE FROM `%TABLE_PREFIX%config`
DELETE FROM `%TABLE_PREFIX%ticket_status`
WHERE `state` = 'resolved';
ALTER TABLE `%TABLE_PREFIX%ticket_status`
DROP `notes`;
OPTIMIZE TABLE `%TABLE_PREFIX%ticket_status`;
......@@ -18,10 +18,19 @@ UPDATE `%TABLE_PREFIX%ticket` t1
SET t1.status_id = @statusId
WHERE t2.state='resolved';
-- add properties field
ALTER TABLE `%TABLE_PREFIX%ticket_status`
ADD `properties` TEXT NOT NULL AFTER `sort`,
-- add properties field IF it doesn't exist
SET @s = (SELECT IF(
(SELECT COUNT(*)
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = '%TABLE_PREFIX%ticket_status'
AND table_schema = DATABASE()
AND column_name = 'properties'
) > 0,
"SELECT 1",
"ALTER TABLE `%TABLE_PREFIX%ticket_status` ADD `properties` text NOT NULL AFTER `sort`"
));
PREPARE stmt FROM @s;
EXECUTE stmt;
UPDATE `%TABLE_PREFIX%ticket_status` s
INNER JOIN `ost_config` c
......
......@@ -51,6 +51,7 @@ CREATE TABLE IF NOT EXISTS `%TABLE_PREFIX%ticket_status` (
`mode` int(11) unsigned NOT NULL DEFAULT '0',
`flags` int(11) unsigned NOT NULL DEFAULT '0',
`sort` int(11) unsigned NOT NULL DEFAULT '0',
`properties` text NOT NULL,
`notes` text NOT NULL,
`created` datetime NOT NULL,
`updated` datetime NOT NULL,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment