ALTER TABLE `mm_Page` CHANGE `isSecure` `isSecure` ENUM('n','y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'y';
ALTER TABLE `mm_DraftPage` CHANGE `isSecure` `isSecure` ENUM('n','y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'y';

UPDATE `mm_DPageOption` SET `value` = 'y' WHERE `name` = 'isSecure';
UPDATE `mm_PageOption` SET `value` = 'y' WHERE `name` = 'isSecure';
UPDATE `mm_DraftPageOption` SET `value` = 'y' WHERE `name` = 'isSecure';

DROP FUNCTION IF EXISTS fixContent;
DELIMITER $$$
CREATE FUNCTION fixContent(_content LONGTEXT)
RETURNS LONGTEXT
BEGIN
  DECLARE result LONGTEXT;
  SET result = REPLACE(_content, '{BASE_URL_HTTP}', '{BASE_URL_HTTPS}');
  SET result = REPLACE(result, 'http://www.mmua.org', 'https://www.mmua.org');
  RETURN result;
END $$$
DELIMITER ;

UPDATE `mm_Classified` SET
  `description` = fixContent(`description`),
  `contactDetails` = fixContent(`contactDetails`)
;

UPDATE `mm_Event` SET `description` = fixContent(`description`);
UPDATE `mm_News` SET `content` = fixContent(`content`);
UPDATE `mm_Post` SET `content` = fixContent(`content`);
UPDATE `mm_SideBlock` SET `content` = fixContent(`content`);
UPDATE `mm_SponsorCategory` SET `description` = fixContent(`description`);
UPDATE `mm_TradeShow` SET `description` = fixContent(`description`);
UPDATE `mm_TrainingOffering` SET `description` = fixContent(`description`), `moreInfo` = fixContent(`moreInfo`);
UPDATE `mm_HtmlBlockContent` SET `content` = fixContent(`content`), `rawContent` = fixContent(`rawContent`);
UPDATE `mm_DraftHtmlBlockContent` SET `content` = fixContent(`content`), `rawContent` = fixContent(`rawContent`);
UPDATE `mm_Settings` SET `value` = fixContent(`value`);
UPDATE `mm_Company` SET `websiteUrl` = fixContent(`websiteUrl`);

DROP FUNCTION IF EXISTS fixContent;