-- basic information of bay

-- DROP TABLE IF EXISTS PUBLIC.BAY;

CREATE TABLE PUBLIC.BAY (
    ID SERIAL PRIMARY KEY,
  	NAME VARCHAR(64) NOT NULL DEFAULT '',
  	TYPE VARCHAR(64) NOT NULL DEFAULT '',
    NOMINAL_VOLTAGE DOUBLE PRECISION NOT NULL DEFAULT -1,
    FLA DOUBLE PRECISION NOT NULL DEFAULT -1,
    CAPACITY DOUBLE PRECISION NOT NULL DEFAULT -1,
    DESCRIPTION VARCHAR(512) NOT NULL DEFAULT '',
    IN_SERVICE BOOLEAN NOT NULL DEFAULT FALSE,
    STATE INTEGER NOT NULL DEFAULT -1,
    GRID VARCHAR(64) NOT NULL DEFAULT '',
    ZONE VARCHAR(64) NOT NULL DEFAULT '',
    STATION VARCHAR(64) NOT NULL DEFAULT '',
    BUSINESS JSONB NOT NULL DEFAULT '{}', -- {'unom':0.0,'bus_connected':''}
  	FROM_UUIDS JSONB NOT NULL DEFAULT '[]', -- uuids
  	TO_UUIDS JSONB NOT NULL DEFAULT '[]', -- uuids
	OP INTEGER NOT NULL DEFAULT -1,
    TS TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP 
);