Refine scada tables

This commit is contained in:
WQY\qiong
2023-02-24 13:47:24 +08:00
parent c3ae9b306f
commit cef631b41b
10 changed files with 35 additions and 27 deletions

View File

@@ -0,0 +1,9 @@
create type scada_device_type as enum ('PRESSURE', 'DEMAND', 'QUALITY', 'LEVEL', 'FLOW');
create table scada_device
(
id text primary key
, name text
, address text
, type scada_device_type
);

View File

@@ -1,15 +0,0 @@
create type scada_type as enum ('PRESSURE', 'DEMAND', 'QUALITY', 'LEVEL', 'FLOW');
create type scada_status as enum ('OFF', 'ON');
create table scada_model
(
id text primary key
, x numeric not null
, y numeric not null
, device_id text not null unique
, device_name text
, address text
, type scada_type
, model_id varchar(32) -- add constraint in API
, status scada_status not null default 'OFF'
);

View File

@@ -1,6 +1,6 @@
create table scada_data
create table scada_device_data
(
device_id text not null references scada_model(device_id)
device_id text not null references scada_device(id)
, time timestamp not null
, value numeric not null
, primary key (device_id, time)

View File

@@ -0,0 +1,11 @@
create type scada_element_status as enum ('OFF', 'ON');
create table scada_element
(
id text primary key
, x numeric not null
, y numeric not null
, device_id text references scada_device(id)
, model_id varchar(32) -- add constraint in API
, status scada_element_status not null default 'OFF'
);

View File

@@ -0,0 +1,3 @@
drop table if exists scada_device;
drop type if exists scada_device_type;

View File

@@ -1,5 +0,0 @@
drop table if exists scada_model;
drop type if exists scada_status;
drop type if exists scada_type;

View File

@@ -1 +0,0 @@
drop table if exists scada_data;

View File

@@ -0,0 +1 @@
drop table if exists scada_device_data;

View File

@@ -0,0 +1,3 @@
drop table if exists scada_element;
drop type if exists scada_element_status;