feat(schema): tag and watch (#1833)

This commit is contained in:
ⵄⵎⵉⵔⵓⵛ 2024-01-17 08:58:16 +01:00 committed by GitHub
parent cf9cad7f75
commit 7dac657885
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 93 additions and 1 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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