1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
-- This code is required because of github issue #3588
-- The essence of that issue: when creating a new database,
-- scripts template_menu.sql and template_menu3.sql fail.
-- This script doesn't assume as much about the context of the menu
-- as the aforementioned scripts do. The most important thing
-- (being the reason the other scripts fail) is that this script
-- explicitly "creates room" for each node to be inserted into the menu
-- by "freeing up" the position in the menu this script wants to insert
-- the menu item into.
DO $$
BEGIN
-- Create room to insert the nodes
PERFORM 1 FROM menu_node
WHERE id = 29;
IF NOT FOUND THEN
UPDATE menu_node
SET position = position + 1
WHERE position >= 18 AND parent = 156;
INSERT INTO menu_node(id, parent, position, label)
VALUES (29, 156, 18, 'Payment'); -- printPayment.html
INSERT INTO menu_attribute(id, node_id, attribute, value)
VALUES
(256, 29, 'action', 'display'),
(257, 29, 'format', 'html'),
(258, 29, 'module', 'template.pl'),
(259, 29, 'template_name', 'printPayment');
END IF;
PERFORM 1 FROM menu_node
WHERE id = 30;
IF NOT FOUND THEN
UPDATE menu_node
SET position = position + 1
WHERE position >= 18 AND parent = 172;
INSERT INTO menu_node(id, parent, position, label)
VALUES (30, 172, 18, 'Check Base'); -- check_base.tex
INSERT INTO menu_attribute(id, node_id, attribute, value)
VALUES
(260, 30, 'action', 'display'),
(261, 30, 'format', 'tex'),
(262, 30, 'module', 'template.pl'),
(267, 30, 'template_name', 'check_base');
END IF;
PERFORM 1 FROM menu_node
WHERE id = 31;
IF NOT FOUND THEN
UPDATE menu_node
SET position = position + 1
WHERE position >= 19 AND parent = 172;
INSERT INTO menu_node(id, parent, position, label)
VALUES (31, 172, 19, 'Multiple Checks'); -- check_multiple.tex
INSERT INTO menu_attribute(id, node_id, attribute, value)
VALUES
(289, 31, 'action', 'display'),
(290, 31, 'format', 'tex'),
(291, 31, 'module', 'template.pl'),
(292, 31, 'template_name', 'check_multiple');
END IF;
PERFORM 1 FROM menu_node
WHERE id = 32;
IF NOT FOUND THEN
UPDATE menu_node
SET position = position + 1
WHERE position >= 20 AND parent = 172;
INSERT INTO menu_node(id, parent, position, label)
VALUES (32, 172, 20, 'Envelope'); -- envelope
INSERT INTO menu_attribute(id, node_id, attribute, value)
VALUES
(293, 32, 'action', 'display'),
(294, 32, 'format', 'tex'),
(295, 32, 'module', 'template.pl'),
(296, 32, 'template_name', 'envelope');
END IF;
PERFORM 1 FROM menu_node
WHERE id = 33;
IF NOT FOUND THEN
UPDATE menu_node
SET position = position + 1
WHERE position >= 21 AND parent = 172;
INSERT INTO menu_node(id, parent, position, label)
VALUES (33, 172, 21, 'Shipping Label'); -- shipping_label.tex
INSERT INTO menu_attribute(id, node_id, attribute, value)
VALUES
(297, 33, 'action', 'display'),
(298, 33, 'format', 'tex'),
(299, 33, 'module', 'template.pl'),
(300, 33, 'template_name', 'shipping_label');
END IF;
END;
$$ LANGUAGE plpgsql;
|