openreplay/scripts/schema/db/init_dbs/postgresql/1.15.0/1.15.0.sql
Kraiem Taha Yassine a7d5f86787
Api v1.15.0 (#1564)
* feat(chalice): upgraded dependencies

* feat(chalice): changed path analysis schema

* feat(DB): click coordinate support

* feat(chalice): changed path analysis issues schema
feat(chalice): upgraded dependencies

* fix(chalice): fixed pydantic issue

* refactor(chalice): refresh token validator

* feat(chalice): role restrictions

* feat(chalice): EE path analysis changes

* refactor(DB): changed creation queries
refactor(DB): changed delte queries
feat(DB): support new path analysis payload

* feat(chalice): save path analysis card

* feat(chalice): restrict access

* feat(chalice): restrict access

* feat(chalice): EE save new path analysis card

* refactor(chalice): path analysis

* feat(chalice): path analysis new query

* fix(chalice): configurable CH config

* fix(chalice): assist autocomplete

* refactor(chalice): refactored permissions

* refactor(chalice): changed log level

* refactor(chalice): upgraded dependencies

* refactor(chalice): changed path analysis query

* refactor(chalice): changed path analysis query

* refactor(chalice): upgraded dependencies
refactor(alerts): upgraded dependencies
refactor(crons): upgraded dependencies

* feat(chalice): path analysis ignore start point

* feat(chalice): path analysis in progress

* refactor(chalice): path analysis changed link sort

* refactor(chalice): path analysis changed link sort

* refactor(chalice): path analysis changed link sort

* refactor(chalice): path analysis new query
refactor(chalice): authorizers

* refactor(chalice): refactored authorizer

* fix(chalice): fixed create card of PathAnalysis

* refactor(chalice): compute link-percentage for Path Analysis

* refactor(chalice): remove null starting point from Path Analysis

* feat(chalice): path analysis CH query

* refactor(chalice): changed Path Analysis links-value
fix(chalice): fixed search notes for EE

* feat(chalice): path analysis enhanced query results

* feat(chalice): include timezone in search sessions response

* refactor(chalice): refactored logs

* refactor(chalice): refactored logs
feat(chalice): get path analysis issues

* fix(chalice): fixed path analysis issues pagination

* fix(chalice): sessions-search handle null values

* feat(chalice): PathAnalysis start event support middle-event matching

* feat(chalice): PathAnalysis start event support middle-event matching

* feat(chalice): PathAnalysis support mixed events with start-point

* fix(chalice): PathAnalysis fixed eventType value when metricValue is missing

* fix(chalice): PathAnalysis fixed wrong super-class model for update card

* fix(chalice): PathAnalysis fixed search issues
refactor(chalice): upgraded dependencies

* fix(chalice): enforce isEvent if missing

* fix(chalice): enforce isEvent if missing

* refactor(chalice): refactored custom-metrics

* refactor(chalice): small changes

* feat(chalice): path analysis EE new query

* fix(chalice): fixed hide-excess state for Path Analysis

* fix(chalice): fixed update start point and excludes for Path Analysis

* fix(chalice): fix payload validation
fix(chalice): fix update widget endpoint

* fix(chalice): fix payload validation
fix(chalice): fix update widget endpoint

* fix(chalice): fix add member

* refactor(chalice): upgraded dependencies
refactor!(chalice): upgraded SAML dependencies

* feat(chalice): ios-project support 1/5

* refactor(chalice): changed logs handling

* fix(chalice): fix path analysis issues list

* Api v1.15.0 (#1542)

* refactor(chalice): changed default dev env vars

* refactor(chalice): changes

* refactor(chalice): changed payload fixer

* refactor(chalice): changed payload fixer
refactor(chalice): support duplicate filters

* Api v1.15.0 no merge (#1546)

* refactor(chalice): changed default dev env vars

* refactor(chalice): changes

* refactor(chalice): changed payload fixer

* refactor(chalice): changed payload fixer
refactor(chalice): support duplicate filters

* refactor(chalice): changes

* feature(chalice): mobile sessions search

* Api v1.15.0 no merge (#1549)

* refactor(chalice): changed default dev env vars

* refactor(chalice): changes

* refactor(chalice): changed payload fixer

* refactor(chalice): changed payload fixer
refactor(chalice): support duplicate filters

* refactor(chalice): changes

* feature(chalice): mobile sessions search

* refactor(chalice): fix EE refactored schema

* Api v1.15.0 no merge (#1552)

* refactor(chalice): changed default dev env vars

* refactor(chalice): changes

* refactor(chalice): changed payload fixer

* refactor(chalice): changed payload fixer
refactor(chalice): support duplicate filters

* refactor(chalice): changes

* feature(chalice): mobile sessions search

* refactor(chalice): fix EE refactored schema

* fix(chalice): fix missing platform for EE

* Api v1.15.0 no merge (#1554)

* refactor(chalice): changed default dev env vars

* refactor(chalice): changes

* refactor(chalice): changed payload fixer

* refactor(chalice): changed payload fixer
refactor(chalice): support duplicate filters

* refactor(chalice): changes

* feature(chalice): mobile sessions search

* refactor(chalice): fix EE refactored schema

* fix(chalice): fix missing platform for EE

* fix(DB): fixed init_schema

* Api v1.15.0 no merge (#1554) (#1555)

* refactor(chalice): changed default dev env vars

* refactor(chalice): changes

* refactor(chalice): changed payload fixer

* refactor(chalice): changed payload fixer
refactor(chalice): support duplicate filters

* refactor(chalice): changes

* feature(chalice): mobile sessions search

* refactor(chalice): fix EE refactored schema

* fix(chalice): fix missing platform for EE

* fix(DB): fixed init_schema

* Api v1.15.0 no merge (#1557)

* refactor(chalice): changed default dev env vars

* refactor(chalice): changes

* refactor(chalice): changed payload fixer

* refactor(chalice): changed payload fixer
refactor(chalice): support duplicate filters

* refactor(chalice): changes

* feature(chalice): mobile sessions search

* refactor(chalice): fix EE refactored schema

* fix(chalice): fix missing platform for EE

* fix(DB): fixed init_schema

* feat(DB): changes to support mobile sessions

* feat(chalice): mobile sessions search support

* fix(chalice): fixed signup

* Api v1.15.0 (#1559)

* refactor(chalice): changed default dev env vars

* refactor(chalice): changes

* refactor(chalice): changed payload fixer

* refactor(chalice): changed payload fixer
refactor(chalice): support duplicate filters

* refactor(chalice): changes

* feature(chalice): mobile sessions search

* refactor(chalice): fix EE refactored schema

* fix(chalice): fix missing platform for EE

* fix(DB): fixed init_schema

* feat(DB): changes to support mobile sessions

* feat(chalice): mobile sessions search support

* fix(chalice): fixed signup

* fix(DB): added missing column

* Api v1.15.0 no merge (#1562)

* refactor(chalice): changed default dev env vars

* refactor(chalice): changes

* refactor(chalice): changed payload fixer

* refactor(chalice): changed payload fixer
refactor(chalice): support duplicate filters

* refactor(chalice): changes

* feature(chalice): mobile sessions search

* refactor(chalice): fix EE refactored schema

* fix(chalice): fix missing platform for EE

* fix(DB): fixed init_schema

* feat(DB): changes to support mobile sessions

* feat(chalice): mobile sessions search support

* fix(chalice): fixed signup

* fix(DB): added missing column

* refactor(DB): changed queries

* fix(DB): added missing tables
2023-10-26 12:26:12 +02:00

164 lines
No EOL
5.9 KiB
PL/PgSQL

\set previous_version 'v1.14.0'
\set next_version 'v1.15.0'
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
--
ALTER TABLE IF EXISTS events_common.requests
ADD COLUMN IF NOT EXISTS transfer_size bigint NULL;
ALTER TABLE IF EXISTS public.sessions
ADD COLUMN IF NOT EXISTS timezone text NULL;
ALTER TABLE IF EXISTS public.projects
ADD COLUMN IF NOT EXISTS platform public.platform NOT NULL DEFAULT 'web';
CREATE TABLE IF NOT EXISTS public.crashes_ios
(
crash_ios_id text NOT NULL PRIMARY KEY,
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
name text NOT NULL,
reason text NOT NULL,
stacktrace text NOT NULL
);
CREATE INDEX IF NOT EXISTS crashes_ios_project_id_crash_ios_id_idx ON public.crashes_ios (project_id, crash_ios_id);
CREATE INDEX IF NOT EXISTS crashes_ios_project_id_idx ON public.crashes_ios (project_id);
CREATE TABLE IF NOT EXISTS events_common.crashes
(
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
timestamp bigint NOT NULL,
seq_index integer NOT NULL,
crash_ios_id text NULL REFERENCES public.crashes_ios (crash_ios_id) ON DELETE CASCADE,
PRIMARY KEY (session_id, timestamp, seq_index)
);
CREATE INDEX IF NOT EXISTS crashes_crash_ios_id_timestamp_idx ON events_common.crashes (crash_ios_id, timestamp);
CREATE INDEX IF NOT EXISTS crashes_timestamp_idx ON events_common.crashes (timestamp);
CREATE SCHEMA IF NOT EXISTS events_ios;
CREATE TABLE IF NOT EXISTS events_ios.views
(
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
timestamp bigint NOT NULL,
seq_index integer NOT NULL,
name text NOT NULL,
PRIMARY KEY (session_id, timestamp, seq_index)
);
CREATE TABLE IF NOT EXISTS events_ios.taps
(
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
timestamp bigint NOT NULL,
seq_index integer NOT NULL,
label text NOT NULL,
PRIMARY KEY (session_id, timestamp, seq_index)
);
CREATE INDEX IF NOT EXISTS taps_session_id_idx ON events_ios.taps (session_id);
CREATE INDEX IF NOT EXISTS taps_label_idx ON events_ios.taps (label);
CREATE INDEX IF NOT EXISTS taps_label_gin_idx ON events_ios.taps USING GIN (label gin_trgm_ops);
CREATE INDEX IF NOT EXISTS taps_timestamp_idx ON events_ios.taps (timestamp);
CREATE INDEX IF NOT EXISTS taps_label_session_id_timestamp_idx ON events_ios.taps (label, session_id, timestamp);
CREATE INDEX IF NOT EXISTS taps_session_id_timestamp_idx ON events_ios.taps (session_id, timestamp);
CREATE TABLE IF NOT EXISTS events_ios.inputs
(
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
timestamp bigint NOT NULL,
seq_index integer NOT NULL,
label text NOT NULL,
PRIMARY KEY (session_id, timestamp, seq_index)
);
CREATE INDEX IF NOT EXISTS inputs_session_id_idx ON events_ios.inputs (session_id);
CREATE INDEX IF NOT EXISTS inputs_label_gin_idx ON events_ios.inputs USING GIN (label gin_trgm_ops);
CREATE INDEX IF NOT EXISTS inputs_timestamp_idx ON events_ios.inputs (timestamp);
CREATE INDEX IF NOT EXISTS inputs_label_session_id_timestamp_idx ON events_ios.inputs (label, session_id, timestamp);
CREATE TABLE IF NOT EXISTS events_ios.swipes
(
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
timestamp bigint NOT NULL,
seq_index integer NOT NULL,
label text NOT NULL,
direction text NOT NULL,
PRIMARY KEY (session_id, timestamp, seq_index)
);
CREATE INDEX IF NOT EXISTS swipes_session_id_idx ON events_ios.swipes (session_id);
CREATE INDEX IF NOT EXISTS swipes_label_gin_idx ON events_ios.swipes USING GIN (label gin_trgm_ops);
CREATE INDEX IF NOT EXISTS swipes_timestamp_idx ON events_ios.swipes (timestamp);
CREATE INDEX IF NOT EXISTS swipes_label_session_id_timestamp_idx ON events_ios.swipes (label, session_id, timestamp);
ALTER TYPE issue_type ADD VALUE IF NOT EXISTS 'tap_rage';
ALTER TABLE IF EXISTS public.users
ADD COLUMN IF NOT EXISTS jwt_refresh_jti integer NULL DEFAULT NULL,
ADD COLUMN IF NOT EXISTS jwt_refresh_iat timestamp without time zone NULL DEFAULT NULL;
ALTER TABLE IF EXISTS events.clicks
ADD COLUMN IF NOT EXISTS x integer DEFAULT NULL,
ADD COLUMN IF NOT EXISTS y integer DEFAULT NULL;
ALTER TABLE IF EXISTS public.metrics
ADD COLUMN IF NOT EXISTS card_info jsonb NULL;
CREATE TABLE IF NOT EXISTS public.assist_events
(
event_id varchar NOT NULL PRIMARY KEY,
project_id integer NOT NULL,
session_id varchar NOT NULL,
event_type varchar NOT NULL,
event_state varchar NOT NULL,
timestamp integer NOT NULL,
user_id varchar,
agent_id varchar
);
CREATE TABLE IF NOT EXISTS public.assist_events_aggregates
(
timestamp BIGINT not null,
project_id integer not null,
agent_id integer not null,
assist_avg BIGINT,
call_avg BIGINT,
control_avg BIGINT,
assist_total BIGINT,
call_total BIGINT,
control_total BIGINT
);
CREATE TABLE IF NOT EXISTS public.assist_events_aggregates_logs
(
time BIGINT not null
);
ALTER TABLE IF EXISTS public.users
ADD COLUMN IF NOT EXISTS settings jsonb DEFAULT NULL;
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