From 3264a424d1478f2582986b550b45be5b3a47d852 Mon Sep 17 00:00:00 2001 From: Taha Yassine Kraiem Date: Fri, 24 Jun 2022 19:29:54 +0200 Subject: [PATCH] feat(DB): changed resources primary keys --- ee/scripts/helm/db/init_dbs/postgresql/1.7.0/1.7.0.sql | 9 ++++++++- ee/scripts/helm/db/init_dbs/postgresql/init_schema.sql | 2 +- scripts/helm/db/init_dbs/postgresql/1.7.0/1.7.0.sql | 7 +++++++ scripts/helm/db/init_dbs/postgresql/init_schema.sql | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ee/scripts/helm/db/init_dbs/postgresql/1.7.0/1.7.0.sql b/ee/scripts/helm/db/init_dbs/postgresql/1.7.0/1.7.0.sql index ee01e24e0..6f7cbea0d 100644 --- a/ee/scripts/helm/db/init_dbs/postgresql/1.7.0/1.7.0.sql +++ b/ee/scripts/helm/db/init_dbs/postgresql/1.7.0/1.7.0.sql @@ -3,7 +3,7 @@ CREATE OR REPLACE FUNCTION openreplay_version() RETURNS text AS $$ -SELECT 'v1.6.1-ee' +SELECT 'v1.7.0-ee' $$ LANGUAGE sql IMMUTABLE; @@ -50,6 +50,13 @@ $$ END $$; +ALTER TABLE IF EXISTS events.resources + DROP CONSTRAINT IF EXISTS resources_pkey; + +ALTER TABLE IF EXISTS events.resources + ADD CONSTRAINT resources_pk + PRIMARY KEY (session_id, message_id, timestamp); + COMMIT; CREATE INDEX CONCURRENTLY IF NOT EXISTS projects_project_id_deleted_at_n_idx ON public.projects (project_id) WHERE deleted_at IS NULL; ALTER TYPE metric_type ADD VALUE IF NOT EXISTS 'funnel'; diff --git a/ee/scripts/helm/db/init_dbs/postgresql/init_schema.sql b/ee/scripts/helm/db/init_dbs/postgresql/init_schema.sql index 76ed78d87..7cac6e10e 100644 --- a/ee/scripts/helm/db/init_dbs/postgresql/init_schema.sql +++ b/ee/scripts/helm/db/init_dbs/postgresql/init_schema.sql @@ -1052,7 +1052,7 @@ $$ header_size bigint NULL, encoded_body_size integer NULL, decoded_body_size integer NULL, - PRIMARY KEY (session_id, message_id) + PRIMARY KEY (session_id, message_id, timestamp) ); CREATE INDEX IF NOT EXISTS resources_session_id_idx ON events.resources (session_id); CREATE INDEX IF NOT EXISTS resources_status_idx ON events.resources (status); diff --git a/scripts/helm/db/init_dbs/postgresql/1.7.0/1.7.0.sql b/scripts/helm/db/init_dbs/postgresql/1.7.0/1.7.0.sql index 2ed45dea7..b4c536498 100644 --- a/scripts/helm/db/init_dbs/postgresql/1.7.0/1.7.0.sql +++ b/scripts/helm/db/init_dbs/postgresql/1.7.0/1.7.0.sql @@ -37,6 +37,13 @@ $$ END $$; +ALTER TABLE IF EXISTS events.resources + DROP CONSTRAINT IF EXISTS resources_pkey; + +ALTER TABLE IF EXISTS events.resources + ADD CONSTRAINT resources_pk + PRIMARY KEY (session_id, message_id, timestamp); + COMMIT; CREATE INDEX CONCURRENTLY IF NOT EXISTS projects_project_id_deleted_at_n_idx ON public.projects (project_id) WHERE deleted_at IS NULL; ALTER TYPE metric_type ADD VALUE IF NOT EXISTS 'predefined'; diff --git a/scripts/helm/db/init_dbs/postgresql/init_schema.sql b/scripts/helm/db/init_dbs/postgresql/init_schema.sql index f06ff4f9a..8c6ff9d2c 100644 --- a/scripts/helm/db/init_dbs/postgresql/init_schema.sql +++ b/scripts/helm/db/init_dbs/postgresql/init_schema.sql @@ -780,7 +780,7 @@ $$ header_size bigint NULL, encoded_body_size integer NULL, decoded_body_size integer NULL, - PRIMARY KEY (session_id, message_id) + PRIMARY KEY (session_id, message_id, timestamp) ); CREATE INDEX resources_session_id_idx ON events.resources (session_id); CREATE INDEX resources_status_idx ON events.resources (status);