ALTER TABLE qs_Page
  ADD `showSideBlock` ENUM('y', 'n') NOT NULL DEFAULT "y" AFTER `showInDropdowns`;

ALTER TABLE qs_DraftPage
ADD `showSideBlock` ENUM('y', 'n') NOT NULL DEFAULT "y" AFTER `showInDropdowns`;

INSERT INTO qs_DPageOption (`name`, `title`, `show`, `value`, `sorter`) VALUES
('showSideBlock', 'Show SideBlocks', 'n', 'y', 17);

SET @showInDropdowns := (SELECT `value` FROM qs_DPageOption WHERE `name` = "showInDropdowns" LIMIT 1);

INSERT INTO qs_PageOption
SELECT
  NULL AS `id`,
  p.id AS `idPage`,
  "showSideBlock" AS `name`,
  "n" AS `show`,
  IF(po.id IS NULL, @showInDropdowns, po.value) AS `value`
FROM qs_Page p
LEFT JOIN qs_PageOption po ON po.idPage = p.id AND po.name = "showInDropdowns";

INSERT INTO qs_DraftPageOption
  SELECT
    NULL AS `id`,
    p.id AS `idPage`,
    "showSideBlock" AS `name`,
    "n" AS `show`,
    IF(po.id IS NULL, @showInDropdowns, po.value) AS `value`
  FROM qs_Page p
    LEFT JOIN qs_DraftPageOption po ON po.idPage = p.id AND po.name = "showInDropdowns";
