X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=planetlab4.sql;h=555ee288b7840688f1e872920bbc355592c391fa;hb=1600712a2312d824ade8c8a688e1dee9a426a68e;hp=e657946d9c2408d62f3f5045f0fd15bc58e8d1cb;hpb=c7b7fb7f13aaa1da283f02ad5a20293746508b8c;p=plcapi.git diff --git a/planetlab4.sql b/planetlab4.sql index e657946..555ee28 100644 --- a/planetlab4.sql +++ b/planetlab4.sql @@ -9,7 +9,7 @@ -- -- Copyright (C) 2006 The Trustees of Princeton University -- --- $Id: planetlab4.sql,v 1.80 2007/08/01 17:01:01 tmack Exp $ +-- $Id: planetlab4.sql 793 2007-08-28 15:21:17Z thierry $ -- SET client_encoding = 'UNICODE'; @@ -37,7 +37,7 @@ CREATE TABLE plc_db_version ( subversion integer NOT NULL DEFAULT 0 ) WITH OIDS; -INSERT INTO plc_db_version (version, subversion) VALUES (4, 2); +INSERT INTO plc_db_version (version, subversion) VALUES (4, 8); -------------------------------------------------------------------------------- -- Accounts @@ -450,6 +450,67 @@ array_accum(nodenetwork_id) AS nodenetwork_ids FROM nodenetworks_ordered GROUP BY node_id; +-------------------------------------------------------------------------------- +-- Nodenetwork setting types and nodenetworks settings +-------------------------------------------------------------------------------- + +CREATE TABLE nodenetwork_setting_types ( + nodenetwork_setting_type_id serial PRIMARY KEY, + -- Setting Type Identifier + name text UNIQUE NOT NULL, -- Setting Name + description text, -- Optional Description + category text NOT NULL, -- Category, e.g. Wifi, or whatever + min_role_id integer references roles -- If set, minimal role required +) WITH OIDS; + +CREATE TABLE nodenetwork_setting ( + nodenetwork_setting_id serial PRIMARY KEY, -- Nodenetwork Setting Identifier + nodenetwork_id integer REFERENCES nodenetworks NOT NULL, + -- the nodenetwork this applies to + nodenetwork_setting_type_id integer REFERENCES nodenetwork_setting_types NOT NULL, + -- the setting type + value text +) WITH OIDS; + +CREATE OR REPLACE VIEW nodenetwork_settings AS +SELECT nodenetwork_id, +array_accum(nodenetwork_setting_id) AS nodenetwork_setting_ids +FROM nodenetwork_setting +GROUP BY nodenetwork_id; + +CREATE OR REPLACE VIEW view_nodenetwork_settings AS +SELECT +nodenetwork_setting.nodenetwork_setting_id, +nodenetwork_setting.nodenetwork_id, +nodenetwork_setting_types.nodenetwork_setting_type_id, +nodenetwork_setting_types.name, +nodenetwork_setting_types.description, +nodenetwork_setting_types.category, +nodenetwork_setting_types.min_role_id, +nodenetwork_setting.value +FROM nodenetwork_setting +INNER JOIN nodenetwork_setting_types USING (nodenetwork_setting_type_id); + +CREATE OR REPLACE VIEW view_nodenetworks AS +SELECT +nodenetworks.nodenetwork_id, +nodenetworks.node_id, +nodenetworks.is_primary, +nodenetworks.type, +nodenetworks.method, +nodenetworks.ip, +nodenetworks.mac, +nodenetworks.gateway, +nodenetworks.network, +nodenetworks.broadcast, +nodenetworks.netmask, +nodenetworks.dns1, +nodenetworks.dns2, +nodenetworks.bwlimit, +nodenetworks.hostname, +COALESCE((SELECT nodenetwork_setting_ids FROM nodenetwork_settings WHERE nodenetwork_settings.nodenetwork_id = nodenetworks.nodenetwork_id), '{}') AS nodenetwork_setting_ids +FROM nodenetworks; + -------------------------------------------------------------------------------- -- Power control units (PCUs) -------------------------------------------------------------------------------- @@ -813,7 +874,7 @@ CREATE INDEX event_object_event_id_idx ON event_object (event_id); CREATE INDEX event_object_object_id_idx ON event_object (object_id); CREATE INDEX event_object_object_type_idx ON event_object (object_type); -CREATE VIEW event_objects AS +CREATE OR REPLACE VIEW event_objects AS SELECT event_id, array_accum(object_id) AS object_ids, array_accum(object_type) AS object_types @@ -840,6 +901,21 @@ COALESCE((SELECT object_ids FROM event_objects WHERE event_objects.event_id = ev COALESCE((SELECT object_types FROM event_objects WHERE event_objects.event_id = events.event_id), '{}') AS object_types FROM events; +CREATE OR REPLACE VIEW view_event_objects AS +SELECT +events.event_id, +events.person_id, +events.node_id, +events.fault_code, +events.call_name, +events.call, +events.message, +events.runtime, +CAST(date_part('epoch', events.time) AS bigint) AS time, +event_object.object_id, +event_object.object_type +FROM events LEFT JOIN event_object USING (event_id); + CREATE OR REPLACE VIEW view_persons AS SELECT persons.person_id,