solar-toolkit/gateway/sql/migrations/20220713135223_create_runti...

79 lines
4.1 KiB
SQL

CREATE TABLE et_runtime_data (
timestamp TIMESTAMP WITH TIME ZONE NOT NULL,
pv1_voltage DOUBLE PRECISION NOT NULL DEFAULT 0.0,
pv1_current DOUBLE PRECISION NOT NULL DEFAULT 0.0,
pv1_power DOUBLE PRECISION NOT NULL DEFAULT 0.0,
pv2_voltage DOUBLE PRECISION NOT NULL DEFAULT 0.0,
pv2_current DOUBLE PRECISION NOT NULL DEFAULT 0.0,
pv2_power DOUBLE PRECISION NOT NULL DEFAULT 0.0,
pv_power DOUBLE PRECISION NOT NULL DEFAULT 0.0,
pv2_mode INT NOT NULL DEFAULT 0,
pv1_mode INT NOT NULL DEFAULT 0,
on_grid_l1_voltage DOUBLE PRECISION NOT NULL DEFAULT 0.0,
on_grid_l1_current DOUBLE PRECISION NOT NULL DEFAULT 0.0,
on_grid_l1_frequency DOUBLE PRECISION NOT NULL DEFAULT 0.0,
on_grid_l1_power DOUBLE PRECISION NOT NULL DEFAULT 0.0,
on_grid_l2_voltage DOUBLE PRECISION NOT NULL DEFAULT 0.0,
on_grid_l2_current DOUBLE PRECISION NOT NULL DEFAULT 0.0,
on_grid_l2_frequency DOUBLE PRECISION NOT NULL DEFAULT 0.0,
on_grid_l2_power DOUBLE PRECISION NOT NULL DEFAULT 0.0,
on_grid_l3_voltage DOUBLE PRECISION NOT NULL DEFAULT 0.0,
on_grid_l3_current DOUBLE PRECISION NOT NULL DEFAULT 0.0,
on_grid_l3_frequency DOUBLE PRECISION NOT NULL DEFAULT 0.0,
on_grid_l3_power DOUBLE PRECISION NOT NULL DEFAULT 0.0,
grid_mode INT NOT NULL DEFAULT 0,
total_inverter_power DOUBLE PRECISION NOT NULL DEFAULT 0.0,
active_power DOUBLE PRECISION NOT NULL DEFAULT 0.0,
reactive_power DOUBLE PRECISION NOT NULL DEFAULT 0.0,
apparent_power DOUBLE PRECISION NOT NULL DEFAULT 0.0,
backup_l1_voltage DOUBLE PRECISION NOT NULL DEFAULT 0.0,
backup_l1_current DOUBLE PRECISION NOT NULL DEFAULT 0.0,
backup_l1_frequency DOUBLE PRECISION NOT NULL DEFAULT 0.0,
load_mode_l1 INT NOT NULL DEFAULT 0,
backup_l1_power DOUBLE PRECISION NOT NULL DEFAULT 0.0,
backup_l2_voltage DOUBLE PRECISION NOT NULL DEFAULT 0.0,
backup_l2_current DOUBLE PRECISION NOT NULL DEFAULT 0.0,
backup_l2_frequency DOUBLE PRECISION NOT NULL DEFAULT 0.0,
load_mode_l2 INT NOT NULL DEFAULT 0,
backup_l2_power DOUBLE PRECISION NOT NULL DEFAULT 0.0,
backup_l3_voltage DOUBLE PRECISION NOT NULL DEFAULT 0.0,
backup_l3_current DOUBLE PRECISION NOT NULL DEFAULT 0.0,
backup_l3_frequency DOUBLE PRECISION NOT NULL DEFAULT 0.0,
load_mode_l3 INT NOT NULL DEFAULT 0,
backup_l3_power DOUBLE PRECISION NOT NULL DEFAULT 0.0,
load_l1 DOUBLE PRECISION NOT NULL DEFAULT 0.0,
load_l2 DOUBLE PRECISION NOT NULL DEFAULT 0.0,
load_l3 DOUBLE PRECISION NOT NULL DEFAULT 0.0,
backup_load DOUBLE PRECISION NOT NULL DEFAULT 0.0,
load DOUBLE PRECISION NOT NULL DEFAULT 0.0,
ups_load DOUBLE PRECISION NOT NULL DEFAULT 0.0,
temperature_air DOUBLE PRECISION NOT NULL DEFAULT 0.0,
temperature_module DOUBLE PRECISION NOT NULL DEFAULT 0.0,
temperature DOUBLE PRECISION NOT NULL DEFAULT 0.0,
bus_voltage DOUBLE PRECISION NOT NULL DEFAULT 0.0,
nbus_voltage DOUBLE PRECISION NOT NULL DEFAULT 0.0,
battery_voltage DOUBLE PRECISION NOT NULL DEFAULT 0.0,
battery_current DOUBLE PRECISION NOT NULL DEFAULT 0.0,
battery_mode INT NOT NULL DEFAULT 0,
warning_code INT NOT NULL DEFAULT 0,
safety_country_code INT NOT NULL DEFAULT 0,
work_mode INT NOT NULL DEFAULT 0,
operation_code INT NOT NULL DEFAULT 0,
energy_generation_total DOUBLE PRECISION NOT NULL DEFAULT 0.0,
energy_generation_today DOUBLE PRECISION NOT NULL DEFAULT 0.0,
energy_export_total DOUBLE PRECISION NOT NULL DEFAULT 0.0,
energy_export_total_hours DOUBLE PRECISION NOT NULL DEFAULT 0.0,
energy_export_today DOUBLE PRECISION NOT NULL DEFAULT 0.0,
energy_import_total DOUBLE PRECISION NOT NULL DEFAULT 0.0,
energy_import_today DOUBLE PRECISION NOT NULL DEFAULT 0.0,
energy_load_total DOUBLE PRECISION NOT NULL DEFAULT 0.0,
energy_load_day DOUBLE PRECISION NOT NULL DEFAULT 0.0,
battery_charge_total DOUBLE PRECISION NOT NULL DEFAULT 0.0,
battery_charge_today DOUBLE PRECISION NOT NULL DEFAULT 0.0,
battery_discharge_total DOUBLE PRECISION NOT NULL DEFAULT 0.0,
battery_discharge_today DOUBLE PRECISION NOT NULL DEFAULT 0.0,
house_consumption DOUBLE PRECISION NOT NULL DEFAULT 0.0
);
CREATE UNIQUE INDEX index_et_runtime_data_on_timestamp ON et_runtime_data (timestamp);