refactor(db): align project template schema

This commit is contained in:
2026-08-03 10:39:31 +08:00
parent 0be31869b5
commit f010f071eb
9 changed files with 25 additions and 132 deletions
-10
View File
@@ -1,10 +0,0 @@
-- [USERS]
-- 王名豪
-- 2025/03/23
-- 存储系统的用户信息,如用户名,密码
create table users (
user_id SERIAL PRIMARY KEY,
username varchar(32) not null unique,
password varchar(32) not null
)
+1 -1
View File
@@ -7,7 +7,7 @@ create table scheme_list (
scheme_id SERIAL PRIMARY KEY,
scheme_name varchar(32) not null,
scheme_type varchar(32) not null,
username varchar(32) not null REFERENCES "users"(username) ON UPDATE CASCADE ON DELETE RESTRICT,
username varchar(32) not null,
create_time TIMESTAMP WITH TIME ZONE not null DEFAULT date_trunc('minute', CURRENT_TIMESTAMP),
scheme_start_time TIMESTAMP WITH TIME ZONE not null,
scheme_detail JSON
+2 -2
View File
@@ -8,7 +8,7 @@ CREATE TABLE sensor_placement (
scheme_name varchar(32) not null,
sensor_number int,
min_diameter int,
username varchar(32) not null REFERENCES "users"(username) ON UPDATE CASCADE ON DELETE RESTRICT,
username varchar(32) not null,
create_time TIMESTAMP WITH TIME ZONE not null DEFAULT date_trunc('minute', CURRENT_TIMESTAMP),
sensor_location TEXT[]
);
);
@@ -0,0 +1,17 @@
-- [LEAKAGE_IDENTIFY_RESULT]
-- 存储漏损识别任务的结果数据。
CREATE TABLE leakage_identify_result (
id BIGSERIAL PRIMARY KEY,
scheme_name varchar NOT NULL,
network varchar NOT NULL,
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
run_status varchar NOT NULL DEFAULT 'completed',
error_message text,
sensor_nodes jsonb NOT NULL DEFAULT '[]'::jsonb,
result_rows jsonb NOT NULL DEFAULT '[]'::jsonb,
node_area_map jsonb NOT NULL DEFAULT '{}'::jsonb,
areas jsonb DEFAULT '[]'::jsonb,
drawing_payload jsonb DEFAULT '{"type": "FeatureCollection", "features": []}'::jsonb,
CONSTRAINT uq_leakage_identify_result_scheme UNIQUE (scheme_name)
);