* feat(DB): rearranged queries feat(DB): ready for v1.15.0 * refactor(chalice): upgraded dependencies refactor(crons): upgraded dependencies refactor(alerts): upgraded dependencies * fix(chalice): return error when updating inexistant webhook * feat(chalice): fixed delete webhook response * feat(chalice): limit webhooks name length * feat(chalice): upgraded dependencies feat(alerts): upgraded dependencies feat(crons): upgraded dependencies * fix(chalice): remove urllib3 dependency * feat(chalice): remove FOSS to pydantic v2 * fix(chalice): freeze urllib3 to not have conflicts between boto3 and requests * feat(chalice): refactoring schema in progress * feat(chalice): refactoring schema in progress * feat(chalice): refactoring schema in progress * feat(chalice): refactoring schema in progress feat(chalice): upgraded dependencies * feat(chalice): refactored schema * fix(chalice): pull rebase dev * feat(DB): transfer size support * feat(chalice): support service account * feat(chalice): support service account * fix(chalice): fixed refactored PayloadSchema-name * feat(chalice): path analysis * feat(chalice): support service account 1/2 * feat(DB): timezone support * feat(chalice): upgraded dependencies feat(alerts): upgraded dependencies feat(crons): upgraded dependencies feat(assist): upgraded dependencies feat(sourcemaps): upgraded dependencies * feat(chalice): path analysis schema changes * feat(chalice): path analysis query change * feat(chalice): path analysis query change * feat(chalice): ios replay support * feat(chalice): ios replay support * feat(chalice): path analysis changes * feat(chalice): upgraded dependencies * feat(chalice): simple hide minor paths * feat(chalice): path analysis density * feat(chalice): session's replay ios events * feat(chalice): fixed typo * feat(chalice): support project's platform * feat(DB): support project's platform * feat(chalice): path analysis EE in progress * feat(chalice): project's platform API * feat(chalice): fixed create project * feat(chalice): EE path analysis in progress * feat(chalice): EE path analysis refactor(chalice): support specific database name for clickhouse-client * feat(chalice): upgraded dependencies feat(chalice): path analysis specific event type for startPoint feat(chalice): path analysis specific event type for endPoint feat(chalice): path analysis specific event type for exclude * refactoring(chalice): changed IOS click event type
88 lines
No EOL
3.6 KiB
PL/PgSQL
88 lines
No EOL
3.6 KiB
PL/PgSQL
\set previous_version 'v1.13.0-ee'
|
|
\set next_version 'v1.14.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
|
|
|
|
--
|
|
|
|
CREATE TABLE IF NOT EXISTS public.feature_flags
|
|
(
|
|
feature_flag_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
|
flag_key text NOT NULL,
|
|
description text DEFAULT NULL,
|
|
payload jsonb DEFAULT NULL,
|
|
flag_type text NOT NULL,
|
|
is_persist boolean NOT NULL DEFAULT FALSE,
|
|
is_active boolean NOT NULL DEFAULT FALSE,
|
|
created_by integer REFERENCES users (user_id) ON DELETE SET NULL,
|
|
updated_by integer REFERENCES users (user_id) ON DELETE SET NULL,
|
|
created_at timestamp without time zone NOT NULL DEFAULT timezone('utc'::text, now()),
|
|
updated_at timestamp without time zone NOT NULL DEFAULT timezone('utc'::text, now()),
|
|
deleted_at timestamp without time zone NULL DEFAULT NULL
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_feature_flags_project_id ON public.feature_flags (project_id);
|
|
|
|
ALTER TABLE feature_flags
|
|
ADD CONSTRAINT unique_project_flag_deleted UNIQUE (project_id, flag_key, deleted_at);
|
|
|
|
CREATE TABLE IF NOT EXISTS public.feature_flags_conditions
|
|
(
|
|
condition_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|
feature_flag_id integer NOT NULL REFERENCES feature_flags (feature_flag_id) ON DELETE CASCADE,
|
|
name text NOT NULL,
|
|
rollout_percentage integer NOT NULL,
|
|
filters jsonb NOT NULL DEFAULT '[]'::jsonb
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS public.feature_flags_variants
|
|
(
|
|
variant_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|
feature_flag_id integer NOT NULL REFERENCES feature_flags (feature_flag_id) ON DELETE CASCADE,
|
|
value text NOT NULL,
|
|
description text DEFAULT NULL,
|
|
payload jsonb DEFAULT NULL,
|
|
rollout_percentage integer DEFAULT 0
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS public.sessions_feature_flags
|
|
(
|
|
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
|
feature_flag_id integer NOT NULL REFERENCES feature_flags (feature_flag_id) ON DELETE CASCADE,
|
|
condition_id integer NULL REFERENCES feature_flags_conditions (condition_id) ON DELETE SET NULL
|
|
);
|
|
|
|
UPDATE public.roles
|
|
SET permissions = (SELECT array_agg(distinct e) FROM unnest(permissions || '{FEATURE_FLAGS}') AS e)
|
|
where not permissions @> '{FEATURE_FLAGS}';
|
|
|
|
ALTER TYPE public.user_role ADD VALUE IF NOT EXISTS 'service';
|
|
|
|
ALTER TABLE IF EXISTS public.users
|
|
ADD COLUMN IF NOT EXISTS service_account bool NOT NULL DEFAULT FALSE;
|
|
|
|
ALTER TABLE IF EXISTS public.roles
|
|
ADD COLUMN IF NOT EXISTS service_role bool NOT NULL DEFAULT FALSE;
|
|
|
|
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 |