drop view mgn_all_views;
drop function mgn_drop_all_views ();
+----------------------------------------
+-- peers
+----------------------------------------
+ALTER TABLE peers ADD COLUMN shortname TEXT;
+ALTER TABLE peers ADD COLUMN hrn_root TEXT;
+
+----------------------------------------
+-- nodes
+----------------------------------------
+ALTER TABLE nodes ADD COLUMN node_type TEXT NOT NULL DEFAULT 'regular';
+
----------------------------------------
-- tag types
----------------------------------------
--- former slice_attribute_types had no 'category'
ALTER TABLE tag_types ADD COLUMN category TEXT NOT NULL DEFAULT 'slice/legacy';
---- append in tag_types the contents of nodenetwork_setting_types
+--- append in tag_types the contents of former nodenetwork_setting_types
INSERT INTO tag_types (tagname,description,min_role_id,category)
SELECT name,description,min_role_id,'interface/legacy' FROM interface_tag_types;
-- alter column name to reflect change
ALTER TABLE interface_tag RENAME interface_tag_type_id TO tag_type_id;
--- add contraint again
+-- add constraint again
ALTER TABLE interface_tag ADD CONSTRAINT interface_tag_tag_type_id_fkey
FOREIGN KEY (tag_type_id) references tag_types(tag_type_id) ;
node_tag_id serial PRIMARY KEY, -- ID
node_id integer REFERENCES nodes NOT NULL, -- node id
tag_type_id integer REFERENCES tag_types, -- tag type id
- tagvalue text -- value attached
+ value text -- value attached
) WITH OIDS;
---------- nodegroups table - start
-- nodegroup_id is preserved for conf_files and other references
-- former nodegroups table was (nodegroup_id,name,description)
--- new table is now (nodegroup_id, groupname, tag_type_id, tagvalue)
+-- new table is now (nodegroup_id, groupname, tag_type_id, value)
-- rename column
ALTER TABLE nodegroups RENAME name TO groupname;
ALTER TABLE nodegroups DROP COLUMN description;
---------- set the right tags so as to recover former nodegroups
-INSERT INTO node_tag (node_id, tag_type_id, tagvalue)
- SELECT node_id, tag_type_id, tagvalue FROM
+INSERT INTO node_tag (node_id, tag_type_id, value)
+ SELECT node_id, tag_type_id, value FROM
nodegroup_node LEFT JOIN nodegroups USING (nodegroup_id)
INNER JOIN mgn_site_nodegroup USING (groupname)
LEFT JOIN tag_types using (tagname);
---------- nodegroups table - conclusion
ALTER TABLE nodegroups ADD COLUMN tag_type_id INTEGER;
-ALTER TABLE nodegroups ADD COLUMN tagvalue TEXT;
+ALTER TABLE nodegroups ADD COLUMN value TEXT;
CREATE OR REPLACE VIEW mgn_nodegroups AS
- SELECT groupname, tag_types.tag_type_id, mgn_site_nodegroup.tagvalue
+ SELECT groupname, tag_types.tag_type_id, mgn_site_nodegroup.value
FROM nodegroups INNER JOIN mgn_site_nodegroup USING (groupname)
INNER JOIN tag_types USING (tagname);
UPDATE nodegroups SET tag_type_id = (SELECT tag_type_id FROM mgn_nodegroups WHERE nodegroups.groupname=mgn_nodegroups.groupname);
-UPDATE nodegroups SET tagvalue = (SELECT tagvalue FROM mgn_nodegroups WHERE nodegroups.groupname=mgn_nodegroups.groupname);
+UPDATE nodegroups SET value = (SELECT value FROM mgn_nodegroups WHERE nodegroups.groupname=mgn_nodegroups.groupname);
-- install corresponding constraints
ALTER TABLE nodegroups ADD CONSTRAINT nodegroups_tag_type_id_fkey
----------------------------------------
-- boot states
----------------------------------------
+-- create new ones
INSERT INTO boot_states (boot_state) VALUES ('safeboot');
INSERT INTO boot_states (boot_state) VALUES ('failboot');
INSERT INTO boot_states (boot_state) VALUES ('disabled');
INSERT INTO boot_states (boot_state) VALUES ('install');
INSERT INTO boot_states (boot_state) VALUES ('reinstall');
--- xxx need checking
---
--- boot boot
--- dbg failboot
--- diag safeboot
--- disable disabled
--- inst install
--- rins reinstall
--- new reinstall
--- rcnf failboot
-
-
+-- map old ones
UPDATE nodes SET boot_state='failboot' WHERE boot_state='dbg';
UPDATE nodes SET boot_state='safeboot' WHERE boot_state='diag';
UPDATE nodes SET boot_state='disabled' WHERE boot_state='disable';
UPDATE nodes SET boot_state='reinstall' WHERE boot_state='new';
UPDATE nodes SET boot_state='failboot' WHERE boot_state='rcnf';
--- one-by-one is safer
+-- delete old ones
DELETE FROM boot_states WHERE boot_state='dbg';
DELETE FROM boot_states WHERE boot_state='diag';
DELETE FROM boot_states WHERE boot_state='disable';