From 650df7090d756a09689821a8ea1c57bbb5bf209c Mon Sep 17 00:00:00 2001 From: Shekar Siri Date: Fri, 12 Jan 2024 11:46:11 +0100 Subject: [PATCH] feat(db): conditional capture db changes for ee --- .../schema/db/init_dbs/postgresql/1.17.0/1.17.0.sql | 12 ++++++++++++ .../schema/db/init_dbs/postgresql/init_schema.sql | 12 +++++++++++- .../schema/db/init_dbs/postgresql/init_schema.sql | 12 +++++++++++- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/ee/scripts/schema/db/init_dbs/postgresql/1.17.0/1.17.0.sql b/ee/scripts/schema/db/init_dbs/postgresql/1.17.0/1.17.0.sql index 45f2244bd..a5289b55e 100644 --- a/ee/scripts/schema/db/init_dbs/postgresql/1.17.0/1.17.0.sql +++ b/ee/scripts/schema/db/init_dbs/postgresql/1.17.0/1.17.0.sql @@ -29,6 +29,18 @@ UPDATE public.sessions SET has_ut_test= TRUE WHERE session_id IN (SELECT session_id FROM public.ut_tests_signals); +ALTER TABLE IF EXISTS public.projects + ADD COLUMN IF NOT EXISTS conditional_capture boolean DEFAULT FALSE; + +CREATE TABLE IF NOT EXISTS public.projects_conditions +( + condition_id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, + project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE, + name varchar(255) NOT NULL, + capture_rate integer NOT NULL CHECK (capture_rate >= 0 AND capture_rate <= 100), + filters jsonb NOT NULL DEFAULT '[]'::jsonb +); + COMMIT; \elif :is_next diff --git a/ee/scripts/schema/db/init_dbs/postgresql/init_schema.sql b/ee/scripts/schema/db/init_dbs/postgresql/init_schema.sql index 838016bc4..3cc459fc2 100644 --- a/ee/scripts/schema/db/init_dbs/postgresql/init_schema.sql +++ b/ee/scripts/schema/db/init_dbs/postgresql/init_schema.sql @@ -222,7 +222,8 @@ $$ }'::jsonb, first_recorded_session_at timestamp without time zone NULL DEFAULT NULL, sessions_last_check_at timestamp without time zone NULL DEFAULT NULL, - beacon_size integer NOT NULL DEFAULT 0 + beacon_size integer NOT NULL DEFAULT 0, + conditional_capture boolean NOT NULL DEFAULT FALSE ); CREATE INDEX projects_project_key_idx ON public.projects (project_key); @@ -1293,6 +1294,15 @@ $$ time BIGINT not null ); + CREATE TABLE IF NOT EXISTS public.projects_conditions + ( + condition_id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, + project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE, + name varchar(255) NOT NULL, + capture_rate integer NOT NULL CHECK (capture_rate >= 0 AND capture_rate <= 100), + filters jsonb NOT NULL DEFAULT '[]'::jsonb + ); + raise notice 'DB created'; END IF; END; diff --git a/scripts/schema/db/init_dbs/postgresql/init_schema.sql b/scripts/schema/db/init_dbs/postgresql/init_schema.sql index b684e3622..904917900 100644 --- a/scripts/schema/db/init_dbs/postgresql/init_schema.sql +++ b/scripts/schema/db/init_dbs/postgresql/init_schema.sql @@ -199,7 +199,8 @@ $$ }'::jsonb, first_recorded_session_at timestamp without time zone NULL DEFAULT NULL, sessions_last_check_at timestamp without time zone NULL DEFAULT NULL, - beacon_size integer NOT NULL DEFAULT 0 + beacon_size integer NOT NULL DEFAULT 0, + conditional_capture boolean NOT NULL DEFAULT FALSE ); CREATE INDEX projects_project_key_idx ON public.projects (project_key); @@ -1178,6 +1179,15 @@ $$ ); CREATE INDEX canvas_recordings_session_id_idx ON events.canvas_recordings (session_id); + CREATE TABLE IF NOT EXISTS public.projects_conditions + ( + condition_id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, + project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE, + name varchar(255) NOT NULL, + capture_rate integer NOT NULL CHECK (capture_rate >= 0 AND capture_rate <= 100), + filters jsonb NOT NULL DEFAULT '[]'::jsonb + ); + raise notice 'DB created'; END IF; END;