diff --git a/db-schema/schema.sql b/db-schema/schema.sql index 17ebd48727ed6f420fd1bef5caa82df68a95a92e..6b668fb9936b48551decbaafafeac644a8c0ff3a 100755 --- a/db-schema/schema.sql +++ b/db-schema/schema.sql @@ -21,56 +21,85 @@ CREATE DOMAIN ulong64 AS numeric(20) CHECK(VALUE >= 0 AND VALUE <= 18446744073709551615); ------------------------------------------------------------------------------- -DROP TABLE IF EXISTS att_conf_data_type; +DROP TABLE IF EXISTS att_conf_type; -CREATE TABLE IF NOT EXISTS att_conf_data_type ( - att_conf_data_type_id serial NOT NULL, - data_type text NOT NULL, - tango_data_type smallint NOT NULL, - PRIMARY KEY (att_conf_data_type_id) +-- Mappings for ths Tango Data Type (used in att_conf) +CREATE TABLE att_conf_type ( + att_conf_type_id serial NOT NULL, + type text NOT NULL, + type_num smallint NOT NULL, + PRIMARY KEY (att_conf_type_id) ); -COMMENT ON TABLE att_conf_data_type is 'Attribute types description'; - -INSERT INTO att_conf_data_type (data_type, tango_data_type) VALUES -('att_scalar_devboolean_ro', 1),('att_scalar_devboolean_rw', 1),('att_att_array_devboolean_ro', 1),('att_array_devboolean_rw', 1), -('att_scalar_devuchar_ro', 22),('att_scalar_devuchar_rw', 22),('att_array_devuchar_ro', 22),('att_array_devuchar_rw', 22), -('att_scalar_devshort_ro', 2),('att_scalar_devshort_rw', 2),('att_array_devshort_ro', 2),('att_array_devshort_rw', 2), -('att_scalar_devushort_ro', 6),('att_scalar_devushort_rw', 6),('att_array_devushort_ro', 6),('att_array_devushort_rw', 6), -('att_scalar_devlong_ro', 3),('att_scalar_devlong_rw', 3),('att_array_devlong_ro', 3),('att_array_devlong_rw', 3), -('att_scalar_devulong_ro', 7),('att_scalar_devulong_rw', 7),('att_array_devulong_ro', 7),('att_array_devulong_rw', 7), -('att_scalar_devlong64_ro', 23),('att_scalar_devlong64_rw', 23),('att_array_devlong64_ro', 23),('att_array_devlong64_rw', 23), -('att_scalar_devulong64_ro', 24),('att_scalar_devulong64_rw', 24),('att_array_devulong64_ro', 24),('att_array_devulong64_rw', 24), -('att_scalar_devfloat_ro', 4),('att_scalar_devfloat_rw', 4),('att_array_devfloat_ro', 4),('att_array_devfloat_rw', 4), -('att_scalar_devdouble_ro', 5),('att_scalar_devdouble_rw', 5),('att_array_devdouble_ro', 5),('att_array_devdouble_rw', 5), -('att_scalar_devstring_ro', 8),('att_scalar_devstring_rw', 8),('att_array_devstring_ro', 8),('att_array_devstring_rw', 8), -('att_scalar_devstate_ro', 19),('att_scalar_devstate_rw', 19),('att_array_devstate_ro', 19),('att_array_devstate_rw', 19), -('att_scalar_devencoded_ro', 28),('att_scalar_devencoded_rw', 28),('att_array_devencoded_ro', 28),('att_array_devencoded_rw', 28), -('att_scalar_devenum_ro', 29),('att_scalar_devenum_rw', 29),('att_array_devenum_ro', 29),('att_array_devenum_rw', 29); +COMMENT ON TABLE att_conf_type is 'Attribute data type'; +INSERT INTO att_conf_type (type, type_num) VALUES +('DEV_BOOLEAN', 1),('DEV_SHORT', 2),('DEV_LONG', 3),('DEV_FLOAT', 4), +('DEV_DOUBLE', 5),('DEV_USHORT', 6),('DEV_ULONG', 7),('DEV_STRING', 8), +('DEV_STATE', 19),('DEV_UCHAR',22),('DEV_LONG64', 23),('DEV_ULONG64', 24), +('DEV_ENCODED', 28),('DEV_ENUM', 29); + +DROP TABLE IF EXISTS att_conf_format; + +-- Mappings for ths Tango Data Format Type (used in att_conf) +CREATE TABLE att_conf_format ( + att_conf_format_id serial NOT NULL, + format text NOT NULL, + format_num smallint NOT NULL, + PRIMARY KEY (att_conf_format_id) +); + +COMMENT ON TABLE att_conf_format is 'Attribute format type'; + +INSERT INTO att_conf_format (format, format_num) VALUES +('SCALAR', 0),('SPECTRUM', 1),('IMAGE', 2); + +DROP TABLE IF EXISTS att_conf_write; + +-- Mappings for the Tango Data Write Type (used in att_conf) +CREATE TABLE att_conf_write ( + att_conf_write_id serial NOT NULL, + write text NOT NULL, + write_num smallint NOT NULL, + PRIMARY KEY (att_conf_write_id) +); + +COMMENT ON TABLE att_conf_write is 'Attribute write type'; + +INSERT INTO att_conf_write (write, write_num) VALUES +('READ', 0),('READ_WITH_WRITE', 1),('WRITE', 2),('READ_WRITE', 3); + +-- The att_conf table contains the primary key for all data tables, the +-- att_conf_id. Expanded on the normal hdb++ tables since we add information +-- about the type. CREATE TABLE IF NOT EXISTS att_conf ( att_conf_id serial NOT NULL, att_name text NOT NULL, - att_conf_data_type_id integer NOT NULL, + att_conf_type_id smallint NOT NULL, + att_conf_format_id smallint NOT NULL, + att_conf_write_id smallint NOT NULL, + table_name text NOT NULL, cs_name text NOT NULL DEFAULT '', domain text NOT NULL DEFAULT '', family text NOT NULL DEFAULT '', member text NOT NULL DEFAULT '', name text NOT NULL DEFAULT '', - ttl int, -- TODO + ttl int, PRIMARY KEY (att_conf_id), - FOREIGN KEY (att_conf_data_type_id) REFERENCES att_conf_data_type (att_conf_data_type_id), + FOREIGN KEY (att_conf_type_id) REFERENCES att_conf_type (att_conf_type_id), + FOREIGN KEY (att_conf_format_id) REFERENCES att_conf_format (att_conf_format_id), + FOREIGN KEY (att_conf_write_id) REFERENCES att_conf_write (att_conf_write_id), UNIQUE (att_name) ); COMMENT ON TABLE att_conf is 'Attribute Configuration Table'; CREATE INDEX IF NOT EXISTS att_conf_att_conf_id_idx ON att_conf (att_conf_id); -CREATE INDEX IF NOT EXISTS att_conf_att_conf_data_type_id_idx ON att_conf (att_conf_data_type_id); +CREATE INDEX IF NOT EXISTS att_conf_att_conf_type_id_idx ON att_conf (att_conf_type_id); ------------------------------------------------------------------------------- DROP TABLE IF EXISTS att_history_event; -CREATE TABLE IF NOT EXISTS att_history_event ( +CREATE TABLE att_history_event ( att_history_event_id serial NOT NULL, event text NOT NULL, PRIMARY KEY (att_history_event_id) @@ -83,6 +112,7 @@ CREATE TABLE IF NOT EXISTS att_history ( att_conf_id integer NOT NULL, att_history_event_id integer NOT NULL, event_time timestamp(6) with time zone, + details json, PRIMARY KEY (att_conf_id, event_time), FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), FOREIGN KEY (att_history_event_id) REFERENCES att_history_event (att_history_event_id) @@ -95,7 +125,6 @@ CREATE INDEX IF NOT EXISTS att_history_att_conf_id_inx ON att_history (att_conf_ CREATE TABLE IF NOT EXISTS att_parameter ( att_conf_id integer NOT NULL, recv_time timestamp with time zone NOT NULL, - insert_time timestamp with time zone, label text NOT NULL DEFAULT '', unit text NOT NULL DEFAULT '', standard_unit text NOT NULL DEFAULT '', @@ -105,6 +134,7 @@ CREATE TABLE IF NOT EXISTS att_parameter ( archive_abs_change text NOT NULL DEFAULT '', archive_period text NOT NULL DEFAULT '', description text NOT NULL DEFAULT '', + details json, FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id) ); @@ -125,1034 +155,510 @@ COMMENT ON TABLE att_error_desc IS 'Error Description Table'; CREATE INDEX IF NOT EXISTS att_error_desc_att_error_desc_id_idx ON att_error_desc (att_error_desc_id); ------------------------------------------------------------------------------- -CREATE TABLE IF NOT EXISTS att_scalar_devboolean_ro ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, - value_r boolean, - quality smallint, - att_error_desc_id integer, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_scalar_devboolean_ro IS 'Scalar Boolean ReadOnly Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devboolean_ro_att_conf_id_idx ON att_scalar_devboolean_ro (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devboolean_ro_att_conf_id_data_time_idx ON att_scalar_devboolean_ro (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devboolean_ro', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_scalar_devboolean_rw ( +CREATE TABLE IF NOT EXISTS att_scalar_devboolean ( att_conf_id integer NOT NULL, data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, value_r boolean, value_w boolean, quality smallint, att_error_desc_id integer, + details json, PRIMARY KEY (att_conf_id, data_time), FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) ); -COMMENT ON TABLE att_scalar_devboolean_rw IS 'Scalar Boolean ReadWrite Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devboolean_rw_att_conf_id_idx ON att_scalar_devboolean_rw (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devboolean_rw_att_conf_id_data_time_idx ON att_scalar_devboolean_rw (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devboolean_rw', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); +COMMENT ON TABLE att_scalar_devboolean IS 'Scalar Boolean Values Table'; +CREATE INDEX IF NOT EXISTS att_scalar_devboolean_att_conf_id_idx ON att_scalar_devboolean (att_conf_id); +CREATE INDEX IF NOT EXISTS att_scalar_devboolean_att_conf_id_data_time_idx ON att_scalar_devboolean (att_conf_id,data_time DESC); +SELECT create_hypertable('att_scalar_devboolean', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); -CREATE TABLE IF NOT EXISTS att_array_devboolean_ro ( +CREATE TABLE IF NOT EXISTS att_array_devboolean ( att_conf_id integer NOT NULL, data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, - value_r boolean[], - quality smallint, - att_error_desc_id integer, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_array_devboolean_ro IS 'Array Boolean ReadOnly Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devboolean_ro_att_conf_id_idx ON att_array_devboolean_ro (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devboolean_ro_att_conf_id_data_time_idx ON att_array_devboolean_ro (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devboolean_ro', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_array_devboolean_rw ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, value_r boolean[], value_w boolean[], quality smallint, att_error_desc_id integer, + details json, PRIMARY KEY (att_conf_id, data_time), FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) ); -COMMENT ON TABLE att_array_devboolean_rw IS 'Array Boolean ReadWrite Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devboolean_rw_att_conf_id_idx ON att_array_devboolean_rw (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devboolean_rw_att_conf_id_data_time_idx ON att_array_devboolean_rw (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devboolean_rw', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_scalar_devuchar_ro ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, - value_r uchar, - quality smallint, - att_error_desc_id integer, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_scalar_devuchar_ro IS 'Scalar UChar ReadOnly Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devuchar_ro_att_conf_id_idx ON att_scalar_devuchar_ro (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devuchar_ro_att_conf_id_data_time_idx ON att_scalar_devuchar_ro (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devuchar_ro', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); +COMMENT ON TABLE att_array_devboolean IS 'Array Boolean Values Table'; +CREATE INDEX IF NOT EXISTS att_array_devboolean_att_conf_id_idx ON att_array_devboolean (att_conf_id); +CREATE INDEX IF NOT EXISTS att_array_devboolean_att_conf_id_data_time_idx ON att_array_devboolean (att_conf_id,data_time DESC); +SELECT create_hypertable('att_array_devboolean', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); -CREATE TABLE IF NOT EXISTS att_scalar_devuchar_rw ( +CREATE TABLE IF NOT EXISTS att_scalar_devuchar ( att_conf_id integer NOT NULL, data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, value_r uchar, value_w uchar, quality smallint, att_error_desc_id integer, + details json, PRIMARY KEY (att_conf_id, data_time), FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) ); -COMMENT ON TABLE att_scalar_devuchar_rw IS 'Scalar UChar ReadWrite Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devuchar_rw_att_conf_id_idx ON att_scalar_devuchar_rw (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devuchar_rw_att_conf_id_data_time_idx ON att_scalar_devuchar_rw (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devuchar_rw', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); +COMMENT ON TABLE att_scalar_devuchar IS 'Scalar UChar Values Table'; +CREATE INDEX IF NOT EXISTS att_scalar_devuchar_att_conf_id_idx ON att_scalar_devuchar (att_conf_id); +CREATE INDEX IF NOT EXISTS att_scalar_devuchar_att_conf_id_data_time_idx ON att_scalar_devuchar (att_conf_id,data_time DESC); +SELECT create_hypertable('att_scalar_devuchar', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); -CREATE TABLE IF NOT EXISTS att_array_devuchar_ro ( +CREATE TABLE IF NOT EXISTS att_array_devuchar ( att_conf_id integer NOT NULL, data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, - value_r uchar[], - quality smallint, - att_error_desc_id integer, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_array_devuchar_ro IS 'Array UChar ReadOnly Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devuchar_ro_att_conf_id_idx ON att_array_devuchar_ro (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devuchar_ro_att_conf_id_data_time_idx ON att_array_devuchar_ro (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devuchar_ro', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_array_devuchar_rw ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, value_r uchar[], value_w uchar[], quality smallint, + details json, att_error_desc_id integer, PRIMARY KEY (att_conf_id, data_time), FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) ); -COMMENT ON TABLE att_array_devuchar_rw IS 'Array UChar ReadWrite Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devuchar_rw_att_conf_id_idx ON att_array_devuchar_rw (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devuchar_rw_att_conf_id_data_time_idx ON att_array_devuchar_rw (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devuchar_rw', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_scalar_devshort_ro ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, - value_r smallint, - quality smallint, - att_error_desc_id integer, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_scalar_devshort_ro IS 'Scalar Short ReadOnly Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devshort_ro_att_conf_id_idx ON att_scalar_devshort_ro (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devshort_ro_att_conf_id_data_time_idx ON att_scalar_devshort_ro (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devshort_ro', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); +COMMENT ON TABLE att_array_devuchar IS 'Array UChar Values Table'; +CREATE INDEX IF NOT EXISTS att_array_devuchar_att_conf_id_idx ON att_array_devuchar (att_conf_id); +CREATE INDEX IF NOT EXISTS att_array_devuchar_att_conf_id_data_time_idx ON att_array_devuchar (att_conf_id,data_time DESC); +SELECT create_hypertable('att_array_devuchar', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); -CREATE TABLE IF NOT EXISTS att_scalar_devshort_rw ( +CREATE TABLE IF NOT EXISTS att_scalar_devshort ( att_conf_id integer NOT NULL, data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, value_r smallint, value_w smallint, quality smallint, + details json, att_error_desc_id integer, PRIMARY KEY (att_conf_id, data_time), FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) ); -COMMENT ON TABLE att_scalar_devshort_rw IS 'Scalar Short ReadWrite Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devshort_rw_att_conf_id_idx ON att_scalar_devshort_rw (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devshort_rw_att_conf_id_data_time_idx ON att_scalar_devshort_rw (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devshort_rw', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); +COMMENT ON TABLE att_scalar_devshort IS 'Scalar Short Values Table'; +CREATE INDEX IF NOT EXISTS att_scalar_devshort_att_conf_id_idx ON att_scalar_devshort (att_conf_id); +CREATE INDEX IF NOT EXISTS att_scalar_devshort_att_conf_id_data_time_idx ON att_scalar_devshort (att_conf_id,data_time DESC); +SELECT create_hypertable('att_scalar_devshort', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); -CREATE TABLE IF NOT EXISTS att_array_devshort_ro ( +CREATE TABLE IF NOT EXISTS att_array_devshort ( att_conf_id integer NOT NULL, data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, - value_r smallint[], - quality smallint, - att_error_desc_id integer, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_array_devshort_ro IS 'Array Short ReadOnly Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devshort_ro_att_conf_id_idx ON att_array_devshort_ro (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devshort_ro_att_conf_id_data_time_idx ON att_array_devshort_ro (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devshort_ro', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_array_devshort_rw ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, value_r smallint[], value_w smallint[], quality smallint, att_error_desc_id integer, + details json, PRIMARY KEY (att_conf_id, data_time), FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) ); -COMMENT ON TABLE att_array_devshort_rw IS 'Array Short ReadWrite Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devshort_rw_att_conf_id_idx ON att_array_devshort_rw (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devshort_rw_att_conf_id_data_time_idx ON att_array_devshort_rw (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devshort_rw', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); +COMMENT ON TABLE att_array_devshort IS 'Array Short Values Table'; +CREATE INDEX IF NOT EXISTS att_array_devshort_att_conf_id_idx ON att_array_devshort (att_conf_id); +CREATE INDEX IF NOT EXISTS att_array_devshort_att_conf_id_data_time_idx ON att_array_devshort (att_conf_id,data_time DESC); +SELECT create_hypertable('att_array_devshort', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); -CREATE TABLE IF NOT EXISTS att_scalar_devushort_ro ( +CREATE TABLE IF NOT EXISTS att_scalar_devushort ( att_conf_id integer NOT NULL, data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, - value_r ushort, - quality smallint, - att_error_desc_id integer, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_scalar_devushort_ro IS 'Scalar UShort ReadOnly Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devushort_ro_att_conf_id_idx ON att_scalar_devushort_ro (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devushort_ro_att_conf_id_data_time_idx ON att_scalar_devushort_ro (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devushort_ro', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_scalar_devushort_rw ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, value_r ushort, value_w ushort, quality smallint, att_error_desc_id integer, + details json, PRIMARY KEY (att_conf_id, data_time), FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) ); -COMMENT ON TABLE att_scalar_devushort_rw IS 'Scalar UShort ReadWrite Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devushort_rw_att_conf_id_idx ON att_scalar_devushort_rw (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devushort_rw_att_conf_id_data_time_idx ON att_scalar_devushort_rw (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devushort_rw', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); +COMMENT ON TABLE att_scalar_devushort IS 'Scalar UShort Values Table'; +CREATE INDEX IF NOT EXISTS att_scalar_devushort_att_conf_id_idx ON att_scalar_devushort (att_conf_id); +CREATE INDEX IF NOT EXISTS att_scalar_devushort_att_conf_id_data_time_idx ON att_scalar_devushort (att_conf_id,data_time DESC); +SELECT create_hypertable('att_scalar_devushort', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); -CREATE TABLE IF NOT EXISTS att_array_devushort_ro ( +CREATE TABLE IF NOT EXISTS att_array_devushort ( att_conf_id integer NOT NULL, data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, - value_r ushort[], - quality smallint, - att_error_desc_id integer, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_array_devushort_ro IS 'Array UShort ReadOnly Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devushort_ro_att_conf_id_idx ON att_array_devushort_ro (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devushort_ro_att_conf_id_data_time_idx ON att_array_devushort_ro (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devushort_ro', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_array_devushort_rw ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, value_r ushort[], value_w ushort[], quality smallint, att_error_desc_id integer, + details json, PRIMARY KEY (att_conf_id, data_time), FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) ); -COMMENT ON TABLE att_array_devushort_rw IS 'Array UShort ReadWrite Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devushort_rw_att_conf_id_idx ON att_array_devushort_rw (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devushort_rw_att_conf_id_data_time_idx ON att_array_devushort_rw (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devushort_rw', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_scalar_devlong_ro ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, - value_r integer, - quality smallint, - att_error_desc_id integer, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_scalar_devlong_ro IS 'Scalar Long ReadOnly Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devlong_ro_att_conf_id_idx ON att_scalar_devlong_ro (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devlong_ro_att_conf_id_data_time_idx ON att_scalar_devlong_ro (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devlong_ro', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); +COMMENT ON TABLE att_array_devushort IS 'Array UShort Values Table'; +CREATE INDEX IF NOT EXISTS att_array_devushort_att_conf_id_idx ON att_array_devushort (att_conf_id); +CREATE INDEX IF NOT EXISTS att_array_devushort_att_conf_id_data_time_idx ON att_array_devushort (att_conf_id,data_time DESC); +SELECT create_hypertable('att_array_devushort', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); -CREATE TABLE IF NOT EXISTS att_scalar_devlong_rw ( +CREATE TABLE IF NOT EXISTS att_scalar_devlong ( att_conf_id integer NOT NULL, data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, value_r integer, value_w integer, quality smallint, att_error_desc_id integer, + details json, PRIMARY KEY (att_conf_id, data_time), FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) ); -COMMENT ON TABLE att_scalar_devlong_rw IS 'Scalar Long ReadWrite Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devlong_rw_att_conf_id_idx ON att_scalar_devlong_rw (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devlong_rw_att_conf_id_data_time_idx ON att_scalar_devlong_rw (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devlong_rw', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); +COMMENT ON TABLE att_scalar_devlong IS 'Scalar Long Values Table'; +CREATE INDEX IF NOT EXISTS att_scalar_devlong_att_conf_id_idx ON att_scalar_devlong (att_conf_id); +CREATE INDEX IF NOT EXISTS att_scalar_devlong_att_conf_id_data_time_idx ON att_scalar_devlong (att_conf_id,data_time DESC); +SELECT create_hypertable('att_scalar_devlong', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); -CREATE TABLE IF NOT EXISTS att_array_devlong_ro ( +CREATE TABLE IF NOT EXISTS att_array_devlong ( att_conf_id integer NOT NULL, data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, - value_r integer[], - quality smallint, - att_error_desc_id integer, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_array_devlong_ro IS 'Array Long ReadOnly Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devlong_ro_att_conf_id_idx ON att_array_devlong_ro (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devlong_ro_att_conf_id_data_time_idx ON att_array_devlong_ro (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devlong_ro', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_array_devlong_rw ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, value_r integer[], value_w integer[], quality smallint, att_error_desc_id integer, + details json, PRIMARY KEY (att_conf_id, data_time), FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) ); -COMMENT ON TABLE att_array_devlong_rw IS 'Array Long ReadWrite Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devlong_rw_att_conf_id_idx ON att_array_devlong_rw (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devlong_rw_att_conf_id_data_time_idx ON att_array_devlong_rw (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devlong_rw', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); +COMMENT ON TABLE att_array_devlong IS 'Array Long Values Table'; +CREATE INDEX IF NOT EXISTS att_array_devlong_att_conf_id_idx ON att_array_devlong (att_conf_id); +CREATE INDEX IF NOT EXISTS att_array_devlong_att_conf_id_data_time_idx ON att_array_devlong (att_conf_id,data_time DESC); +SELECT create_hypertable('att_array_devlong', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); -CREATE TABLE IF NOT EXISTS att_scalar_devulong_ro ( +CREATE TABLE IF NOT EXISTS att_scalar_devulong ( att_conf_id integer NOT NULL, data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, - value_r ulong, - quality smallint, - att_error_desc_id integer, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_scalar_devulong_ro IS 'Scalar ULong ReadOnly Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devulong_ro_att_conf_id_idx ON att_scalar_devulong_ro (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devulong_ro_att_conf_id_data_time_idx ON att_scalar_devulong_ro (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devulong_ro', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_scalar_devulong_rw ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, value_r ulong, value_w ulong, quality smallint, att_error_desc_id integer, + details json, PRIMARY KEY (att_conf_id, data_time), FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) ); -COMMENT ON TABLE att_scalar_devulong_rw IS 'Scalar ULong ReadWrite Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devulong_rw_att_conf_id_idx ON att_scalar_devulong_rw (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devulong_rw_att_conf_id_data_time_idx ON att_scalar_devulong_rw (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devulong_rw', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); +COMMENT ON TABLE att_scalar_devulong IS 'Scalar ULong Values Table'; +CREATE INDEX IF NOT EXISTS att_scalar_devulong_att_conf_id_idx ON att_scalar_devulong (att_conf_id); +CREATE INDEX IF NOT EXISTS att_scalar_devulong_att_conf_id_data_time_idx ON att_scalar_devulong (att_conf_id,data_time DESC); +SELECT create_hypertable('att_scalar_devulong', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); -CREATE TABLE IF NOT EXISTS att_array_devulong_ro ( +CREATE TABLE IF NOT EXISTS att_array_devulong ( att_conf_id integer NOT NULL, data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, - value_r ulong[], - quality smallint, - att_error_desc_id integer, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_array_devulong_ro IS 'Array ULong ReadOnly Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devulong_ro_att_conf_id_idx ON att_array_devulong_ro (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devulong_ro_att_conf_id_data_time_idx ON att_array_devulong_ro (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devulong_ro', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_array_devulong_rw ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, value_r ulong[], value_w ulong[], quality smallint, att_error_desc_id integer, + details json, PRIMARY KEY (att_conf_id, data_time), FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) ); -COMMENT ON TABLE att_array_devulong_rw IS 'Array ULong ReadWrite Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devulong_rw_att_conf_id_idx ON att_array_devulong_rw (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devulong_rw_att_conf_id_data_time_idx ON att_array_devulong_rw (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devulong_rw', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); +COMMENT ON TABLE att_array_devulong IS 'Array ULong Values Table'; +CREATE INDEX IF NOT EXISTS att_array_devulong_att_conf_id_idx ON att_array_devulong (att_conf_id); +CREATE INDEX IF NOT EXISTS att_array_devulong_att_conf_id_data_time_idx ON att_array_devulong (att_conf_id,data_time DESC); +SELECT create_hypertable('att_array_devulong', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); -CREATE TABLE IF NOT EXISTS att_scalar_devlong64_ro ( +CREATE TABLE IF NOT EXISTS att_scalar_devlong64 ( att_conf_id integer NOT NULL, data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, - value_r bigint, - quality smallint, - att_error_desc_id integer, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_scalar_devlong64_ro IS 'Scalar Long64 ReadOnly Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devlong64_ro_att_conf_id_idx ON att_scalar_devlong64_ro (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devlong64_ro_att_conf_id_data_time_idx ON att_scalar_devlong64_ro (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devlong64_ro', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_scalar_devlong64_rw ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, value_r bigint, value_w bigint, quality smallint, att_error_desc_id integer, + details json, PRIMARY KEY (att_conf_id, data_time), FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) ); -COMMENT ON TABLE att_scalar_devlong64_rw IS 'Scalar Long64 ReadWrite Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devlong64_rw_att_conf_id_idx ON att_scalar_devlong64_rw (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devlong64_rw_att_conf_id_data_time_idx ON att_scalar_devlong64_rw (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devlong64_rw', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_array_devlong64_ro ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, - value_r bigint[], - quality smallint, - att_error_desc_id integer, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_array_devlong64_ro IS 'Array Long64 ReadOnly Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devlong64_ro_att_conf_id_idx ON att_array_devlong64_ro (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devlong64_ro_att_conf_id_data_time_idx ON att_array_devlong64_ro (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devlong64_ro', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); +COMMENT ON TABLE att_scalar_devlong64 IS 'Scalar Long64 Values Table'; +CREATE INDEX IF NOT EXISTS att_scalar_devlong64_att_conf_id_idx ON att_scalar_devlong64 (att_conf_id); +CREATE INDEX IF NOT EXISTS att_scalar_devlong64_att_conf_id_data_time_idx ON att_scalar_devlong64 (att_conf_id,data_time DESC); +SELECT create_hypertable('att_scalar_devlong64', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); -CREATE TABLE IF NOT EXISTS att_array_devlong64_rw ( +CREATE TABLE IF NOT EXISTS att_array_devlong64 ( att_conf_id integer NOT NULL, data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, value_r bigint[], value_w bigint[], quality smallint, att_error_desc_id integer, + details json, PRIMARY KEY (att_conf_id, data_time), FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) ); -COMMENT ON TABLE att_array_devlong64_rw IS 'Array Long64 ReadWrite Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devlong64_rw_att_conf_id_idx ON att_array_devlong64_rw (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devlong64_rw_att_conf_id_data_time_idx ON att_array_devlong64_rw (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devlong64_rw', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); +COMMENT ON TABLE att_array_devlong64 IS 'Array Long64 Values Table'; +CREATE INDEX IF NOT EXISTS att_array_devlong64_att_conf_id_idx ON att_array_devlong64 (att_conf_id); +CREATE INDEX IF NOT EXISTS att_array_devlong64_att_conf_id_data_time_idx ON att_array_devlong64 (att_conf_id,data_time DESC); +SELECT create_hypertable('att_array_devlong64', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); -CREATE TABLE IF NOT EXISTS att_scalar_devulong64_ro ( +CREATE TABLE IF NOT EXISTS att_scalar_devulong64 ( att_conf_id integer NOT NULL, data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, - value_r ulong64, - quality smallint, - att_error_desc_id integer, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_scalar_devulong64_ro IS 'Scalar ULong64 ReadOnly Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devulong64_ro_att_conf_id_idx ON att_scalar_devulong64_ro (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devulong64_ro_att_conf_id_data_time_idx ON att_scalar_devulong64_ro (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devulong64_ro', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_scalar_devulong64_rw ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, value_r ulong64, value_w ulong64, quality smallint, att_error_desc_id integer, + details json, PRIMARY KEY (att_conf_id, data_time), FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) ); -COMMENT ON TABLE att_scalar_devulong64_rw IS 'Scalar ULong64 ReadWrite Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devulong64_rw_att_conf_id_idx ON att_scalar_devulong64_rw (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devulong64_rw_att_conf_id_data_time_idx ON att_scalar_devulong64_rw (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devulong64_rw', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); +COMMENT ON TABLE att_scalar_devulong64 IS 'Scalar ULong64 Values Table'; +CREATE INDEX IF NOT EXISTS att_scalar_devulong64_att_conf_id_idx ON att_scalar_devulong64 (att_conf_id); +CREATE INDEX IF NOT EXISTS att_scalar_devulong64_att_conf_id_data_time_idx ON att_scalar_devulong64 (att_conf_id,data_time DESC); +SELECT create_hypertable('att_scalar_devulong64', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); -CREATE TABLE IF NOT EXISTS att_array_devulong64_ro ( +CREATE TABLE IF NOT EXISTS att_array_devulong64 ( att_conf_id integer NOT NULL, data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, - value_r ulong64[], - quality smallint, - att_error_desc_id integer, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_array_devulong64_ro IS 'Array ULong64 ReadOnly Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devulong64_ro_att_conf_id_idx ON att_array_devulong64_ro (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devulong64_ro_att_conf_id_data_time_idx ON att_array_devulong64_ro (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devulong64_ro', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_array_devulong64_rw ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, value_r ulong64[], value_w ulong64[], quality smallint, att_error_desc_id integer, + details json, PRIMARY KEY (att_conf_id, data_time), FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) ); -COMMENT ON TABLE att_array_devulong64_rw IS 'Array ULong64 ReadWrite Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devulong64_rw_att_conf_id_idx ON att_array_devulong64_rw (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devulong64_rw_att_conf_id_data_time_idx ON att_array_devulong64_rw (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devulong64_rw', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_scalar_devfloat_ro ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, - value_r real, - quality smallint, - att_error_desc_id integer, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_scalar_devfloat_ro IS 'Scalar Float ReadOnly Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devfloat_ro_att_conf_id_idx ON att_scalar_devfloat_ro (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devfloat_ro_att_conf_id_data_time_idx ON att_scalar_devfloat_ro (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devfloat_ro', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); +COMMENT ON TABLE att_array_devulong64 IS 'Array ULong64 Values Table'; +CREATE INDEX IF NOT EXISTS att_array_devulong64_att_conf_id_idx ON att_array_devulong64 (att_conf_id); +CREATE INDEX IF NOT EXISTS att_array_devulong64_att_conf_id_data_time_idx ON att_array_devulong64 (att_conf_id,data_time DESC); +SELECT create_hypertable('att_array_devulong64', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); -CREATE TABLE IF NOT EXISTS att_scalar_devfloat_rw ( +CREATE TABLE IF NOT EXISTS att_scalar_devfloat ( att_conf_id integer NOT NULL, data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, value_r real, value_w real, quality smallint, att_error_desc_id integer, + details json, PRIMARY KEY (att_conf_id, data_time), FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) ); -COMMENT ON TABLE att_scalar_devfloat_rw IS 'Scalar Float ReadWrite Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devfloat_rw_att_conf_id_idx ON att_scalar_devfloat_rw (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devfloat_rw_att_conf_id_data_time_idx ON att_scalar_devfloat_rw (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devfloat_rw', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_array_devfloat_ro ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, - value_r real[], - quality smallint, - att_error_desc_id integer, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_array_devfloat_ro IS 'Array Float ReadOnly Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devfloat_ro_att_conf_id_idx ON att_array_devfloat_ro (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devfloat_ro_att_conf_id_data_time_idx ON att_array_devfloat_ro (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devfloat_ro', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); +COMMENT ON TABLE att_scalar_devfloat IS 'Scalar Float Values Table'; +CREATE INDEX IF NOT EXISTS att_scalar_devfloat_att_conf_id_idx ON att_scalar_devfloat (att_conf_id); +CREATE INDEX IF NOT EXISTS att_scalar_devfloat_att_conf_id_data_time_idx ON att_scalar_devfloat (att_conf_id,data_time DESC); +SELECT create_hypertable('att_scalar_devfloat', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); -CREATE TABLE IF NOT EXISTS att_array_devfloat_rw ( +CREATE TABLE IF NOT EXISTS att_array_devfloat ( att_conf_id integer NOT NULL, data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, value_r real[], value_w real[], quality smallint, att_error_desc_id integer, + details json, PRIMARY KEY (att_conf_id, data_time), FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) ); -COMMENT ON TABLE att_array_devfloat_rw IS 'Array Float ReadWrite Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devfloat_rw_att_conf_id_idx ON att_array_devfloat_rw (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devfloat_rw_att_conf_id_data_time_idx ON att_array_devfloat_rw (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devfloat_rw', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); +COMMENT ON TABLE att_array_devfloat IS 'Array Float Values Table'; +CREATE INDEX IF NOT EXISTS att_array_devfloat_att_conf_id_idx ON att_array_devfloat (att_conf_id); +CREATE INDEX IF NOT EXISTS att_array_devfloat_att_conf_id_data_time_idx ON att_array_devfloat (att_conf_id,data_time DESC); +SELECT create_hypertable('att_array_devfloat', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); -CREATE TABLE IF NOT EXISTS att_scalar_devdouble_ro ( +CREATE TABLE IF NOT EXISTS att_scalar_devdouble ( att_conf_id integer NOT NULL, data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, - value_r double precision, - quality smallint, - att_error_desc_id integer, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_scalar_devdouble_ro IS 'Scalar Double ReadOnly Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devdouble_ro_att_conf_id_idx ON att_scalar_devdouble_ro (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devdouble_ro_att_conf_id_data_time_idx ON att_scalar_devdouble_ro (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devdouble_ro', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_scalar_devdouble_rw ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, value_r double precision, value_w double precision, quality smallint, att_error_desc_id integer, + details json, PRIMARY KEY (att_conf_id, data_time), FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) ); -COMMENT ON TABLE att_scalar_devdouble_rw IS 'Scalar Double ReadWrite Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devdouble_rw_att_conf_id_idx ON att_scalar_devdouble_rw (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devdouble_rw_att_conf_id_data_time_idx ON att_scalar_devdouble_rw (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devdouble_rw', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); +COMMENT ON TABLE att_scalar_devdouble IS 'Scalar Double Values Table'; +CREATE INDEX IF NOT EXISTS att_scalar_devdouble_att_conf_id_idx ON att_scalar_devdouble (att_conf_id); +CREATE INDEX IF NOT EXISTS att_scalar_devdouble_att_conf_id_data_time_idx ON att_scalar_devdouble (att_conf_id,data_time DESC); +SELECT create_hypertable('att_scalar_devdouble', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); -CREATE TABLE IF NOT EXISTS att_array_devdouble_ro ( +CREATE TABLE IF NOT EXISTS att_array_devdouble ( att_conf_id integer NOT NULL, data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, - value_r double precision[], - quality smallint, - att_error_desc_id integer, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_array_devdouble_ro IS 'Array Double ReadOnly Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devdouble_ro_att_conf_id_idx ON att_array_devdouble_ro (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devdouble_ro_att_conf_id_data_time_idx ON att_array_devdouble_ro (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devdouble_ro', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_array_devdouble_rw ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, value_r double precision[], value_w double precision[], quality smallint, att_error_desc_id integer, + details json, PRIMARY KEY (att_conf_id, data_time), FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) ); -COMMENT ON TABLE att_array_devdouble_rw IS 'Array Double ReadWrite Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devdouble_rw_att_conf_id_idx ON att_array_devdouble_rw (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devdouble_rw_att_conf_id_data_time_idx ON att_array_devdouble_rw (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devdouble_rw', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_scalar_devstring_ro ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, - value_r text, - quality smallint, - att_error_desc_id integer, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_scalar_devstring_ro IS 'Scalar String ReadOnly Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devstring_ro_att_conf_id_idx ON att_scalar_devstring_ro (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devstring_ro_att_conf_id_data_time_idx ON att_scalar_devstring_ro (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devstring_ro', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); +COMMENT ON TABLE att_array_devdouble IS 'Array Double Values Table'; +CREATE INDEX IF NOT EXISTS att_array_devdouble_att_conf_id_idx ON att_array_devdouble (att_conf_id); +CREATE INDEX IF NOT EXISTS att_array_devdouble_att_conf_id_data_time_idx ON att_array_devdouble (att_conf_id,data_time DESC); +SELECT create_hypertable('att_array_devdouble', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); -CREATE TABLE IF NOT EXISTS att_scalar_devstring_rw ( +CREATE TABLE IF NOT EXISTS att_scalar_devstring ( att_conf_id integer NOT NULL, data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, value_r text, value_w text, quality smallint, att_error_desc_id integer, + details json, PRIMARY KEY (att_conf_id, data_time), FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) ); -COMMENT ON TABLE att_scalar_devstring_rw IS 'Scalar String ReadWrite Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devstring_rw_att_conf_id_idx ON att_scalar_devstring_rw (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devstring_rw_att_conf_id_data_time_idx ON att_scalar_devstring_rw (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devstring_rw', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_array_devstring_ro ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, - value_r text[], - quality smallint, - att_error_desc_id integer, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_array_devstring_ro IS 'Array String ReadOnly Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devstring_ro_att_conf_id_idx ON att_array_devstring_ro (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devstring_ro_att_conf_id_data_time_idx ON att_array_devstring_ro (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devstring_ro', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); +COMMENT ON TABLE att_scalar_devstring IS 'Scalar String Values Table'; +CREATE INDEX IF NOT EXISTS att_scalar_devstring_att_conf_id_idx ON att_scalar_devstring (att_conf_id); +CREATE INDEX IF NOT EXISTS att_scalar_devstring_att_conf_id_data_time_idx ON att_scalar_devstring (att_conf_id,data_time DESC); +SELECT create_hypertable('att_scalar_devstring', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); -CREATE TABLE IF NOT EXISTS att_array_devstring_rw ( +CREATE TABLE IF NOT EXISTS att_array_devstring ( att_conf_id integer NOT NULL, data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, value_r text[], value_w text[], quality smallint, att_error_desc_id integer, + details json, PRIMARY KEY (att_conf_id, data_time), FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) ); -COMMENT ON TABLE att_array_devstring_rw IS 'Array String ReadWrite Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devstring_rw_att_conf_id_idx ON att_array_devstring_rw (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devstring_rw_att_conf_id_data_time_idx ON att_array_devstring_rw (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devstring_rw', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); +COMMENT ON TABLE att_array_devstring IS 'Array String Values Table'; +CREATE INDEX IF NOT EXISTS att_array_devstring_att_conf_id_idx ON att_array_devstring (att_conf_id); +CREATE INDEX IF NOT EXISTS att_array_devstring_att_conf_id_data_time_idx ON att_array_devstring (att_conf_id,data_time DESC); +SELECT create_hypertable('att_array_devstring', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); -CREATE TABLE IF NOT EXISTS att_scalar_devstate_ro ( +CREATE TABLE IF NOT EXISTS att_scalar_devstate ( att_conf_id integer NOT NULL, data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, - value_r integer, - quality smallint, - att_error_desc_id integer, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_scalar_devstate_ro IS 'Scalar State ReadOnly Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devstate_ro_att_conf_id_idx ON att_scalar_devstate_ro (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devstate_ro_att_conf_id_data_time_idx ON att_scalar_devstate_ro (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devstate_ro', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_scalar_devstate_rw ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, value_r integer, value_w integer, quality smallint, att_error_desc_id integer, + details json, PRIMARY KEY (att_conf_id, data_time), FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) ); -COMMENT ON TABLE att_scalar_devstate_rw IS 'Scalar State ReadWrite Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devstate_rw_att_conf_id_idx ON att_scalar_devstate_rw (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devstate_rw_att_conf_id_data_time_idx ON att_scalar_devstate_rw (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devstate_rw', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_array_devstate_ro ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, - value_r integer[], - quality smallint, - att_error_desc_id integer, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_array_devstate_ro IS 'Array State ReadOnly Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devstate_ro_att_conf_id_idx ON att_array_devstate_ro (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devstate_ro_att_conf_id_data_time_idx ON att_array_devstate_ro (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devstate_ro', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); +COMMENT ON TABLE att_scalar_devstate IS 'Scalar State Values Table'; +CREATE INDEX IF NOT EXISTS att_scalar_devstate_att_conf_id_idx ON att_scalar_devstate (att_conf_id); +CREATE INDEX IF NOT EXISTS att_scalar_devstate_att_conf_id_data_time_idx ON att_scalar_devstate (att_conf_id,data_time DESC); +SELECT create_hypertable('att_scalar_devstate', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); -CREATE TABLE IF NOT EXISTS att_array_devstate_rw ( +CREATE TABLE IF NOT EXISTS att_array_devstate ( att_conf_id integer NOT NULL, data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, value_r integer[], value_w integer[], quality smallint, att_error_desc_id integer, + details json, PRIMARY KEY (att_conf_id, data_time), FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) ); -COMMENT ON TABLE att_array_devstate_rw IS 'Array State ReadWrite Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devstate_rw_att_conf_id_idx ON att_array_devstate_rw (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devstate_rw_att_conf_id_data_time_idx ON att_array_devstate_rw (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devstate_rw', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); +COMMENT ON TABLE att_array_devstate IS 'Array State Values Table'; +CREATE INDEX IF NOT EXISTS att_array_devstate_att_conf_id_idx ON att_array_devstate (att_conf_id); +CREATE INDEX IF NOT EXISTS att_array_devstate_att_conf_id_data_time_idx ON att_array_devstate (att_conf_id,data_time DESC); +SELECT create_hypertable('att_array_devstate', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); -CREATE TABLE IF NOT EXISTS att_scalar_devenum_ro ( +CREATE TABLE IF NOT EXISTS att_scalar_devencoded ( att_conf_id integer NOT NULL, data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, - value_r integer, - quality smallint, - att_error_desc_id integer, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_scalar_devenum_ro IS 'Scalar Enum ReadOnly Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devenum_ro_att_conf_id_idx ON att_scalar_devenum_ro (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devenum_ro_att_conf_id_data_time_idx ON att_scalar_devenum_ro (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devenum_ro', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_scalar_devenum_rw ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, - value_r integer, - value_w integer, - quality smallint, - att_error_desc_id integer, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_scalar_devenum_rw IS 'Scalar Enum ReadWrite Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devenum_rw_att_conf_id_idx ON att_scalar_devenum_rw (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devenum_rw_att_conf_id_data_time_idx ON att_scalar_devenum_rw (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devenum_rw', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_array_devenum_ro ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, - value_r integer[], + value_r bytea, + value_w bytea, quality smallint, att_error_desc_id integer, + details json, PRIMARY KEY (att_conf_id, data_time), FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) ); +COMMENT ON TABLE att_scalar_devencoded IS 'Scalar DevEncoded Values Table'; +CREATE INDEX IF NOT EXISTS att_scalar_devencoded_att_conf_id_idx ON att_scalar_devencoded (att_conf_id); +CREATE INDEX IF NOT EXISTS att_scalar_devencoded_att_conf_id_data_time_idx ON att_scalar_devencoded (att_conf_id,data_time DESC); +SELECT create_hypertable('att_scalar_devencoded', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); -COMMENT ON TABLE att_array_devenum_ro IS 'Array Enum ReadOnly Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devenum_ro_att_conf_id_idx ON att_array_devenum_ro (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devenum_ro_att_conf_id_data_time_idx ON att_array_devenum_ro (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devenum_ro', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_array_devenum_rw ( +CREATE TABLE IF NOT EXISTS att_array_devencoded ( att_conf_id integer NOT NULL, data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, - value_r integer[], - value_w integer[], + value_r bytea[], + value_w bytea[], quality smallint, att_error_desc_id integer, + details json, PRIMARY KEY (att_conf_id, data_time), FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) ); +COMMENT ON TABLE att_array_devencoded IS 'Array DevEncoded Values Table'; +CREATE INDEX IF NOT EXISTS att_array_devencoded_att_conf_id_idx ON att_array_devencoded (att_conf_id); +CREATE INDEX IF NOT EXISTS att_array_devencoded_att_conf_id_data_time_idx ON att_array_devencoded (att_conf_id,data_time DESC); +SELECT create_hypertable('att_array_devencoded', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); -COMMENT ON TABLE att_array_devenum_rw IS 'Array Enum ReadWrite Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devenum_rw_att_conf_id_idx ON att_array_devenum_rw (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devenum_rw_att_conf_id_data_time_idx ON att_array_devenum_rw (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devenum_rw', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_scalar_devencoded_ro ( +-- The Enum tables are unique in that they store a value and text label for +-- each data point +CREATE TABLE IF NOT EXISTS att_scalar_devenum ( att_conf_id integer NOT NULL, data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, - value_r bytea, + value_r_label text, + value_r smallint, + value_w_label text, + value_w smallint, quality smallint, att_error_desc_id integer, + details json, PRIMARY KEY (att_conf_id, data_time), FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) ); -COMMENT ON TABLE att_scalar_devenum_ro IS 'Scalar DevEncoded ReadOnly Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devencoded_ro_att_conf_id_idx ON att_scalar_devencoded_ro (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devencoded_ro_att_conf_id_data_time_idx ON att_scalar_devencoded_ro (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devencoded_ro', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); -CREATE TABLE IF NOT EXISTS att_scalar_devencoded_rw ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, - value_r bytea, - value_w bytea, - quality smallint, - att_error_desc_id integer, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); -COMMENT ON TABLE att_scalar_devenum_rw IS 'Scalar DevEncoded ReadWrite Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devencoded_rw_att_conf_id_idx ON att_scalar_devencoded_rw (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devencoded_rw_att_conf_id_data_time_idx ON att_scalar_devencoded_rw (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devencoded_rw', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); +COMMENT ON TABLE att_scalar_devenum IS 'Scalar Enum Values Table'; +CREATE INDEX IF NOT EXISTS att_scalar_devenum_att_conf_id_idx ON att_scalar_devenum (att_conf_id); +CREATE INDEX IF NOT EXISTS att_scalar_devenum_att_conf_id_data_time_idx ON att_scalar_devenum (att_conf_id,data_time DESC); +SELECT create_hypertable('att_scalar_devenum', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); -CREATE TABLE IF NOT EXISTS att_array_devencoded_ro ( +CREATE TABLE IF NOT EXISTS att_array_devenum ( att_conf_id integer NOT NULL, data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, - value_r bytea[], + value_r_label text[], + value_r smallint[], + value_w_label text[], + value_w smallint[], quality smallint, att_error_desc_id integer, + details json, PRIMARY KEY (att_conf_id, data_time), FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) ); -COMMENT ON TABLE att_array_devenum_ro IS 'Array DevEncoded ReadOnly Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devencoded_ro_att_conf_id_idx ON att_array_devencoded_ro (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devencoded_ro_att_conf_id_data_time_idx ON att_array_devencoded_ro (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devencoded_ro', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); -CREATE TABLE IF NOT EXISTS att_array_devencoded_rw ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - recv_time timestamp with time zone, - insert_time timestamp with time zone, - value_r bytea[], - value_w bytea[], - quality smallint, - att_error_desc_id integer, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); -COMMENT ON TABLE att_array_devenum_rw IS 'Array DevEncoded ReadWrite Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devencoded_rw_att_conf_id_idx ON att_array_devencoded_rw (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devencoded_rw_att_conf_id_data_time_idx ON att_array_devencoded_rw (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devencoded_rw', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); \ No newline at end of file +COMMENT ON TABLE att_array_devenum IS 'Array Enum Values Table'; +CREATE INDEX IF NOT EXISTS att_array_devenum_att_conf_id_idx ON att_array_devenum (att_conf_id); +CREATE INDEX IF NOT EXISTS att_array_devenum_att_conf_id_data_time_idx ON att_array_devenum (att_conf_id,data_time DESC); +SELECT create_hypertable('att_array_devenum', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); diff --git a/db-schema/schema_updated.sql b/db-schema/schema_updated.sql deleted file mode 100755 index d2777eff115392e7dce7e943ac84762df756d7fa..0000000000000000000000000000000000000000 --- a/db-schema/schema_updated.sql +++ /dev/null @@ -1,653 +0,0 @@ -DROP DATABASE IF EXISTS hdbpp; - --- Create the hdb database and use it -CREATE DATABASE hdbpp; -\c hdbpp - --- Add the timescaledb extension (Important) -CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE; - -------------------------------------------------------------------------------- -CREATE DOMAIN uchar AS numeric(3) -- ALT smallint - CHECK(VALUE >= 0 AND VALUE <= 255); - -CREATE DOMAIN ushort AS numeric(5) -- ALT integer - CHECK(VALUE >= 0 AND VALUE <= 65535); - -CREATE DOMAIN ulong AS numeric(10) -- ALT bigint - CHECK(VALUE >= 0 AND VALUE <= 4294967295); - -CREATE DOMAIN ulong64 AS numeric(20) - CHECK(VALUE >= 0 AND VALUE <= 18446744073709551615); - -------------------------------------------------------------------------------- -DROP TABLE IF EXISTS att_conf_data_type; -DROP TABLE IF EXISTS att_conf_data_format; - -CREATE TABLE IF NOT EXISTS att_conf_data_type ( - att_conf_data_type_id serial NOT NULL, - data_type text NOT NULL, - type_num smallint NOT NULL, - PRIMARY KEY (att_conf_data_type_id) -); - -COMMENT ON TABLE att_conf_data_type is 'Attribute type'; - -INSERT INTO att_conf_data_type (data_type, type_num) VALUES -('ATT_BOOL', 0),('ATT_SHORT', 1),('ATT_LONG', 2),('ATT_LONG64', 3), -('ATT_FLOAT', 4),('ATT_DOUBLE', 5),('ATT_UCHAR', 6),('ATT_USHORT', 7), -('ATT_ULONG', 8),('ATT_ULONG64',9),('ATT_STRING', 10),('ATT_STATE', 11), -('ATT_ENCODED', 13),('ATT_NO_DATA', 14); - -CREATE TABLE IF NOT EXISTS att_conf_data_format ( - att_conf_data_format_id serial NOT NULL, - data_format text NOT NULL, - format_num smallint NOT NULL, - PRIMARY KEY (att_conf_data_format_id) -); - -COMMENT ON TABLE att_conf_data_format is 'Attribute format'; - -INSERT INTO att_conf_data_format (data_format, format_num) VALUES -('SCALAR', 0),('SPECTRUM', 1),('IMAGE', 2); - -CREATE TABLE IF NOT EXISTS att_conf_data_write_type ( - att_conf_data_write_type_id serial NOT NULL, - data_access text NOT NULL, - access_num smallint NOT NULL, - PRIMARY KEY (att_conf_data_write_type_id) -); - -COMMENT ON TABLE att_conf_data_access is 'Attribute access'; - -INSERT INTO att_conf_data_write_type (data_access, access_num) VALUES -('READ', 0),('READ_WITH_WRITE', 1),('WRITE', 3),('READ_WRITE', 4); - -CREATE TABLE IF NOT EXISTS att_conf ( - att_conf_id serial NOT NULL, - att_name text NOT NULL, - att_conf_data_type_id smallint NOT NULL, - att_conf_data_format_id smallint NOT NULL, - att_conf_data_write_type_id smallint NOT NULL, - table_name text NOT NULL, - cs_name text NOT NULL DEFAULT '', - domain text NOT NULL DEFAULT '', - family text NOT NULL DEFAULT '', - member text NOT NULL DEFAULT '', - name text NOT NULL DEFAULT '', - ttl int, - PRIMARY KEY (att_conf_id), - FOREIGN KEY (att_conf_data_type_id) REFERENCES att_conf_data_type (att_conf_data_type_id), - FOREIGN KEY (att_conf_data_format_id) REFERENCES att_conf_data_format (att_conf_data_format_id), - FOREIGN KEY (att_conf_data_write_type_id) REFERENCES att_conf_data_access (att_conf_data_write_type_id), - UNIQUE (att_name) -); - -COMMENT ON TABLE att_conf is 'Attribute Configuration Table'; -CREATE INDEX IF NOT EXISTS att_conf_att_conf_id_idx ON att_conf (att_conf_id); -CREATE INDEX IF NOT EXISTS att_conf_att_conf_data_type_id_idx ON att_conf (att_conf_data_type_id); - -------------------------------------------------------------------------------- -DROP TABLE IF EXISTS att_history_event; - -CREATE TABLE IF NOT EXISTS att_history_event ( - att_history_event_id serial NOT NULL, - event text NOT NULL, - PRIMARY KEY (att_history_event_id) -); - -COMMENT ON TABLE att_history_event IS 'Attribute history events description'; -CREATE INDEX IF NOT EXISTS att_history_att_history_event_id_idx ON att_history_event (att_history_event_id); - -CREATE TABLE IF NOT EXISTS att_history ( - att_conf_id integer NOT NULL, - att_history_event_id integer NOT NULL, - event_time timestamp(6) with time zone, - details json, - PRIMARY KEY (att_conf_id, event_time,), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_history_event_id) REFERENCES att_history_event (att_history_event_id) -); - -COMMENT ON TABLE att_history is 'Attribute Configuration Events History Table'; -CREATE INDEX IF NOT EXISTS att_history_att_conf_id_inx ON att_history (att_conf_id); - -------------------------------------------------------------------------------- -CREATE TABLE IF NOT EXISTS att_parameter ( - att_conf_id integer NOT NULL, - recv_time timestamp with time zone NOT NULL, - label text NOT NULL DEFAULT '', - unit text NOT NULL DEFAULT '', - standard_unit text NOT NULL DEFAULT '', - display_unit text NOT NULL DEFAULT '', - format text NOT NULL DEFAULT '', - archive_rel_change text NOT NULL DEFAULT '', - archive_abs_change text NOT NULL DEFAULT '', - archive_period text NOT NULL DEFAULT '', - description text NOT NULL DEFAULT '', - details json, - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id) -); - -COMMENT ON TABLE att_parameter IS 'Attribute configuration parameters'; -CREATE INDEX IF NOT EXISTS att_parameter_recv_time_idx ON att_parameter (recv_time); -CREATE INDEX IF NOT EXISTS att_parameter_att_conf_id_idx ON att_parameter (att_conf_id); -SELECT create_hypertable('att_parameter', 'recv_time', chunk_time_interval => interval '28 day', create_default_indexes => FALSE); - -------------------------------------------------------------------------------- -CREATE TABLE IF NOT EXISTS att_error_desc ( - att_error_desc_id serial NOT NULL, - error_desc text NOT NULL, - PRIMARY KEY (att_error_desc_id), - UNIQUE (error_desc) -); - -COMMENT ON TABLE att_error_desc IS 'Error Description Table'; -CREATE INDEX IF NOT EXISTS att_error_desc_att_error_desc_id_idx ON att_error_desc (att_error_desc_id); - -------------------------------------------------------------------------------- -CREATE TABLE IF NOT EXISTS att_scalar_devboolean ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - value_r boolean, - value_w boolean, - quality smallint, - att_error_desc_id integer, - details json, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_scalar_devboolean IS 'Scalar Boolean Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devboolean_att_conf_id_idx ON att_scalar_devboolean (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devboolean_att_conf_id_data_time_idx ON att_scalar_devboolean (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devboolean', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_array_devboolean ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - value_r boolean[], - value_w boolean[], - quality smallint, - att_error_desc_id integer, - details json, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_array_devboolean IS 'Array Boolean Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devboolean_att_conf_id_idx ON att_array_devboolean (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devboolean_att_conf_id_data_time_idx ON att_array_devboolean (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devboolean', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_scalar_devuchar ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - value_r uchar, - value_w uchar, - quality smallint, - att_error_desc_id integer, - details json, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_scalar_devuchar IS 'Scalar UChar Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devuchar_att_conf_id_idx ON att_scalar_devuchar (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devuchar_att_conf_id_data_time_idx ON att_scalar_devuchar (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devuchar', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_array_devuchar ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - value_r uchar[], - value_w uchar[], - quality smallint, - details json, - att_error_desc_id integer, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_array_devuchar IS 'Array UChar Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devuchar_att_conf_id_idx ON att_array_devuchar (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devuchar_att_conf_id_data_time_idx ON att_array_devuchar (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devuchar', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_scalar_devshort ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - value_r smallint, - value_w smallint, - quality smallint, - details json, - att_error_desc_id integer, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_scalar_devshort IS 'Scalar Short Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devshort_att_conf_id_idx ON att_scalar_devshort (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devshort_att_conf_id_data_time_idx ON att_scalar_devshort (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devshort', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_array_devshort ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - value_r smallint[], - value_w smallint[], - quality smallint, - att_error_desc_id integer, - details json, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_array_devshort IS 'Array Short Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devshort_att_conf_id_idx ON att_array_devshort (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devshort_att_conf_id_data_time_idx ON att_array_devshort (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devshort', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_scalar_devushort ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - value_r ushort, - value_w ushort, - quality smallint, - att_error_desc_id integer, - details json, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_scalar_devushort IS 'Scalar UShort Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devushort_att_conf_id_idx ON att_scalar_devushort (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devushort_att_conf_id_data_time_idx ON att_scalar_devushort (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devushort', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_array_devushort ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - value_r ushort[], - value_w ushort[], - quality smallint, - att_error_desc_id integer, - details json, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_array_devushort IS 'Array UShort Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devushort_att_conf_id_idx ON att_array_devushort (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devushort_att_conf_id_data_time_idx ON att_array_devushort (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devushort', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_scalar_devlong ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - value_r integer, - value_w integer, - quality smallint, - att_error_desc_id integer, - details json, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_scalar_devlong IS 'Scalar Long Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devlong_att_conf_id_idx ON att_scalar_devlong (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devlong_att_conf_id_data_time_idx ON att_scalar_devlong (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devlong', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_array_devlong ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - value_r integer[], - value_w integer[], - quality smallint, - att_error_desc_id integer, - details json, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_array_devlong IS 'Array Long Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devlong_att_conf_id_idx ON att_array_devlong (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devlong_att_conf_id_data_time_idx ON att_array_devlong (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devlong', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_scalar_devulong ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - value_r ulong, - value_w ulong, - quality smallint, - att_error_desc_id integer, - details json, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_scalar_devulong IS 'Scalar ULong Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devulong_att_conf_id_idx ON att_scalar_devulong (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devulong_att_conf_id_data_time_idx ON att_scalar_devulong (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devulong', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_array_devulong ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - value_r ulong[], - value_w ulong[], - quality smallint, - att_error_desc_id integer, - details json, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_array_devulong IS 'Array ULong Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devulong_att_conf_id_idx ON att_array_devulong (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devulong_att_conf_id_data_time_idx ON att_array_devulong (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devulong', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_scalar_devlong64 ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - value_r bigint, - value_w bigint, - quality smallint, - att_error_desc_id integer, - details json, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_scalar_devlong64 IS 'Scalar Long64 Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devlong64_att_conf_id_idx ON att_scalar_devlong64 (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devlong64_att_conf_id_data_time_idx ON att_scalar_devlong64 (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devlong64', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_array_devlong64 ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - value_r bigint[], - value_w bigint[], - quality smallint, - att_error_desc_id integer, - details json, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_array_devlong64 IS 'Array Long64 Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devlong64_att_conf_id_idx ON att_array_devlong64 (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devlong64_att_conf_id_data_time_idx ON att_array_devlong64 (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devlong64', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_scalar_devulong64 ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - value_r ulong64, - value_w ulong64, - quality smallint, - att_error_desc_id integer, - details json, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_scalar_devulong64 IS 'Scalar ULong64 Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devulong64_att_conf_id_idx ON att_scalar_devulong64 (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devulong64_att_conf_id_data_time_idx ON att_scalar_devulong64 (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devulong64', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_array_devulong64 ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - value_r ulong64[], - value_w ulong64[], - quality smallint, - att_error_desc_id integer, - details json, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_array_devulong64 IS 'Array ULong64 Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devulong64_att_conf_id_idx ON att_array_devulong64 (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devulong64_att_conf_id_data_time_idx ON att_array_devulong64 (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devulong64', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_scalar_devfloat ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - value_r real, - value_w real, - quality smallint, - att_error_desc_id integer, - details json, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_scalar_devfloat IS 'Scalar Float Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devfloat_att_conf_id_idx ON att_scalar_devfloat (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devfloat_att_conf_id_data_time_idx ON att_scalar_devfloat (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devfloat', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_array_devfloat ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - value_r real[], - value_w real[], - quality smallint, - att_error_desc_id integer, - details json, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_array_devfloat IS 'Array Float Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devfloat_att_conf_id_idx ON att_array_devfloat (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devfloat_att_conf_id_data_time_idx ON att_array_devfloat (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devfloat', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_scalar_devdouble ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - value_r double precision, - value_w double precision, - quality smallint, - att_error_desc_id integer, - details json, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_scalar_devdouble IS 'Scalar Double Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devdouble_att_conf_id_idx ON att_scalar_devdouble (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devdouble_att_conf_id_data_time_idx ON att_scalar_devdouble (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devdouble', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_array_devdouble ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - value_r double precision[], - value_w double precision[], - quality smallint, - att_error_desc_id integer, - details json, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_array_devdouble IS 'Array Double Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devdouble_att_conf_id_idx ON att_array_devdouble (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devdouble_att_conf_id_data_time_idx ON att_array_devdouble (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devdouble', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_scalar_devstring ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - value_r text, - value_w text, - quality smallint, - att_error_desc_id integer, - details json, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_scalar_devstring IS 'Scalar String Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devstring_att_conf_id_idx ON att_scalar_devstring (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devstring_att_conf_id_data_time_idx ON att_scalar_devstring (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devstring', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_array_devstring ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - value_r text[], - value_w text[], - quality smallint, - att_error_desc_id integer, - details json, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_array_devstring IS 'Array String Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devstring_att_conf_id_idx ON att_array_devstring (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devstring_att_conf_id_data_time_idx ON att_array_devstring (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devstring', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_scalar_devstate ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - value_r integer, - value_w integer, - quality smallint, - att_error_desc_id integer, - details json, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_scalar_devstate IS 'Scalar State Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devstate_att_conf_id_idx ON att_scalar_devstate (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devstate_att_conf_id_data_time_idx ON att_scalar_devstate (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devstate', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_array_devstate ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - value_r integer[], - value_w integer[], - quality smallint, - att_error_desc_id integer, - details json, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_array_devstate IS 'Array State Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devstate_att_conf_id_idx ON att_array_devstate (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devstate_att_conf_id_data_time_idx ON att_array_devstate (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devstate', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_scalar_devenum ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - value_r_label text, - value_r smallint, - value_w_label text, - value_w smallint, - quality smallint, - att_error_desc_id integer, - details json, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_scalar_devenum IS 'Scalar Enum Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devenum_att_conf_id_idx ON att_scalar_devenum (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devenum_att_conf_id_data_time_idx ON att_scalar_devenum (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devenum', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_array_devenum ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - value_r_label text[], - value_r smallint[], - value_w_label text[], - value_w smallint[], - quality smallint, - att_error_desc_id integer, - details json, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); - -COMMENT ON TABLE att_array_devenum IS 'Array Enum Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devenum_att_conf_id_idx ON att_array_devenum (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devenum_att_conf_id_data_time_idx ON att_array_devenum (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devenum', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_scalar_devencoded ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - value_r bytea, - value_w bytea, - quality smallint, - att_error_desc_id integer, - details json, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); -COMMENT ON TABLE att_scalar_devenum IS 'Scalar DevEncoded Values Table'; -CREATE INDEX IF NOT EXISTS att_scalar_devencoded_att_conf_id_idx ON att_scalar_devencoded (att_conf_id); -CREATE INDEX IF NOT EXISTS att_scalar_devencoded_att_conf_id_data_time_idx ON att_scalar_devencoded (att_conf_id,data_time DESC); -SELECT create_hypertable('att_scalar_devencoded', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); - -CREATE TABLE IF NOT EXISTS att_array_devencoded ( - att_conf_id integer NOT NULL, - data_time timestamp with time zone NOT NULL, - value_r bytea[], - value_w bytea[], - quality smallint, - att_error_desc_id integer, - details json, - PRIMARY KEY (att_conf_id, data_time), - FOREIGN KEY (att_conf_id) REFERENCES att_conf (att_conf_id), - FOREIGN KEY (att_error_desc_id) REFERENCES att_error_desc (att_error_desc_id) -); -COMMENT ON TABLE att_array_devenum IS 'Array DevEncoded Values Table'; -CREATE INDEX IF NOT EXISTS att_array_devencoded_att_conf_id_idx ON att_array_devencoded (att_conf_id); -CREATE INDEX IF NOT EXISTS att_array_devencoded_att_conf_id_data_time_idx ON att_array_devencoded (att_conf_id,data_time DESC); -SELECT create_hypertable('att_array_devencoded', 'data_time', chunk_time_interval => interval '1 day', create_default_indexes => FALSE); \ No newline at end of file diff --git a/src/DbConnection.cpp b/src/DbConnection.cpp index 35dc2eb6e935f97739c567cdcdb8cfb83ed51819..26d2287890c7401f133dc4c14f4a744027524ddd 100644 --- a/src/DbConnection.cpp +++ b/src/DbConnection.cpp @@ -347,7 +347,7 @@ namespace pqxx_conn _logger->error("Error message found missing, this occurred when storing msg: \"{}\" for attribute: {}", error_msg, full_attr_name); - + _logger->error("Throwing consistency error with message: \"{}\"", msg); Tango::Except::throw_exception("Consistency Error", msg, LOCATION_INFO); } @@ -496,7 +496,7 @@ namespace pqxx_conn _logger->trace("Created prepared statement for: {}", StoreErrorString); } - auto row = tx.exec_prepared1(StoreErrorString, tx.quote(error_msg)); + auto row = tx.exec_prepared1(StoreErrorString, error_msg); tx.commit(); // we should have a single row with a single result, so attempt to return it diff --git a/src/DbConnection.tpp b/src/DbConnection.tpp index 068589343b8028890bfd60a750feda8b53ef2955..2323eeb83a268d88027c81ae8e9594129f67b822 100644 --- a/src/DbConnection.tpp +++ b/src/DbConnection.tpp @@ -26,8 +26,12 @@ namespace hdbpp { namespace pqxx_conn { + // This namespace containers a collection of specialisations for the storeDataEvent() function. These + // specialisations can not be handled by the main function, so we break them out here. namespace store_data_utils { + //============================================================================= + //============================================================================= template<typename T> struct Preprocess { @@ -41,8 +45,57 @@ namespace pqxx_conn { static void run(std::unique_ptr<std::vector<std::string>> &value, pqxx::work &tx) { - for (auto &str : *value) + cout << "dump " << endl; + + for (auto &str : *value) + cout << str << " "; + + for (auto &str : *value) str = tx.quote(str); + + for (auto &str : *value) + cout << str << " "; + } + }; + + //============================================================================= + //============================================================================= + template<typename T> + struct Store + { + static void run( + std::unique_ptr<std::vector<T>> &value, pqxx::prepare::invocation &inv, const AttributeTraits &traits) + { + // for a scalar, store the first element of the vector, + // we do not expect more than 1 element, for an array, store + // the entire vector + if (traits.isScalar()) + inv((*value)[0]); + else + inv(*value); + } + }; + + //============================================================================= + //============================================================================= + template<> + struct Store<bool> + { + static void run(std::unique_ptr<std::vector<bool>> &value, + pqxx::prepare::invocation &inv, + const AttributeTraits &traits) + { + // a vector<bool> is not actually a vector<bool>, rather its some kind of bitfield. When + // trying to return an element, we appear to get some kind of bitfield reference (?), + // and since we have no way to handle this in the string_traits templates, it causes + // errors. Here we work around it, by creating a local variable and passing that instead + if (traits.isScalar()) + { + bool v = (*value)[0]; + inv(v); + } + else + inv(*value); } }; } // namespace store_data_utils @@ -95,14 +148,7 @@ namespace pqxx_conn { // this ensures strings are quoted and escaped, other types are ignored store_data_utils::Preprocess<T>::run(value, tx); - - // for a scalar, store the first element of the vector, - // we do not expect more than 1 element, for an array, store - // the entire vector - if (traits.isScalar()) - inv((*value)[0]); - else - inv(*value); + store_data_utils::Store<T>::run(value, inv, traits); } else { diff --git a/src/HdbppTxDataEvent.hpp b/src/HdbppTxDataEvent.hpp index a1f5b23655b20bc1173a26e95758cb8a36aec48b..4d3c179487bda56c370c0127f41b4058f0de7b51 100644 --- a/src/HdbppTxDataEvent.hpp +++ b/src/HdbppTxDataEvent.hpp @@ -97,8 +97,7 @@ HdbppTxDataEvent<Conn> &HdbppTxDataEvent<Conn>::store() // doStore the data is extracted and then stored switch (Base::attributeTraits().type()) { - // TODO enable commented out calls. - //case Tango::DEV_BOOLEAN: this->template doStore<bool>(); break; + case Tango::DEV_BOOLEAN: this->template doStore<bool>(); break; case Tango::DEV_SHORT: this->template doStore<int16_t>(); break; case Tango::DEV_LONG: this->template doStore<int32_t>(); break; case Tango::DEV_LONG64: this->template doStore<int64_t>(); break; diff --git a/src/PqxxExtension.hpp b/src/PqxxExtension.hpp index c4d7961583864203ca19fdca52120ffa26ac89d1..ec05de3a01c9bb9f1b53275761d2ba4e53afb3ff 100644 --- a/src/PqxxExtension.hpp +++ b/src/PqxxExtension.hpp @@ -90,6 +90,17 @@ namespace internal static constexpr const char *value = "vector<uint8_t>"; }; + template<> + struct type_name<std::vector<bool>> + { + static constexpr const char *value = "vector<bool>"; + }; + + template<> + struct type_name<std::vector<std::string>> + { + static constexpr const char *value = "vector<std::string>"; + }; } // namespace internal // this is an extension to the pqxx strconv types to allow our engine to @@ -109,14 +120,13 @@ public: if (str == nullptr) internal::throw_null_conversion(name()); - if (str[0] != '{') + if (str[0] != '{' || str[strlen(str) - 1] != '}') throw pqxx::conversion_error("Invalid array format"); value.clear(); - // not the best solution right now, but we are using this for - // testing only. Copy the str into a std::string so we can work - // with it more easily. + // not the best solution right now, but we are using this for testing only + // currently. Copy the str into a std::string so we can work with it more easily. std::string in(str + 1, str + (strlen(str) - 1)); // count commas and add one to deduce elements in the string, @@ -130,13 +140,14 @@ public: value.resize(items + 1); auto element = 0; - std::string::size_type b = 0; + std::string::size_type comma = 0; - while ((b = in.find_first_not_of(',', b)) != std::string::npos) + // loop and copy out each value from between the separators + while ((comma = in.find_first_not_of(',', comma)) != std::string::npos) { - auto e = in.find_first_of(',', b); - string_traits<T>::from_string(in.substr(b, e - b).c_str(), value[element++]); - b = e; + auto next_comma = in.find_first_of(',', comma); + string_traits<T>::from_string(in.substr(comma, next_comma - comma).c_str(), value[element++]); + comma = next_comma; } } @@ -145,25 +156,8 @@ public: if (value.empty()) return {}; - std::string result; - - // guestimate some space to save allocations, this is far from exact - result.reserve(2 * (sizeof(T) * value.size())); - - // when going to a string, the first element does not include - // a comma, so do it separately - result += "{"; - auto begin = value.begin(); - result += pqxx::string_traits<T>::to_string(*begin++); - - for (auto loop = begin; loop != value.end(); ++loop) - { - result += ","; - result += pqxx::string_traits<T>::to_string(*loop); - } - - result += "}"; - return result; + // simply use the pqxx utilities for this, rather than reinvent the wheel + return "{" + separated_list(",", value.begin(), value.end()) + "}"; } }; @@ -183,23 +177,42 @@ public: if (str == nullptr) internal::throw_null_conversion(name()); - auto len = strlen(str); + if (str[0] != '{' || str[strlen(str) - 1] != '}') + throw pqxx::conversion_error("Invalid array format"); + value.clear(); - //for (std::size_t i{2}; i < len;) - //{ - //value.emplace_back(from_hex(str[i], str[i + 1])); - //i += 2; - //} + // not the best solution right now, but we are using this for testing only + // currently. Copy the str into a std::string so we can work with it more easily. + std::string in(str + 1, str + (strlen(str) - 1)); + std::string sep {"','"}; + size_t last_position = 1; + size_t position = in.find(sep, 0); + + // as mention above, this could probably be sped up, i.e. preallocate + // the vector etc, but for now we just need it for testing, so improvements + // are left till later + while (position != std::string::npos) + { + value.push_back(in.substr(last_position, position - last_position)); + last_position = position + 3; + position = in.find(sep, position + 1); + } + + std::cout << "ITS " << str << std::endl; } static std::string to_string(const std::vector<std::string> &value) { + // simply use the pqxx utilities for this, rather than reinvent the wheel return "{" + separated_list(",", value.begin(), value.end()) + "}"; } }; -/*template<> +// This specialisation is for bool, since it is not a normal container class, but +// rather some kind of bitfield. We have to adjust the from_string to take into +// account we can not use container element access +template<> struct string_traits<std::vector<bool>> { public: @@ -212,16 +225,44 @@ public: { if (str == nullptr) internal::throw_null_conversion(name()); + + if (str[0] != '{' || str[strlen(str) - 1] != '}') + throw pqxx::conversion_error("Invalid array format"); + + value.clear(); + + // not the best solution right now, but we are using this for + // testing only. Copy the str into a std::string so we can work + // with it more easily. + std::string in(str + 1, str + (strlen(str) - 1)); + std::string::size_type comma = 0; + + // loop and copy out each value from between the separators + while ((comma = in.find_first_not_of(',', comma)) != std::string::npos) + { + auto next_comma = in.find_first_of(',', comma); + + // we can not pass an element of the vector, since vector<bool> is not + // in fact a container, but some kind of bit field. In this case, we + // have to create a local variable to read the value into, then push this + // back onto the vector + bool field; + string_traits<bool>::from_string(in.substr(comma, next_comma - comma).c_str(), field); + value.push_back(field); + + comma = next_comma; + } } static std::string to_string(const std::vector<bool> &value) { - //if (value.empty()) - // return {}; + if (value.empty()) + return {}; - return "{"; //+ separated_list(",", value.begin(), value.end()) + "}"; + // simply use the pqxx utilities for this, rather than reinvent the wheel + return "{" + separated_list(",", value.begin(), value.end()) + "}"; } -};*/ +}; // Specialization for unsigned char, which was not included in pqxx, // this becomes an int16_t in the database diff --git a/test/DbConnectionTests.cpp b/test/DbConnectionTests.cpp index 166c81dde6df0a38bcc3783262706d8b3dadae84..695fed0ef4d30f0ce7f0411ce0ebf6be7b355ccf 100644 --- a/test/DbConnectionTests.cpp +++ b/test/DbConnectionTests.cpp @@ -84,6 +84,8 @@ tuple<vector<typename TangoTypeTraits<Type>::type>, vector<typename TangoTypeTra template<typename T> bool compareData(T lhs, T rhs) { + // just to help debug + REQUIRE(lhs == rhs); return lhs == rhs; } @@ -126,6 +128,8 @@ bool compareData<double>(double lhs, double rhs) template<typename T> bool compareVector(const vector<T> &lhs, const vector<T> &rhs) { + // just to help debug + REQUIRE(lhs == rhs); return lhs == rhs; } @@ -615,7 +619,7 @@ SCENARIO("Storing Parameter Events in the database", "[db-access][hdbpp-db-acces if (test_conn.is_open()) test_conn.disconnect(); } - +/* SCENARIO("Storing Parameter Events in a disconnected state", "[db-access][hdbpp-db-access][db-connection][psql]") { struct timeval tv; @@ -743,7 +747,7 @@ SCENARIO("Storing event data which is invalid", "[db-access][hdbpp-db-access][db if (test_conn.is_open()) test_conn.disconnect(); } - +*/ TEST_CASE("Storing event data of all Tango type combinations in the database", "[db-access][hdbpp-db-access][db-connection][psql]") { @@ -754,13 +758,10 @@ TEST_CASE("Storing event data of all Tango type combinations in the database", pqxx::connection test_conn(postgres_db::HdbppConnectionString); psql_conn_test::clearTable(test_conn, CONF_TABLE_NAME); - // vector<unsigned int> types{ - // Tango::DEV_DOUBLE, Tango::DEV_FLOAT, Tango::DEV_STRING, Tango::DEV_LONG, Tango::DEV_ULONG, - // Tango::DEV_LONG64, Tango::DEV_ULONG64, Tango::DEV_SHORT, Tango::DEV_USHORT, Tango::DEV_BOOLEAN, - // Tango::DEV_UCHAR, Tango::DEV_STATE, Tango::DEV_ENCODED, Tango::DEV_ENUM} - - vector<unsigned int> types {Tango::DEV_DOUBLE, - Tango::DEV_FLOAT, + vector<unsigned int> types { +// Tango::DEV_BOOLEAN, + // Tango::DEV_DOUBLE, + // Tango::DEV_FLOAT, Tango::DEV_STRING, Tango::DEV_LONG, Tango::DEV_ULONG, @@ -769,7 +770,9 @@ TEST_CASE("Storing event data of all Tango type combinations in the database", Tango::DEV_SHORT, Tango::DEV_USHORT, Tango::DEV_UCHAR, - Tango::DEV_STATE}; + Tango::DEV_STATE, + //Tango::DEV_ENCODED, Tango::DEV_ENUM + }; vector<Tango::AttrWriteType> write_types {Tango::READ, Tango::WRITE, Tango::READ_WRITE, Tango::READ_WITH_WRITE}; vector<Tango::AttrDataFormat> format_types {Tango::SCALAR, Tango::SPECTRUM}; @@ -789,12 +792,11 @@ TEST_CASE("Storing event data of all Tango type combinations in the database", switch (traits.type()) { - // TODO enable commented out calls. - //case Tango::DEV_BOOLEAN: - //psql_conn_test::checkStoreTestEventData( - //test_conn, traits, psql_conn_test::storeTestEventData<Tango::DEV_BOOLEAN>(conn, traits)); + case Tango::DEV_BOOLEAN: + psql_conn_test::checkStoreTestEventData( + test_conn, traits, psql_conn_test::storeTestEventData<Tango::DEV_BOOLEAN>(conn, traits)); - //break; + break; case Tango::DEV_SHORT: psql_conn_test::checkStoreTestEventData( diff --git a/test/HdbppTxDataEventTests.cpp b/test/HdbppTxDataEventTests.cpp index cdc2378ef1bb3e8db927ad6c05c30300078193e6..b96307d7b1ccccf29739d08144990a23c734958a 100644 --- a/test/HdbppTxDataEventTests.cpp +++ b/test/HdbppTxDataEventTests.cpp @@ -37,7 +37,6 @@ Tango::DeviceAttribute createDeviceAttribute(const AttributeTraits &traits) auto attr_gen = [&traits](int size_x, int size_y) { switch (traits.type()) { - // TODO enable commented out calls. case Tango::DEV_BOOLEAN: return Tango::DeviceAttribute( TestAttrFQDName.c_str(), *generateSpectrumData<Tango::DEV_BOOLEAN>(false, size_x + size_y)); diff --git a/test/TestHelpers.cpp b/test/TestHelpers.cpp index 63217f7fd9be30d6ad11506e4441fbe1dbfc9e1a..3dc906a2786971dc18cd8376f3fa67cce947a231 100644 --- a/test/TestHelpers.cpp +++ b/test/TestHelpers.cpp @@ -206,7 +206,10 @@ namespace data_gen "it's", "going", "to", - "taste"}; + "taste", + "more test's", + "test '' quotes", + "test \a escape"}; auto value = make_unique<vector<typename TangoTypeTraits<Tango::DEV_STRING>::type>>(); diff --git a/test/TestHelpers.hpp b/test/TestHelpers.hpp index b4ad8e35bb0729a55798fb428a7558c5bb998ccb..00e31e4690c3d2e3db8c32b5da1363b050701b0f 100644 --- a/test/TestHelpers.hpp +++ b/test/TestHelpers.hpp @@ -66,11 +66,11 @@ namespace attr_name namespace attr_info { - const std::string AttrInfoDescription = "Description"; + const std::string AttrInfoDescription = "Description about attribute, its \"quoted\", and 'quoted', yet does it work?"; const std::string AttrInfoLabel = "Label"; - const std::string AttrInfoUnit = "Unit"; + const std::string AttrInfoUnit = "Unit %"; const std::string AttrInfoStandardUnit = "Standard Unit"; - const std::string AttrInfoDisplayUnit = "Display Unit"; + const std::string AttrInfoDisplayUnit = "Display Unit $"; const std::string AttrInfoFormat = "Format"; const std::string AttrInfoRel = "Rel"; const std::string AttrInfoAbs = "Abs"; diff --git a/test/main.cpp b/test/main.cpp index 2a7e0b16f87e03f7caeebbcacaa094c1999e92fe..58729e804ab4002f8226892edcd7293fed98f2a3 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -26,7 +26,7 @@ int main(int argc, char *argv[]) { // console only warning level logging hdbpp::LogConfigurator::initLogging(false, true); - hdbpp::LogConfigurator::setLoggingLevel(spdlog::level::trace); + hdbpp::LogConfigurator::setLoggingLevel(spdlog::level::err); int result = Catch::Session().run(argc, argv);