feat(DB): DB changes for v1.18.0 (#1871)

This commit is contained in:
Kraiem Taha Yassine 2024-02-01 17:56:41 +01:00 committed by GitHub
parent 8263773bff
commit 9879bd65bb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 119 additions and 51 deletions

View file

@ -0,0 +1 @@
CREATE OR REPLACE FUNCTION openreplay_version AS() -> 'v1.18.0-ee';

View file

@ -1,4 +1,4 @@
CREATE OR REPLACE FUNCTION openreplay_version AS() -> 'v1.17.0-ee';
CREATE OR REPLACE FUNCTION openreplay_version AS() -> 'v1.18.0-ee';
CREATE DATABASE IF NOT EXISTS experimental;
CREATE TABLE IF NOT EXISTS experimental.autocomplete

View file

@ -0,0 +1,29 @@
\set previous_version 'v1.17.0-ee'
\set next_version 'v1.18.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
--
DROP FUNCTION IF EXISTS events.funnel(steps integer[], m integer);
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

View file

@ -1,4 +1,4 @@
\set or_version 'v1.17.0-ee'
\set or_version 'v1.18.0-ee'
SET client_min_messages TO NOTICE;
\set ON_ERROR_STOP true
SELECT EXISTS (SELECT 1
@ -48,30 +48,6 @@ end;
$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION events.funnel(steps integer[], m integer) RETURNS boolean AS
$$
DECLARE
step integer;
c integer := 0;
BEGIN
FOREACH step IN ARRAY steps
LOOP
IF step + c = 0 THEN
IF c = 0 THEN
RETURN false;
END IF;
c := 0;
CONTINUE;
END IF;
IF c + 1 = step THEN
c := step;
END IF;
END LOOP;
RETURN c = m;
END;
$$ LANGUAGE plpgsql IMMUTABLE;
CREATE OR REPLACE FUNCTION notify_integration() RETURNS trigger AS
$$
BEGIN

View file

@ -0,0 +1,28 @@
\set previous_version 'v1.18.0-ee'
\set next_version 'v1.17.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 downgrade 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
--
COMMIT;
\elif :is_next
\echo new version detected :'next_version', nothing to do
\else
\warn skipping DB downgrade of :'next_version', expected previous version :'previous_version', found :'current_version'
\endif

View file

@ -0,0 +1,29 @@
\set previous_version 'v1.17.0'
\set next_version 'v1.18.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
--
DROP FUNCTION IF EXISTS events.funnel(steps integer[], m integer);
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

View file

@ -1,4 +1,4 @@
\set or_version 'v1.17.0'
\set or_version 'v1.18.0'
SET client_min_messages TO NOTICE;
\set ON_ERROR_STOP true
SELECT EXISTS (SELECT 1
@ -48,30 +48,6 @@ end;
$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION events.funnel(steps integer[], m integer) RETURNS boolean AS
$$
DECLARE
step integer;
c integer := 0;
BEGIN
FOREACH step IN ARRAY steps
LOOP
IF step + c = 0 THEN
IF c = 0 THEN
RETURN false;
END IF;
c := 0;
CONTINUE;
END IF;
IF c + 1 = step THEN
c := step;
END IF;
END LOOP;
RETURN c = m;
END;
$$ LANGUAGE plpgsql IMMUTABLE;
CREATE OR REPLACE FUNCTION notify_integration() RETURNS trigger AS
$$
BEGIN

View file

@ -0,0 +1,29 @@
\set previous_version 'v1.18.0'
\set next_version 'v1.17.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 downgrade 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
--
COMMIT;
\elif :is_next
\echo new version detected :'next_version', nothing to do
\else
\warn skipping DB downgrade of :'next_version', expected previous version :'previous_version', found :'current_version'
\endif