From 508822c91cd43d925ba3323f5454998cef71cead Mon Sep 17 00:00:00 2001 From: "WQY\\qiong" Date: Sat, 22 Oct 2022 10:57:35 +0800 Subject: [PATCH] Refine status schema --- script/sql/create/10.status.sql | 28 +++++----------------------- script/sql/drop/10.status.sql | 12 ++---------- 2 files changed, 7 insertions(+), 33 deletions(-) diff --git a/script/sql/create/10.status.sql b/script/sql/create/10.status.sql index 44f007b..68f001a 100644 --- a/script/sql/create/10.status.sql +++ b/script/sql/create/10.status.sql @@ -1,29 +1,11 @@ -- [STATUS] -create type status_pipe_pump_status as enum ('open', 'closed'); +create type link_status as enum ('OPEN', 'CLOSED', 'ACTIVE'); -create table status_pipe -( - id varchar(32) primary key references pipes(id) -, status status_pipe_pump_status not null -); - -create table status_pump -( - id varchar(32) primary key references pumps(id) -, status status_pipe_pump_status not null -); - -create type status_valve_status as enum ('open', 'closed', 'active'); - -create table status_valve -( - id varchar(32) primary key references valves(id) -, status status_valve_status not null -); - -create table status_link +create table status ( id varchar(32) primary key references _link(id) -, setting numeric not null +, l_status link_status +, setting numeric +, check (l_status is not null or setting is not null) ); diff --git a/script/sql/drop/10.status.sql b/script/sql/drop/10.status.sql index c3273b3..fe43c43 100644 --- a/script/sql/drop/10.status.sql +++ b/script/sql/drop/10.status.sql @@ -1,13 +1,5 @@ -- [STATUS] -drop table if exists status_link; +drop table if exists status; -drop table if exists status_valve; - -drop type if exists status_valve_status; - -drop table if exists status_pump; - -drop table if exists status_pipe; - -drop type if exists status_pipe_pump_status; +drop type if exists link_status;