-- measurement of component in bay

-- DROP TABLE IF EXISTS PUBLIC.MEASUREMENT;

CREATE TABLE PUBLIC.MEASUREMENT (
    ID SERIAL PRIMARY KEY,
    TAG VARCHAR(64) NOT NULL DEFAULT '',
    NAME VARCHAR(64) NOT NULL DEFAULT '',
    TYPE SMALLINT NOT NULL DEFAULT -1,
    DATA_SOURCE JSONB NOT NULL DEFAULT '{}', -- {'type':,'main_pos':'','sub_pos':''}
    SIZE INTEGER NOT NULL DEFAULT -1,
    BAY_ID INTEGER NOT NULL DEFAULT -1,
    COMPONENT_ID INTEGER NOT NULL DEFAULT -1,
    OP INTEGER NOT NULL DEFAULT -1,
    TS TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP 
);