Skip to content

Instantly share code, notes, and snippets.

@thebapi
Last active March 20, 2023 13:00
Show Gist options
  • Save thebapi/000b57bbf3a2cfd3dbc0bfba7d0b57ca to your computer and use it in GitHub Desktop.
Save thebapi/000b57bbf3a2cfd3dbc0bfba7d0b57ca to your computer and use it in GitHub Desktop.
Alarm Log table
CREATE TABLE IF NOT EXISTS public.alarmlog
(
id_alarm_log bigserial NOT NULL,
id_control_device bigint NOT NULL,
asset_name character varying(50) NOT NULL,
property_group_name character varying(50) NOT NULL,
value double precision NOT NULL,
unit character varying(5) NOT NULL,
is_acknowledged boolean NOT NULL DEFAULT 'false',
acknowledged_at double precision,
alarm_activation_time double precision NOT NULL,
incident_id bigint NOT NULL,
type smallint NOT NULL,
property character varying(50) NOT NULL,
acknowledgement_link text NOT NULL,
CONSTRAINT alarmlog_pkey PRIMARY KEY (id_alarm_log),
CONSTRAINT alarm_log_control_device_fn FOREIGN KEY (id_control_device)
REFERENCES public.controldevice (id_control_device) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID
);
CREATE INDEX IF NOT EXISTS alarm_ack_time_index
ON public.alarmlog USING btree
(is_acknowledged ASC NULLS LAST, alarm_activation_time ASC NULLS LAST);
CREATE INDEX IF NOT EXISTS fki_alarm_log_control_device_fn
ON public.alarmlog USING btree
(id_control_device ASC NULLS LAST);
CREATE UNIQUE INDEX "alarm-log-uniq-index"
ON public.alarmlog USING btree
(incident_id ASC NULLS LAST);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment