Saves data from the TIC (Enedis Tele Information Client) received from MQTT to a TimescaleDB
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
692 B

-- +goose Up
CREATE TABLE current (
time TIMESTAMP (0) WITHOUT TIME ZONE NOT NULL,
phase INTEGER NOT NULL DEFAULT(0),
current INTEGER NOT NULL,
UNIQUE (time, phase)
);
CREATE TABLE power (
time TIMESTAMP (0) WITHOUT TIME ZONE UNIQUE NOT NULL,
power INTEGER NOT NULL
);
CREATE TABLE energy (
time TIMESTAMP (0) WITHOUT TIME ZONE NOT NULL,
tariff TEXT NOT NULL,
reading INTEGER NOT NULL,
UNIQUE (time, tariff)
);
SELECT create_hypertable('current','time');
SELECT create_hypertable('power','time');
SELECT create_hypertable('energy','time');
-- +goose Down
DROP TABLE current;
DROP TABLE power;
DROP TABLE energy;