hs.hsadmin/hsarback/database/database_update.sql
2022-08-10 13:25:27 +02:00

86 lines
6.4 KiB
SQL

DROP VIEW ipconfig;
ALTER TABLE packet
ALTER COLUMN packet_name TYPE VARCHAR(6);
ALTER TABLE packet
ALTER COLUMN hive_id DROP NOT NULL;
UPDATE packet SET packet_name='vm10' || substr(packet_name,4,2) WHERE packet_name LIKE 'srv%';
CREATE VIEW ipconfig AS
SELECT DISTINCT ON (theunion.ipv4) theunion.ipv4,
theunion.name,
theunion.alias,
theunion.hivename
FROM ( SELECT h.hive_name AS hivename,
ip.inet_addr AS ipv4,
'eth0:'::text || p.packet_name::text AS alias,
p.packet_name AS name,
2 AS prio
FROM inet_addr ip
JOIN packet p ON p.cur_inet_addr_id = ip.inet_addr_id
JOIN hive h ON h.hive_id = p.hive_id
UNION
SELECT h.hive_name AS hivename,
ip.inet_addr AS ipv4,
'eth0'::text AS alias,
h.hive_name AS name,
1 AS prio
FROM inet_addr ip
JOIN hive h ON h.inet_addr_id = ip.inet_addr_id
ORDER BY 2, 5) theunion;
INSERT INTO basepacket (basepacket_code, description, sorting, valid, article_number)
VALUES ('SRV/CLD', 'Cloud Server', 0, true, 3000);
INSERT INTO basecomponent (basecomponent_code, description, sorting, valid)
VALUES ('BANDWIDTH', 'Bandbreite 95/5 (Mbit/s)', 0, true);
INSERT INTO basecomponent (basecomponent_code, description, sorting, valid)
VALUES ('SLAINFR8H', 'HS Ext. Support (24x7 8h) for Infrastructure', 0, true);
INSERT INTO basecomponent (basecomponent_code, description, sorting, valid)
VALUES ('SLAINFR4H', 'HS Ext. Support (24x7 4h) for Infrastructure', 0, true);
INSERT INTO basecomponent (basecomponent_code, description, sorting, valid)
VALUES ('SLAINFR2H', 'HS Ext. Support (24x7 2h) for Infrastructure', 0, true);
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 1, 102400000, 1, 1, 0, false, 3011 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='CPU';
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 1024, 102400000, 1024, 1024, 0, false, 3012 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='RAM';
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 0, 102400000, 250, 250, 0, false, 3013 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='TRAFFIC';
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 0, 1000, 0, 1, 0, false, 3017 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='BANDWIDTH';
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 25600, 102400000, 25600, 25600, 0, false, 3014 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='QUOTA';
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 0, 102400000, 0, 256000, 0, false, 3015 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='STORAGE';
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 1, 1, 1, 1, 0, false, 3136 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='SLABASIC';
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 0, 1, 0, 1, 0, false, 3122 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='SLAINFR8H';
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 0, 1, 0, 1, 0, false, 3125 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='SLAINFR4H';
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 0, 1, 0, 1, 0, false, 3151 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='SLAINFR2H';
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 0, 1000, 0, 1, 0, false, 2017 FROM basepacket, basecomponent WHERE basepacket_code='SRV/MGD' AND basecomponent_code='BANDWIDTH';
UPDATE component SET min_quantity=0 WHERE component_id=38; -- min. Traffic für Managed Server auf 0
INSERT INTO price (article_number, price, vat, price_list) VALUES (3011, 15, 19.0, 1);
INSERT INTO price (article_number, price, vat, price_list) VALUES (3012, 5, 19.0, 1);
INSERT INTO price (article_number, price, vat, price_list) VALUES (3013, 5, 19.0, 1);
INSERT INTO price (article_number, price, vat, price_list) VALUES (3014, 5, 19.0, 1);
INSERT INTO price (article_number, price, vat, price_list) VALUES (3015, 5, 19.0, 1);
INSERT INTO price (article_number, price, vat, price_list) VALUES (3017, 2, 19.0, 1);
INSERT INTO price (article_number, price, vat, price_list) VALUES (3136, 10, 19.0, 1);
INSERT INTO price (article_number, price, vat, price_list) VALUES (3122, 40, 19.0, 1);
INSERT INTO price (article_number, price, vat, price_list) VALUES (3125, 80, 19.0, 1);
INSERT INTO price (article_number, price, vat, price_list) VALUES (3151, 160, 19.0, 1);
INSERT INTO price (article_number, price, vat, price_list) VALUES (2017, 2, 19.0, 1);