feat(api): fixed create DB order
This commit is contained in:
parent
ee5d6dca52
commit
98b5fad26e
1 changed files with 25 additions and 27 deletions
|
|
@ -269,33 +269,6 @@ $$
|
|||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE notify_project();
|
||||
|
||||
-- --- alerts.sql ---
|
||||
|
||||
CREATE TYPE alert_detection_method AS ENUM ('threshold', 'change');
|
||||
|
||||
CREATE TABLE alerts
|
||||
(
|
||||
alert_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
series_id integer NULL REFERENCES metric_series (series_id) ON DELETE CASCADE,
|
||||
name text NOT NULL,
|
||||
description text NULL DEFAULT NULL,
|
||||
active boolean NOT NULL DEFAULT TRUE,
|
||||
detection_method alert_detection_method NOT NULL,
|
||||
query jsonb NOT NULL,
|
||||
deleted_at timestamp NULL DEFAULT NULL,
|
||||
created_at timestamp NOT NULL DEFAULT timezone('utc'::text, now()),
|
||||
options jsonb NOT NULL DEFAULT '{
|
||||
"renotifyInterval": 1440
|
||||
}'::jsonb
|
||||
);
|
||||
CREATE INDEX alerts_project_id_idx ON alerts (project_id);
|
||||
CREATE INDEX alerts_series_id_idx ON alerts (series_id);
|
||||
CREATE TRIGGER on_insert_or_update_or_delete
|
||||
AFTER INSERT OR UPDATE OR DELETE
|
||||
ON alerts
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE notify_alert();
|
||||
|
||||
-- --- webhooks.sql ---
|
||||
|
||||
|
|
@ -966,6 +939,31 @@ $$
|
|||
CREATE INDEX searches_user_id_is_public_idx ON public.searches (user_id, is_public);
|
||||
CREATE INDEX searches_project_id_idx ON public.searches (project_id);
|
||||
|
||||
CREATE TYPE alert_detection_method AS ENUM ('threshold', 'change');
|
||||
|
||||
CREATE TABLE alerts
|
||||
(
|
||||
alert_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
series_id integer NULL REFERENCES metric_series (series_id) ON DELETE CASCADE,
|
||||
name text NOT NULL,
|
||||
description text NULL DEFAULT NULL,
|
||||
active boolean NOT NULL DEFAULT TRUE,
|
||||
detection_method alert_detection_method NOT NULL,
|
||||
query jsonb NOT NULL,
|
||||
deleted_at timestamp NULL DEFAULT NULL,
|
||||
created_at timestamp NOT NULL DEFAULT timezone('utc'::text, now()),
|
||||
options jsonb NOT NULL DEFAULT '{
|
||||
"renotifyInterval": 1440
|
||||
}'::jsonb
|
||||
);
|
||||
CREATE INDEX alerts_project_id_idx ON alerts (project_id);
|
||||
CREATE INDEX alerts_series_id_idx ON alerts (series_id);
|
||||
CREATE TRIGGER on_insert_or_update_or_delete
|
||||
AFTER INSERT OR UPDATE OR DELETE
|
||||
ON alerts
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE notify_alert();
|
||||
|
||||
raise notice 'DB created';
|
||||
END IF;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue