Refine scada tables
This commit is contained in:
9
script/sql/create/29.scada_device.sql
Normal file
9
script/sql/create/29.scada_device.sql
Normal 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
|
||||
);
|
||||
@@ -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'
|
||||
);
|
||||
@@ -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)
|
||||
11
script/sql/create/31.scada_element.sql
Normal file
11
script/sql/create/31.scada_element.sql
Normal 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'
|
||||
);
|
||||
3
script/sql/drop/29.scada_device.sql
Normal file
3
script/sql/drop/29.scada_device.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
drop table if exists scada_device;
|
||||
|
||||
drop type if exists scada_device_type;
|
||||
@@ -1,5 +0,0 @@
|
||||
drop table if exists scada_model;
|
||||
|
||||
drop type if exists scada_status;
|
||||
|
||||
drop type if exists scada_type;
|
||||
@@ -1 +0,0 @@
|
||||
drop table if exists scada_data;
|
||||
1
script/sql/drop/30.scada_device_data.sql
Normal file
1
script/sql/drop/30.scada_device_data.sql
Normal file
@@ -0,0 +1 @@
|
||||
drop table if exists scada_device_data;
|
||||
3
script/sql/drop/31.scada_element.sql
Normal file
3
script/sql/drop/31.scada_element.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
drop table if exists scada_element;
|
||||
|
||||
drop type if exists scada_element_status;
|
||||
Reference in New Issue
Block a user