diff --git a/script/sql/create/0.base.sql b/script/sql/create/0.base.sql index e936579..0d508f0 100644 --- a/script/sql/create/0.base.sql +++ b/script/sql/create/0.base.sql @@ -1,25 +1,25 @@ -CREATE TYPE _NODE_TYPE AS ENUM ('junction', 'reservoir', 'tank'); +create type _node_type as enum ('junction', 'reservoir', 'tank'); -CREATE TYPE _LINK_TYPE AS ENUM ('pipe', 'pump', 'valve'); +create type _link_type as enum ('pipe', 'pump', 'valve'); -CREATE TABLE _NODE +create table _node ( - ID VARCHAR(32) PRIMARY KEY -, Type _NODE_TYPE NOT NULL + id varchar(32) primary key +, type _node_type not null ); -CREATE TABLE _LINK +create table _link ( - ID VARCHAR(32) PRIMARY KEY -, Type _LINK_TYPE NOT NULL + id varchar(32) primary key +, type _link_type not null ); -CREATE TABLE _CURVE +create table _curve ( - ID VARCHAR(32) PRIMARY KEY + id varchar(32) primary key ); -CREATE TABLE _PATTERN +create table _pattern ( - ID VARCHAR(32) PRIMARY KEY + id varchar(32) primary key ); diff --git a/script/sql/create/1.title.sql b/script/sql/create/1.title.sql index c00e981..36e6d5b 100644 --- a/script/sql/create/1.title.sql +++ b/script/sql/create/1.title.sql @@ -1,8 +1,8 @@ -- [TITLE] -CREATE TABLE TITLE +create table title ( - Value TEXT + value text ); -INSERT INTO TITLE (Value) VALUES (''); +insert into title (value) values (''); diff --git a/script/sql/create/10.status.sql b/script/sql/create/10.status.sql index 34da1f7..44f007b 100644 --- a/script/sql/create/10.status.sql +++ b/script/sql/create/10.status.sql @@ -1,29 +1,29 @@ -- [STATUS] -CREATE TYPE STATUS_PIPE_PUMP_STATUS AS ENUM ('OPEN', 'CLOSED'); +create type status_pipe_pump_status as enum ('open', 'closed'); -CREATE TABLE STATUS_PIPE +create table status_pipe ( - ID VARCHAR(32) PRIMARY KEY REFERENCES PIPES(ID) -, Status STATUS_PIPE_PUMP_STATUS NOT NULL + id varchar(32) primary key references pipes(id) +, status status_pipe_pump_status not null ); -CREATE TABLE STATUS_PUMP +create table status_pump ( - ID VARCHAR(32) PRIMARY KEY REFERENCES PUMPS(ID) -, Status STATUS_PIPE_PUMP_STATUS NOT NULL + 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 type status_valve_status as enum ('open', 'closed', 'active'); -CREATE TABLE STATUS_VALVE +create table status_valve ( - ID VARCHAR(32) PRIMARY KEY REFERENCES VALVES(ID) -, Status STATUS_VALVE_STATUS NOT NULL + id varchar(32) primary key references valves(id) +, status status_valve_status not null ); -CREATE TABLE STATUS_LINK +create table status_link ( - ID VARCHAR(32) PRIMARY KEY REFERENCES _LINK(ID) -, Setting NUMERIC NOT NULL + id varchar(32) primary key references _link(id) +, setting numeric not null ); diff --git a/script/sql/create/11.patterns.sql b/script/sql/create/11.patterns.sql index dfb23b0..d6aaa4e 100644 --- a/script/sql/create/11.patterns.sql +++ b/script/sql/create/11.patterns.sql @@ -1,7 +1,7 @@ -- [PATTERNS] -CREATE TABLE PATTERNS +create table patterns ( - ID VARCHAR(32) REFERENCES _PATTERN(ID) NOT NULL -, Multipliers NUMERIC NOT NULL + id varchar(32) references _pattern(id) not null +, multipliers numeric not null ); diff --git a/script/sql/create/12.curves.sql b/script/sql/create/12.curves.sql index ac2460e..11ae78b 100644 --- a/script/sql/create/12.curves.sql +++ b/script/sql/create/12.curves.sql @@ -1,8 +1,8 @@ -- [CURVES] -CREATE TABLE CURVES +create table curves ( - ID VARCHAR(32) REFERENCES _CURVE(ID) NOT NULL -, X NUMERIC NOT NULL -, Y NUMERIC NOT NULL + id varchar(32) references _curve(id) not null +, x numeric not null +, y numeric not null ); diff --git a/script/sql/create/13.controls.sql b/script/sql/create/13.controls.sql index 71e74da..c5930ab 100644 --- a/script/sql/create/13.controls.sql +++ b/script/sql/create/13.controls.sql @@ -1,30 +1,30 @@ -- [CONTROLS] -CREATE TYPE CONTROLS_1_PREP AS ENUM ('ABOVE', 'BELOW'); +create type controls_1_prep as enum ('above', 'below'); -- LINK linkID status IF NODE nodeID ABOVE / BELOW value -CREATE TABLE CONTROLS_1 +create table controls_1 ( - LinkID VARCHAR(32) PRIMARY KEY REFERENCES _LINK(ID) -, Status TEXT NOT NULL -- OPEN / CLOSED, a pump speed setting, or a control valve setting -, NodeID VARCHAR(32) REFERENCES _NODE(ID) NOT NULL -, Prep CONTROLS_1_PREP NOT NULL -, Value NUMERIC NOT NULL + linkid varchar(32) primary key references _link(id) +, status text not null -- open / closed, a pump speed setting, or a control valve setting +, nodeid varchar(32) references _node(id) not null +, prep controls_1_prep not null +, value numeric not null ); -- LINK linkID status AT TIME time -CREATE TABLE CONTROLS_2 +create table controls_2 ( - LinkID VARCHAR(32) PRIMARY KEY REFERENCES _LINK(ID) -, Status TEXT NOT NULL -- OPEN / CLOSED, a pump speed setting, or a control valve setting -, Time INTERVAL HOUR + linkid varchar(32) primary key references _link(id) +, status text not null -- open / closed, a pump speed setting, or a control valve setting +, time interval hour ); -- LINK linkID status AT CLOCKTIME clocktime AM / PM -CREATE TABLE CONTROLS_3 +create table controls_3 ( - LinkID VARCHAR(32) PRIMARY KEY REFERENCES _LINK(ID) -, Status TEXT NOT NULL -- OPEN / CLOSED, a pump speed setting, or a control valve setting -, Clock_Time_Hour INTERVAL HOUR -- get AM/PM from it -, Clock_Time_Min INTERVAL MINUTE + linkid varchar(32) primary key references _link(id) +, status text not null -- open / closed, a pump speed setting, or a control valve setting +, clock_time_hour interval hour -- get am/pm from it +, clock_time_min interval minute ); diff --git a/script/sql/create/14.rules.sql b/script/sql/create/14.rules.sql index 7d288ca..7fb07d5 100644 --- a/script/sql/create/14.rules.sql +++ b/script/sql/create/14.rules.sql @@ -1,6 +1,6 @@ -- [RULES] -CREATE TABLE RULES +create table rules ( - Content TEXT PRIMARY KEY + content text primary key ); diff --git a/script/sql/create/15.energy.sql b/script/sql/create/15.energy.sql index a73a3db..dfb89ce 100644 --- a/script/sql/create/15.energy.sql +++ b/script/sql/create/15.energy.sql @@ -1,24 +1,24 @@ -- [ENERGY] -CREATE TYPE ENERGY_PARAM AS ENUM ('PRICE', 'PATTERN', 'EFFIC'); +create type energy_param as enum ('price', 'pattern', 'effic'); -- GLOBAL PRICE / PATTERN / EFFIC value -CREATE TABLE ENERGY_GLOBAL +create table energy_global ( - Param ENERGY_PARAM NOT NULL -, Value NUMERIC NOT NULL + param energy_param not null +, value numeric not null ); -- PUMP pumpID PRICE / PATTERN / EFFIC value -CREATE TABLE ENERGY_PUMP +create table energy_pump ( - ID VARCHAR(32) REFERENCES PUMPS(ID) NOT NULL -, Param ENERGY_PARAM NOT NULL -, Value NUMERIC NOT NULL + id varchar(32) references pumps(id) not null +, param energy_param not null +, value numeric not null ); -- DEMAND CHARGE value -CREATE TABLE ENERGY_DEMAND_CHARGE +create table energy_demand_charge ( - Value NUMERIC NOT NULL + value numeric not null ); diff --git a/script/sql/create/16.emitters.sql b/script/sql/create/16.emitters.sql index b1fe8b4..74744e7 100644 --- a/script/sql/create/16.emitters.sql +++ b/script/sql/create/16.emitters.sql @@ -1,7 +1,7 @@ -- [EMITTERS] -CREATE TABLE EMITTERS +create table emitters ( - Junction VARCHAR(32) PRIMARY KEY REFERENCES JUNCTIONS(ID) -, Coefficient NUMERIC NOT NULL + junction varchar(32) primary key references junctions(id) +, coefficient numeric not null ); diff --git a/script/sql/create/17.quality.sql b/script/sql/create/17.quality.sql index 939e309..af1a83a 100644 --- a/script/sql/create/17.quality.sql +++ b/script/sql/create/17.quality.sql @@ -1,7 +1,7 @@ -- [QUALITY] -CREATE TABLE QUALITY +create table quality ( - Node VARCHAR(32) PRIMARY KEY REFERENCES _NODE(ID) -, InitialQual NUMERIC NOT NULL + node varchar(32) primary key references _node(id) +, initialqual numeric not null ); diff --git a/script/sql/create/18.sources.sql b/script/sql/create/18.sources.sql index 08009f2..0da8c6f 100644 --- a/script/sql/create/18.sources.sql +++ b/script/sql/create/18.sources.sql @@ -1,11 +1,11 @@ -- [SOURCES] -CREATE TYPE SOURCES_TYPE AS ENUM ('CONCEN', 'MASS', 'FLOWPACED', 'SETPOINT'); +create type sources_type as enum ('concen', 'mass', 'flowpaced', 'setpoint'); -CREATE TABLE SOURCES +create table sources ( - Node VARCHAR(32) PRIMARY KEY REFERENCES _NODE(ID) -, Type SOURCES_TYPE NOT NULL -, Strength NUMERIC NOT NULL -, Time_Pattern VARCHAR(32) REFERENCES _PATTERN(ID) + node varchar(32) primary key references _node(id) +, type sources_type not null +, strength numeric not null +, time_pattern varchar(32) references _pattern(id) ); diff --git a/script/sql/create/19.reactions.sql b/script/sql/create/19.reactions.sql index 0d8d13b..ff05a7e 100644 --- a/script/sql/create/19.reactions.sql +++ b/script/sql/create/19.reactions.sql @@ -1,42 +1,42 @@ -- [REACTIONS] -CREATE TYPE REACTIONS_ORDER_PARAM AS ENUM ('BULK', 'WALL', 'TANK'); +create type reactions_order_param as enum ('bulk', 'wall', 'tank'); -CREATE TABLE REACTIONS_ORDER +create table reactions_order ( - Key REACTIONS_ORDER_PARAM NOT NULL -, Value NUMERIC NOT NULL + key reactions_order_param not null +, value numeric not null ); -CREATE TYPE REACTIONS_GLOBAL_PARAM AS ENUM ('BULK', 'WALL'); +create type reactions_global_param as enum ('bulk', 'wall'); -CREATE TABLE REACTIONS_GLOBAL +create table reactions_global ( - Key REACTIONS_GLOBAL_PARAM NOT NULL -, Value NUMERIC NOT NULL + key reactions_global_param not null +, value numeric not null ); -CREATE TYPE REACTIONS_PIPE_PARAM AS ENUM ('BULK', 'WALL'); +create type reactions_pipe_param as enum ('bulk', 'wall'); -CREATE TABLE REACTIONS_PIPE +create table reactions_pipe ( - Key REACTIONS_PIPE_PARAM NOT NULL -, Pipe VARCHAR(32) REFERENCES PIPES(ID) NOT NULL -, Value NUMERIC NOT NULL + key reactions_pipe_param not null +, pipe varchar(32) references pipes(id) not null +, value numeric not null ); -CREATE TABLE REACTIONS_TANK +create table reactions_tank ( - Tank VARCHAR(32) REFERENCES TANKS(ID) NOT NULL -, Value NUMERIC NOT NULL + tank varchar(32) references tanks(id) not null +, value numeric not null ); -CREATE TABLE REACTIONS_LIMITING_POTENTIAL +create table reactions_limiting_potential ( - Value NUMERIC NOT NULL + value numeric not null ); -CREATE TABLE REACTIONS_ROUGHNESS_CORRELATION +create table reactions_roughness_correlation ( - Value NUMERIC NOT NULL + value numeric not null ); diff --git a/script/sql/create/2.junctions.sql b/script/sql/create/2.junctions.sql index 42ea2f3..3487443 100644 --- a/script/sql/create/2.junctions.sql +++ b/script/sql/create/2.junctions.sql @@ -1,9 +1,9 @@ -- [JUNCTIONS] -CREATE TABLE JUNCTIONS +create table junctions ( - ID VARCHAR(32) PRIMARY KEY REFERENCES _NODE(ID) -, Elevation NUMERIC NOT NULL -, Demand NUMERIC -, Pattern VARCHAR(32) REFERENCES _PATTERN(ID) + id varchar(32) primary key references _node(id) +, elevation numeric not null +, demand numeric +, pattern varchar(32) references _pattern(id) ); diff --git a/script/sql/create/20.mixing.sql b/script/sql/create/20.mixing.sql index b6675bb..afdb3bf 100644 --- a/script/sql/create/20.mixing.sql +++ b/script/sql/create/20.mixing.sql @@ -1,10 +1,10 @@ -- [MIXING] -CREATE TYPE MIXING_Model AS ENUM ('MIXED', '2COMP', 'FIFO', 'LIFO'); +create type mixing_model as enum ('mixed', '2comp', 'fifo', 'lifo'); -CREATE TABLE MIXING +create table mixing ( - Tank VARCHAR(32) PRIMARY KEY REFERENCES TANKS(ID) -, Model MIXING_Model NOT NULL -, Value NUMERIC + tank varchar(32) primary key references tanks(id) +, model mixing_model not null +, value numeric ); diff --git a/script/sql/create/21.times.sql b/script/sql/create/21.times.sql index a68e504..0877871 100644 --- a/script/sql/create/21.times.sql +++ b/script/sql/create/21.times.sql @@ -2,8 +2,8 @@ -- TODO: constraint -CREATE TABLE TIMES +create table times ( - Key TEXT NOT NULL -, Value TEXT NOT NULL + key text not null +, value text not null ); diff --git a/script/sql/create/22.report.sql b/script/sql/create/22.report.sql index c2435d3..edd1b3b 100644 --- a/script/sql/create/22.report.sql +++ b/script/sql/create/22.report.sql @@ -2,8 +2,8 @@ -- TODO: constraint -CREATE TABLE REPORT +create table report ( - Key TEXT NOT NULL -, Value TEXT NOT NULL + key text not null +, value text not null ); diff --git a/script/sql/create/23.options.sql b/script/sql/create/23.options.sql index 16d50a4..7b91411 100644 --- a/script/sql/create/23.options.sql +++ b/script/sql/create/23.options.sql @@ -2,8 +2,8 @@ -- TODO: constraint -CREATE TABLE OPTIONS +create table options ( - Key TEXT NOT NULL -, Value TEXT NOT NULL + key text not null +, value text not null ); diff --git a/script/sql/create/24.coordinates.sql b/script/sql/create/24.coordinates.sql index 5b6ed6d..f4ee7c7 100644 --- a/script/sql/create/24.coordinates.sql +++ b/script/sql/create/24.coordinates.sql @@ -1,10 +1,10 @@ -- [COORDINATES] -CREATE TABLE COORDINATES +create table coordinates ( - Node VARCHAR(32) PRIMARY KEY REFERENCES _NODE(ID) -, Coord POINT NOT NULL + node varchar(32) primary key references _node(id) +, coord point not null ); -CREATE INDEX COORDINATES_SPGIST ON COORDINATES USING SPGIST(Coord); -CREATE INDEX COORDINATES_GIST ON COORDINATES USING GIST(Coord); +create index coordinates_spgist on coordinates using spgist(coord); +create index coordinates_gist on coordinates using gist(coord); diff --git a/script/sql/create/25.vertices.sql b/script/sql/create/25.vertices.sql index 3f509c6..c4e2ec0 100644 --- a/script/sql/create/25.vertices.sql +++ b/script/sql/create/25.vertices.sql @@ -1,8 +1,8 @@ -- [VERTICES] -CREATE TABLE VERTICES +create table vertices ( - Link VARCHAR(32) REFERENCES _LINK(ID) NOT NULL -, X NUMERIC NOT NULL -, Y NUMERIC NOT NULL + link varchar(32) references _link(id) not null +, x numeric not null +, y numeric not null ); diff --git a/script/sql/create/26.labels.sql b/script/sql/create/26.labels.sql index cf95e00..5e240a5 100644 --- a/script/sql/create/26.labels.sql +++ b/script/sql/create/26.labels.sql @@ -1,9 +1,9 @@ -- [LABELS] -CREATE TABLE LABELS +create table labels ( - X NUMERIC NOT NULL -, Y NUMERIC NOT NULL -, Label TEXT NOT NULL -, AnchorNode VARCHAR(32) REFERENCES _NODE(ID) + x numeric not null +, y numeric not null +, label text not null +, anchornode varchar(32) references _node(id) ); diff --git a/script/sql/create/27.backdrop.sql b/script/sql/create/27.backdrop.sql index 4216368..d664e97 100644 --- a/script/sql/create/27.backdrop.sql +++ b/script/sql/create/27.backdrop.sql @@ -1,6 +1,6 @@ -- [BACKDROP] -CREATE TABLE BACKDROP +create table backdrop ( - Content TEXT PRIMARY KEY + content text primary key ); diff --git a/script/sql/create/3.reservoirs.sql b/script/sql/create/3.reservoirs.sql index 476c793..29bc5ea 100644 --- a/script/sql/create/3.reservoirs.sql +++ b/script/sql/create/3.reservoirs.sql @@ -1,8 +1,8 @@ -- [RESERVOIRS] -CREATE TABLE RESERVOIRS +create table reservoirs ( - ID VARCHAR(32) PRIMARY KEY REFERENCES _NODE(ID) -, Head NUMERIC NOT NULL -, Pattern VARCHAR(32) REFERENCES _PATTERN(ID) + id varchar(32) primary key references _node(id) +, head numeric not null +, pattern varchar(32) references _pattern(id) ); diff --git a/script/sql/create/4.tanks.sql b/script/sql/create/4.tanks.sql index 963f998..b15c29f 100644 --- a/script/sql/create/4.tanks.sql +++ b/script/sql/create/4.tanks.sql @@ -1,16 +1,16 @@ -- [TANKS] -CREATE TYPE TANKS_OVERFLOW AS ENUM ('yes', 'no'); +create type tanks_overflow as enum ('yes', 'no'); -CREATE TABLE TANKS +create table tanks ( - ID VARCHAR(32) PRIMARY KEY REFERENCES _NODE(ID) -, Elevation NUMERIC NOT NULL -, Init_Level NUMERIC NOT NULL -, Min_Level NUMERIC NOT NULL -, Max_Level NUMERIC NOT NULL -, Diameter NUMERIC NOT NULL -, Min_Vol NUMERIC NOT NULL -, Vol_Curve VARCHAR(32) REFERENCES _CURVE(ID) -, Overflow TANKS_OVERFLOW + id varchar(32) primary key references _node(id) +, elevation numeric not null +, init_level numeric not null +, min_level numeric not null +, max_level numeric not null +, diameter numeric not null +, min_vol numeric not null +, vol_curve varchar(32) references _curve(id) +, overflow tanks_overflow ); diff --git a/script/sql/create/5.pipes.sql b/script/sql/create/5.pipes.sql index 74c4982..26934f4 100644 --- a/script/sql/create/5.pipes.sql +++ b/script/sql/create/5.pipes.sql @@ -1,15 +1,15 @@ -- [PIPES] -CREATE TYPE PIPES_STATUS AS ENUM ('open', 'closed', 'cv'); +create type pipes_status as enum ('open', 'closed', 'cv'); -CREATE TABLE PIPES +create table pipes ( - ID VARCHAR(32) PRIMARY KEY REFERENCES _LINK(ID) -, Node1 VARCHAR(32) REFERENCES _NODE(ID) NOT NULL -, Node2 VARCHAR(32) REFERENCES _NODE(ID) NOT NULL -, Length NUMERIC NOT NULL -, Diameter NUMERIC NOT NULL -, Roughness NUMERIC NOT NULL -, Minor_Loss NUMERIC NOT NULL -, Status PIPES_STATUS NOT NULL + id varchar(32) primary key references _link(id) +, node1 varchar(32) references _node(id) not null +, node2 varchar(32) references _node(id) not null +, length numeric not null +, diameter numeric not null +, roughness numeric not null +, minor_loss numeric not null +, status pipes_status not null ); diff --git a/script/sql/create/6.pumps.sql b/script/sql/create/6.pumps.sql index b701708..128958f 100644 --- a/script/sql/create/6.pumps.sql +++ b/script/sql/create/6.pumps.sql @@ -1,32 +1,32 @@ -- [PUMPS] -CREATE TABLE PUMPS +create table pumps ( - ID VARCHAR(32) PRIMARY KEY REFERENCES _LINK(ID) -, Node1 VARCHAR(32) REFERENCES _NODE(ID) NOT NULL -, Node2 VARCHAR(32) REFERENCES _NODE(ID) NOT NULL + id varchar(32) primary key references _link(id) +, node1 varchar(32) references _node(id) not null +, node2 varchar(32) references _node(id) not null ); -CREATE TABLE PUMPS_PROPERTY_POWER +create table pumps_property_power ( - ID VARCHAR PRIMARY KEY REFERENCES PUMPS(ID) -, Value VARCHAR(32) NOT NULL + id varchar primary key references pumps(id) +, value varchar(32) not null ); -CREATE TABLE PUMPS_PROPERTY_SPEED +create table pumps_property_speed ( - ID VARCHAR PRIMARY KEY REFERENCES PUMPS(ID) -, Value VARCHAR(32) NOT NULL + id varchar primary key references pumps(id) +, value varchar(32) not null ); -CREATE TABLE PUMPS_PROPERTY_HEAD +create table pumps_property_head ( - ID VARCHAR PRIMARY KEY REFERENCES PUMPS(ID) -, Head VARCHAR(32) REFERENCES _CURVE(ID) NOT NULL + id varchar primary key references pumps(id) +, head varchar(32) references _curve(id) not null ); -CREATE TABLE PUMPS_PROPERTY_PATTERN +create table pumps_property_pattern ( - ID VARCHAR PRIMARY KEY REFERENCES PUMPS(ID) -, Pattern VARCHAR(32) REFERENCES _PATTERN(ID) NOT NULL + id varchar primary key references pumps(id) +, pattern varchar(32) references _pattern(id) not null ); diff --git a/script/sql/create/7.valves.sql b/script/sql/create/7.valves.sql index 1a887f1..8472d41 100644 --- a/script/sql/create/7.valves.sql +++ b/script/sql/create/7.valves.sql @@ -1,14 +1,14 @@ -- [VALVES] -CREATE TYPE VALVES_TYPE AS ENUM ('prv', 'psv', 'pbv', 'fcv', 'tcv', 'gpv'); +create type valves_type as enum ('prv', 'psv', 'pbv', 'fcv', 'tcv', 'gpv'); -CREATE TABLE VALVES +create table valves ( - ID VARCHAR(32) PRIMARY KEY REFERENCES _LINK(ID) -, Node1 VARCHAR(32) REFERENCES _NODE(ID) NOT NULL -, Node2 VARCHAR(32) REFERENCES _NODE(ID) NOT NULL -, Diameter NUMERIC NOT NULL -, Type VALVES_TYPE NOT NULL -, Setting NUMERIC NOT NULL -, Minor_Loss NUMERIC NOT NULL + id varchar(32) primary key references _link(id) +, node1 varchar(32) references _node(id) not null +, node2 varchar(32) references _node(id) not null +, diameter numeric not null +, type valves_type not null +, setting numeric not null +, minor_loss numeric not null ); diff --git a/script/sql/create/8.tags.sql b/script/sql/create/8.tags.sql index 0cc496c..2b72ae3 100644 --- a/script/sql/create/8.tags.sql +++ b/script/sql/create/8.tags.sql @@ -1,13 +1,13 @@ -- [TAGS] -CREATE TABLE TAGS_NODE +create table tags_node ( - ID VARCHAR(32) PRIMARY KEY REFERENCES _NODE(ID) -, Tag TEXT NOT NULL + id varchar(32) primary key references _node(id) +, tag text not null ); -CREATE TABLE TAGS_LINK +create table tags_link ( - ID VARCHAR(32) PRIMARY KEY REFERENCES _LINK(ID) -, Tag TEXT NOT NULL + id varchar(32) primary key references _link(id) +, tag text not null ); diff --git a/script/sql/create/9.demands.sql b/script/sql/create/9.demands.sql index 355354d..6e4b2a5 100644 --- a/script/sql/create/9.demands.sql +++ b/script/sql/create/9.demands.sql @@ -1,9 +1,9 @@ -- [DEMANDS] -CREATE TABLE DEMANDS +create table demands ( - Junction VARCHAR(32) REFERENCES JUNCTIONS(ID) NOT NULL -, Demand NUMERIC NOT NULL -, Pattern VARCHAR(32) REFERENCES _PATTERN(ID) -, Category TEXT NOT NULL + junction varchar(32) references junctions(id) not null +, demand numeric not null +, pattern varchar(32) references _pattern(id) +, category text not null ); diff --git a/script/sql/create/operation.sql b/script/sql/create/operation.sql index fa968a3..43f8771 100644 --- a/script/sql/create/operation.sql +++ b/script/sql/create/operation.sql @@ -1,36 +1,36 @@ -CREATE TYPE API_OPERATION AS ENUM ('init', 'add', 'delete', 'update'); +create type api_operation as enum ('init', 'add', 'delete', 'update'); -CREATE TABLE OPERATION +create table operation ( - ID SERIAL PRIMARY KEY -, Redo TEXT NOT NULL -, Undo TEXT NOT NULL -, Parent INTEGER REFERENCES OPERATION(ID) -, Redo_Child INTEGER REFERENCES OPERATION(ID) -, Api_Id TEXT NOT NULL -, Api_Op API_OPERATION NOT NULL -, Api_Object_Type TEXT NOT NULL -, Api_Object_Id TEXT NOT NULL -, Api_Object_Properties TEXT[] + id serial primary key +, redo text not null +, undo text not null +, parent integer references operation(id) +, redo_child integer references operation(id) +, api_id text not null +, api_op api_operation not null +, api_object_type text not null +, api_object_id text not null +, api_object_properties text[] ); -INSERT INTO OPERATION (ID, Redo, Undo, Api_Id, Api_Op, Api_Object_Type, Api_Object_Id) VALUES (0, '', '', '', 'init', '', ''); +insert into operation (id, redo, undo, api_id, api_op, api_object_type, api_object_id) values (0, '', '', '', 'init', '', ''); -CREATE TABLE CURRENT_OPERATION +create table current_operation ( - ID INTEGER PRIMARY KEY REFERENCES OPERATION(ID) + id integer primary key references operation(id) ); -INSERT INTO CURRENT_OPERATION (ID) VALUES (0); +insert into current_operation (id) values (0); -CREATE TABLE SNAPSHOT_OPERATION +create table snapshot_operation ( - ID INTEGER PRIMARY KEY REFERENCES OPERATION(ID) -, Tag TEXT NOT NULL UNIQUE + id integer primary key references operation(id) +, tag text not null unique ); -CREATE TABLE TRANSACTION_OPERATION +create table transaction_operation ( - ID INTEGER PRIMARY KEY REFERENCES OPERATION(ID) -, STRICT BOOLEAN NOT NULL DEFAULT FALSE + id integer primary key references operation(id) +, strict boolean not null default false ); diff --git a/script/sql/drop/0.base.sql b/script/sql/drop/0.base.sql index 3b57bb0..adf7030 100644 --- a/script/sql/drop/0.base.sql +++ b/script/sql/drop/0.base.sql @@ -1,11 +1,11 @@ -DROP TABLE IF EXISTS _PATTERN; +drop table if exists _pattern; -DROP TABLE IF EXISTS _CURVE; +drop table if exists _curve; -DROP TABLE IF EXISTS _LINK; +drop table if exists _link; -DROP TABLE IF EXISTS _NODE; +drop table if exists _node; -DROP TYPE IF EXISTS _LINK_TYPE; +drop type if exists _link_type; -DROP TYPE IF EXISTS _NODE_TYPE; +drop type if exists _node_type; diff --git a/script/sql/drop/1.title.sql b/script/sql/drop/1.title.sql index 7ee6d55..04792a2 100644 --- a/script/sql/drop/1.title.sql +++ b/script/sql/drop/1.title.sql @@ -1,3 +1,3 @@ -- [TITLE] -DROP TABLE IF EXISTS TITLE; +drop table if exists title; diff --git a/script/sql/drop/10.status.sql b/script/sql/drop/10.status.sql index 322a72f..c3273b3 100644 --- a/script/sql/drop/10.status.sql +++ b/script/sql/drop/10.status.sql @@ -1,13 +1,13 @@ -- [STATUS] -DROP TABLE IF EXISTS STATUS_LINK; +drop table if exists status_link; -DROP TABLE IF EXISTS STATUS_VALVE; +drop table if exists status_valve; -DROP TYPE IF EXISTS STATUS_VALVE_STATUS; +drop type if exists status_valve_status; -DROP TABLE IF EXISTS STATUS_PUMP; +drop table if exists status_pump; -DROP TABLE IF EXISTS STATUS_PIPE; +drop table if exists status_pipe; -DROP TYPE IF EXISTS STATUS_PIPE_PUMP_STATUS; +drop type if exists status_pipe_pump_status; diff --git a/script/sql/drop/11.patterns.sql b/script/sql/drop/11.patterns.sql index fd08d97..537ad31 100644 --- a/script/sql/drop/11.patterns.sql +++ b/script/sql/drop/11.patterns.sql @@ -1,3 +1,3 @@ -- [PATTERNS] -DROP TABLE IF EXISTS PATTERNS; +drop table if exists patterns; diff --git a/script/sql/drop/12.curves.sql b/script/sql/drop/12.curves.sql index 577464e..30004b4 100644 --- a/script/sql/drop/12.curves.sql +++ b/script/sql/drop/12.curves.sql @@ -1,3 +1,3 @@ -- [CURVES] -DROP TABLE IF EXISTS CURVES; +drop table if exists curves; diff --git a/script/sql/drop/13.controls.sql b/script/sql/drop/13.controls.sql index 476259d..6dd2eb8 100644 --- a/script/sql/drop/13.controls.sql +++ b/script/sql/drop/13.controls.sql @@ -1,9 +1,9 @@ -- [CONTROLS] -DROP TABLE IF EXISTS CONTROLS_3; +drop table if exists controls_3; -DROP TABLE IF EXISTS CONTROLS_2; +drop table if exists controls_2; -DROP TABLE IF EXISTS CONTROLS_1; +drop table if exists controls_1; -DROP TYPE IF EXISTS CONTROLS_1_PREP; +drop type if exists controls_1_prep; diff --git a/script/sql/drop/14.rules.sql b/script/sql/drop/14.rules.sql index 84e4fd8..9a5e90d 100644 --- a/script/sql/drop/14.rules.sql +++ b/script/sql/drop/14.rules.sql @@ -1,3 +1,3 @@ -- [RULES] -DROP TABLE IF EXISTS RULES; +drop table if exists rules; diff --git a/script/sql/drop/15.energy.sql b/script/sql/drop/15.energy.sql index 5002d5c..cf524bd 100644 --- a/script/sql/drop/15.energy.sql +++ b/script/sql/drop/15.energy.sql @@ -1,9 +1,9 @@ -- [ENERGY] -DROP TABLE IF EXISTS ENERGY_DEMAND_CHARGE; +drop table if exists energy_demand_charge; -DROP TABLE IF EXISTS ENERGY_PUMP; +drop table if exists energy_pump; -DROP TABLE IF EXISTS ENERGY_GLOBAL; +drop table if exists energy_global; -DROP TYPE IF EXISTS ENERGY_PARAM; +drop type if exists energy_param; diff --git a/script/sql/drop/16.emitters.sql b/script/sql/drop/16.emitters.sql index 40a0af8..be8e68b 100644 --- a/script/sql/drop/16.emitters.sql +++ b/script/sql/drop/16.emitters.sql @@ -1,3 +1,3 @@ -- [EMITTERS] -DROP TABLE IF EXISTS EMITTERS; +drop table if exists emitters; diff --git a/script/sql/drop/17.quality.sql b/script/sql/drop/17.quality.sql index b72c290..10010ce 100644 --- a/script/sql/drop/17.quality.sql +++ b/script/sql/drop/17.quality.sql @@ -1,3 +1,3 @@ -- [QUALITY] -DROP TABLE IF EXISTS QUALITY; +drop table if exists quality; diff --git a/script/sql/drop/18.sources.sql b/script/sql/drop/18.sources.sql index 0402ffe..1c7e735 100644 --- a/script/sql/drop/18.sources.sql +++ b/script/sql/drop/18.sources.sql @@ -1,5 +1,5 @@ -- [SOURCES] -DROP TABLE IF EXISTS SOURCES; +drop table if exists sources; -DROP TYPE IF EXISTS SOURCES_TYPE; +drop type if exists sources_type; diff --git a/script/sql/drop/19.reactions.sql b/script/sql/drop/19.reactions.sql index 2f6ba5b..8336620 100644 --- a/script/sql/drop/19.reactions.sql +++ b/script/sql/drop/19.reactions.sql @@ -1,19 +1,19 @@ -- [REACTIONS] -DROP TABLE IF EXISTS REACTIONS_ROUGHNESS_CORRELATION; +drop table if exists reactions_roughness_correlation; -DROP TABLE IF EXISTS REACTIONS_LIMITING_POTENTIAL; +drop table if exists reactions_limiting_potential; -DROP TABLE IF EXISTS REACTIONS_TANK; +drop table if exists reactions_tank; -DROP TABLE IF EXISTS REACTIONS_PIPE; +drop table if exists reactions_pipe; -DROP TYPE IF EXISTS REACTIONS_PIPE_PARAM; +drop type if exists reactions_pipe_param; -DROP TABLE IF EXISTS REACTIONS_GLOBAL; +drop table if exists reactions_global; -DROP TYPE IF EXISTS REACTIONS_GLOBAL_PARAM; +drop type if exists reactions_global_param; -DROP TABLE IF EXISTS REACTIONS_ORDER; +drop table if exists reactions_order; -DROP TYPE IF EXISTS REACTIONS_ORDER_PARAM; +drop type if exists reactions_order_param; diff --git a/script/sql/drop/2.junctions.sql b/script/sql/drop/2.junctions.sql index ef0a609..061aed3 100644 --- a/script/sql/drop/2.junctions.sql +++ b/script/sql/drop/2.junctions.sql @@ -1,3 +1,3 @@ -- [JUNCTIONS] -DROP TABLE IF EXISTS JUNCTIONS; +drop table if exists junctions; diff --git a/script/sql/drop/20.mixing.sql b/script/sql/drop/20.mixing.sql index 938d554..fcbdf6f 100644 --- a/script/sql/drop/20.mixing.sql +++ b/script/sql/drop/20.mixing.sql @@ -1,5 +1,5 @@ -- [MIXING] -DROP TABLE IF EXISTS MIXING; +drop table if exists mixing; -DROP TYPE IF EXISTS MIXING_Model; +drop type if exists mixing_model; diff --git a/script/sql/drop/21.times.sql b/script/sql/drop/21.times.sql index f051bd7..f900c55 100644 --- a/script/sql/drop/21.times.sql +++ b/script/sql/drop/21.times.sql @@ -1,3 +1,3 @@ -- [TIMES] -DROP TABLE IF EXISTS TIMES; +drop table if exists times; diff --git a/script/sql/drop/22.report.sql b/script/sql/drop/22.report.sql index 790684d..76d9cd2 100644 --- a/script/sql/drop/22.report.sql +++ b/script/sql/drop/22.report.sql @@ -1,3 +1,3 @@ -- [REPORT] -DROP TABLE IF EXISTS REPORT; +drop table if exists report; diff --git a/script/sql/drop/23.options.sql b/script/sql/drop/23.options.sql index 7cc629a..50ffe05 100644 --- a/script/sql/drop/23.options.sql +++ b/script/sql/drop/23.options.sql @@ -1,3 +1,3 @@ -- [OPTIONS] -DROP TABLE IF EXISTS OPTIONS; +drop table if exists options; diff --git a/script/sql/drop/24.coordinates.sql b/script/sql/drop/24.coordinates.sql index 04d0465..b7f86b0 100644 --- a/script/sql/drop/24.coordinates.sql +++ b/script/sql/drop/24.coordinates.sql @@ -1,7 +1,7 @@ -- [COORDINATES] -DROP INDEX IF EXISTS COORDINATES_GIST; +drop index if exists coordinates_gist; -DROP INDEX IF EXISTS COORDINATES_SPGIST; +drop index if exists coordinates_spgist; -DROP TABLE IF EXISTS COORDINATES; +drop table if exists coordinates; diff --git a/script/sql/drop/25.vertices.sql b/script/sql/drop/25.vertices.sql index f74dd3e..d4abed6 100644 --- a/script/sql/drop/25.vertices.sql +++ b/script/sql/drop/25.vertices.sql @@ -1,3 +1,3 @@ -- [VERTICES] -DROP TABLE IF EXISTS VERTICES; +drop table if exists vertices; diff --git a/script/sql/drop/26.labels.sql b/script/sql/drop/26.labels.sql index aa1b2b2..e5bf8f3 100644 --- a/script/sql/drop/26.labels.sql +++ b/script/sql/drop/26.labels.sql @@ -1,3 +1,3 @@ -- [LABELS] -DROP TABLE IF EXISTS LABELS; +drop table if exists labels; diff --git a/script/sql/drop/27.backdrop.sql b/script/sql/drop/27.backdrop.sql index 408bb85..dca68cb 100644 --- a/script/sql/drop/27.backdrop.sql +++ b/script/sql/drop/27.backdrop.sql @@ -1,3 +1,3 @@ -- [BACKDROP] -DROP TABLE IF EXISTS BACKDROP; +drop table if exists backdrop; diff --git a/script/sql/drop/3.reservoirs.sql b/script/sql/drop/3.reservoirs.sql index 9864c18..70b0e3b 100644 --- a/script/sql/drop/3.reservoirs.sql +++ b/script/sql/drop/3.reservoirs.sql @@ -1,3 +1,3 @@ -- [RESERVOIRS] -DROP TABLE IF EXISTS RESERVOIRS; +drop table if exists reservoirs; diff --git a/script/sql/drop/4.tanks.sql b/script/sql/drop/4.tanks.sql index da0487d..73477b2 100644 --- a/script/sql/drop/4.tanks.sql +++ b/script/sql/drop/4.tanks.sql @@ -1,5 +1,5 @@ -- [TANKS] -DROP TABLE IF EXISTS TANKS; +drop table if exists tanks; -DROP TYPE IF EXISTS TANKS_OVERFLOW; +drop type if exists tanks_overflow; diff --git a/script/sql/drop/5.pipes.sql b/script/sql/drop/5.pipes.sql index 1e23612..2aab7c5 100644 --- a/script/sql/drop/5.pipes.sql +++ b/script/sql/drop/5.pipes.sql @@ -1,5 +1,5 @@ -- [PIPES] -DROP TABLE IF EXISTS PIPES; +drop table if exists pipes; -DROP TYPE IF EXISTS PIPES_STATUS; +drop type if exists pipes_status; diff --git a/script/sql/drop/6.pumps.sql b/script/sql/drop/6.pumps.sql index 5ac9656..7d4aab1 100644 --- a/script/sql/drop/6.pumps.sql +++ b/script/sql/drop/6.pumps.sql @@ -1,11 +1,11 @@ -- [PUMPS] -DROP TABLE IF EXISTS PUMPS_PROPERTY_PATTERN; +drop table if exists pumps_property_pattern; -DROP TABLE IF EXISTS PUMPS_PROPERTY_HEAD; +drop table if exists pumps_property_head; -DROP TABLE IF EXISTS PUMPS_PROPERTY_SPEED; +drop table if exists pumps_property_speed; -DROP TABLE IF EXISTS PUMPS_PROPERTY_POWER; +drop table if exists pumps_property_power; -DROP TABLE IF EXISTS PUMPS; +drop table if exists pumps; diff --git a/script/sql/drop/7.valves.sql b/script/sql/drop/7.valves.sql index c95b423..3faf460 100644 --- a/script/sql/drop/7.valves.sql +++ b/script/sql/drop/7.valves.sql @@ -1,5 +1,5 @@ -- [VALVES] -DROP TABLE IF EXISTS VALVES; +drop table if exists valves; -DROP TYPE IF EXISTS VALVES_TYPE; +drop type if exists valves_type; diff --git a/script/sql/drop/8.tags.sql b/script/sql/drop/8.tags.sql index df8e3d1..aeaee79 100644 --- a/script/sql/drop/8.tags.sql +++ b/script/sql/drop/8.tags.sql @@ -1,5 +1,5 @@ -- [TAGS] -DROP TABLE IF EXISTS TAGS_LINK; +drop table if exists tags_link; -DROP TABLE IF EXISTS TAGS_NODE; +drop table if exists tags_node; diff --git a/script/sql/drop/9.demands.sql b/script/sql/drop/9.demands.sql index ebe0209..8e65797 100644 --- a/script/sql/drop/9.demands.sql +++ b/script/sql/drop/9.demands.sql @@ -1,3 +1,3 @@ -- [DEMANDS] -DROP TABLE IF EXISTS DEMANDS; +drop table if exists demands; diff --git a/script/sql/drop/operation.sql b/script/sql/drop/operation.sql index 13982ba..0dd5237 100644 --- a/script/sql/drop/operation.sql +++ b/script/sql/drop/operation.sql @@ -1,9 +1,9 @@ -DROP TABLE IF EXISTS TRANSACTION_OPERATION; +drop table if exists transaction_operation; -DROP TABLE IF EXISTS SNAPSHOT_OPERATION; +drop table if exists snapshot_operation; -DROP TABLE IF EXISTS CURRENT_OPERATION; +drop table if exists current_operation; -DROP TABLE IF EXISTS OPERATION; +drop table if exists operation; -DROP TYPE IF EXISTS API_OPERATION; +drop type if exists api_operation;