openreplay/ee/scripts/schema/db/init_dbs/postgresql/1.22.0/1.22.0.sql
Kraiem Taha Yassine b09becdcb7
Dev (#3022)
* refactor(chalice): refactored code

* refactor(chalice): removed support for domainsErrors4xx & domainsErrors5xx predefined cards because UI is not showing them anymore
refactor(chalice): removed support of processed_sessions & count_requests predefined cards because UI is not showing them anymore

* fix(chalice): fixed table of errors CH

* fix(chalice): removed support for errorsPerDomains & errorsPerType predefined cards because UI is not showing them anymore

* fix(chalice): removed support for speedLocation predefined card because UI is not showing it anymore
2025-02-11 13:54:47 +01:00

49 lines
1.4 KiB
PL/PgSQL

\set previous_version 'v1.21.0-ee'
\set next_version 'v1.22.0-ee'
SELECT openreplay_version() AS current_version,
openreplay_version() = :'previous_version' AS valid_previous,
openreplay_version() = :'next_version' AS is_next
\gset
\if :valid_previous
\echo valid previous DB version :'previous_version', starting DB upgrade to :'next_version'
BEGIN;
SELECT format($fn_def$
CREATE OR REPLACE FUNCTION openreplay_version()
RETURNS text AS
$$
SELECT '%1$s'
$$ LANGUAGE sql IMMUTABLE;
$fn_def$, :'next_version')
\gexec
--
DELETE
FROM public.metrics
WHERE metrics.metric_type = 'insights';
DROP TABLE IF EXISTS public.user_favorite_errors;
DROP TABLE IF EXISTS public.user_viewed_errors;
ALTER TABLE IF EXISTS public.sessions_notes
ADD COLUMN start_at integer,
ADD COLUMN end_at integer,
ADD COLUMN thumbnail text,
ADD COLUMN updated_at timestamp DEFAULT NULL,
ALTER COLUMN message DROP NOT NULL;
DELETE
FROM public.metrics
WHERE metric_of IN ('domainsErrors4xx', 'domainsErrors5xx', 'countSessions',
'countRequests', 'errorsPerDomains', 'errorsPerType',
'impactedSessionsByJsErrors', 'resourcesByParty', 'userOs',
'speedLocation');
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