fix
This commit is contained in:
38
dbddl/dataraw.ddl
Normal file
38
dbddl/dataraw.ddl
Normal file
@@ -0,0 +1,38 @@
|
||||
CREATE TABLE public.dataraw
|
||||
(
|
||||
id serial4 NOT NULL,
|
||||
unit_name text NULL,
|
||||
unit_type text NULL,
|
||||
tool_name text NULL,
|
||||
tool_type text NULL,
|
||||
unit_ip text NULL,
|
||||
unit_subnet text NULL,
|
||||
unit_gateway text NULL,
|
||||
event_timestamp timestamp NULL,
|
||||
battery_level float8 NULL,
|
||||
temperature float8 NULL,
|
||||
nodes_jsonb jsonb NULL,
|
||||
created_at timestamp DEFAULT CURRENT_TIMESTAMP NULL,
|
||||
updated_at timestamp NULL,
|
||||
CONSTRAINT dataraw_pk PRIMARY KEY (id),
|
||||
CONSTRAINT dataraw_unique UNIQUE (unit_name, tool_name, event_timestamp)
|
||||
);
|
||||
|
||||
|
||||
CREATE OR REPLACE FUNCTION public.update_updated_at_column()
|
||||
RETURNS trigger
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
NEW.updated_at = now();
|
||||
RETURN NEW;
|
||||
END;
|
||||
$function$
|
||||
;
|
||||
|
||||
|
||||
CREATE TRIGGER update_updated_at BEFORE
|
||||
UPDATE
|
||||
ON dataraw FOR EACH ROW
|
||||
EXECUTE PROCEDURE
|
||||
update_updated_at_column();
|
||||
@@ -1,18 +0,0 @@
|
||||
DROP TABLE public.dataraw;
|
||||
|
||||
CREATE TABLE public.dataraw
|
||||
(
|
||||
id serial4 NOT NULL,
|
||||
unit_name text NULL,
|
||||
unit_type text NULL,
|
||||
tool_name text NULL,
|
||||
tool_type text NULL,
|
||||
ip_centralina text NULL,
|
||||
ip_gateway text NULL,
|
||||
event_timestamp timestamp NULL,
|
||||
battery_level float8 NULL,
|
||||
temperature float8 NULL,
|
||||
nodes_jsonb text NULL,
|
||||
CONSTRAINT dataraw_pk PRIMARY KEY (id),
|
||||
CONSTRAINT dataraw_unique UNIQUE (unit_name, tool_name, event_timestamp)
|
||||
);
|
||||
Reference in New Issue
Block a user