feat(schema): tag and watch (#1833)
This commit is contained in:
parent
cf9cad7f75
commit
7dac657885
4 changed files with 93 additions and 1 deletions
|
|
@ -41,10 +41,33 @@ CREATE TABLE IF NOT EXISTS public.projects_conditions
|
|||
filters jsonb NOT NULL DEFAULT '[]'::jsonb
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.tags
|
||||
(
|
||||
tag_id bigint NOT NULL PRIMARY KEY,
|
||||
name text NOT NULL,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
selector text NOT NULL,
|
||||
ignore_click_rage boolean NOT NULL,
|
||||
ignore_dead_click boolean NOT NULL,
|
||||
deleted_at timestamp without time zone NULL DEFAULT NULL
|
||||
);
|
||||
CREATE INDEX tags_project_id_idx ON public.tags (project_id);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS events.tags
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
seq_index integer NOT NULL,
|
||||
tag_id bigint NOT NULL REFERENCES public.tags (tag_id) ON DELETE CASCADE,
|
||||
PRIMARY KEY (session_id, timestamp, seq_index)
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS tags_session_id_idx ON events.tags (session_id);
|
||||
CREATE INDEX IF NOT EXISTS tags_timestamp_idx ON events.tags (timestamp);
|
||||
|
||||
COMMIT;
|
||||
|
||||
\elif :is_next
|
||||
\echo new version detected :'next_version', nothing to do
|
||||
\else
|
||||
\warn skipping DB upgrade of :'next_version', expected previous version :'previous_version', found :'current_version'
|
||||
\endif
|
||||
\endif
|
||||
|
|
|
|||
|
|
@ -1154,6 +1154,29 @@ $$
|
|||
CREATE INDEX swipes_timestamp_idx ON events_ios.swipes (timestamp);
|
||||
CREATE INDEX swipes_label_session_id_timestamp_idx ON events_ios.swipes (label, session_id, timestamp);
|
||||
|
||||
CREATE TABLE public.tags
|
||||
(
|
||||
tag_id bigint NOT NULL PRIMARY KEY,
|
||||
name text NOT NULL,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
selector text NOT NULL,
|
||||
ignore_click_rage boolean NOT NULL,
|
||||
ignore_dead_click boolean NOT NULL,
|
||||
deleted_at timestamp without time zone NULL DEFAULT NULL
|
||||
);
|
||||
CREATE INDEX tags_project_id_idx ON public.tags (project_id);
|
||||
|
||||
CREATE TABLE events.tags
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
seq_index integer NOT NULL,
|
||||
tag_id bigint NOT NULL REFERENCES public.tags (tag_id) ON DELETE CASCADE,
|
||||
PRIMARY KEY (session_id, timestamp, seq_index)
|
||||
);
|
||||
CREATE INDEX tags_session_id_idx ON events.tags (session_id);
|
||||
CREATE INDEX tags_timestamp_idx ON events.tags (timestamp);
|
||||
|
||||
IF NOT EXISTS(SELECT *
|
||||
FROM pg_type typ
|
||||
WHERE typ.typname = 'ui_tests_status') THEN
|
||||
|
|
|
|||
|
|
@ -41,6 +41,29 @@ CREATE TABLE IF NOT EXISTS public.projects_conditions
|
|||
filters jsonb NOT NULL DEFAULT '[]'::jsonb
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.tags
|
||||
(
|
||||
tag_id bigint NOT NULL PRIMARY KEY,
|
||||
name text NOT NULL,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
selector text NOT NULL,
|
||||
ignore_click_rage boolean NOT NULL,
|
||||
ignore_dead_click boolean NOT NULL,
|
||||
deleted_at timestamp without time zone NULL DEFAULT NULL
|
||||
);
|
||||
CREATE INDEX tags_project_id_idx ON public.tags (project_id);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS events.tags
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
seq_index integer NOT NULL,
|
||||
tag_id bigint NOT NULL REFERENCES public.tags (tag_id) ON DELETE CASCADE,
|
||||
PRIMARY KEY (session_id, timestamp, seq_index)
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS tags_session_id_idx ON events.tags (session_id);
|
||||
CREATE INDEX IF NOT EXISTS tags_timestamp_idx ON events.tags (timestamp);
|
||||
|
||||
COMMIT;
|
||||
|
||||
\elif :is_next
|
||||
|
|
|
|||
|
|
@ -1114,6 +1114,29 @@ $$
|
|||
CREATE INDEX swipes_label_gin_idx ON events_ios.swipes USING GIN (label gin_trgm_ops);
|
||||
CREATE INDEX swipes_timestamp_idx ON events_ios.swipes (timestamp);
|
||||
CREATE INDEX swipes_label_session_id_timestamp_idx ON events_ios.swipes (label, session_id, timestamp);
|
||||
|
||||
CREATE TABLE public.tags
|
||||
(
|
||||
tag_id bigint NOT NULL PRIMARY KEY,
|
||||
name text NOT NULL,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
selector text NOT NULL,
|
||||
ignore_click_rage boolean NOT NULL,
|
||||
ignore_dead_click boolean NOT NULL,
|
||||
deleted_at timestamp without time zone NULL DEFAULT NULL
|
||||
);
|
||||
CREATE INDEX tags_project_id_idx ON public.tags (project_id);
|
||||
|
||||
CREATE TABLE events.tags
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
seq_index integer NOT NULL,
|
||||
tag_id bigint NOT NULL REFERENCES public.tags (tag_id) ON DELETE CASCADE,
|
||||
PRIMARY KEY (session_id, timestamp, seq_index)
|
||||
);
|
||||
CREATE INDEX tags_session_id_idx ON events.tags (session_id);
|
||||
CREATE INDEX tags_timestamp_idx ON events.tags (timestamp);
|
||||
|
||||
IF NOT EXISTS(SELECT *
|
||||
FROM pg_type typ
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue