From 1fbfa45cbeb9ab13170feba594c2aa8e2709d276 Mon Sep 17 00:00:00 2001 From: Taha Yassine Kraiem Date: Tue, 16 Jul 2024 17:26:16 +0200 Subject: [PATCH] refactor(DB): DB delta --- .../db/init_dbs/postgresql/1.20.0/1.20.0.sql | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 ee/scripts/schema/db/init_dbs/postgresql/1.20.0/1.20.0.sql diff --git a/ee/scripts/schema/db/init_dbs/postgresql/1.20.0/1.20.0.sql b/ee/scripts/schema/db/init_dbs/postgresql/1.20.0/1.20.0.sql new file mode 100644 index 0000000000..c0939d7b45 --- /dev/null +++ b/ee/scripts/schema/db/init_dbs/postgresql/1.20.0/1.20.0.sql @@ -0,0 +1,31 @@ +\set previous_version 'v1.19.0-ee' +\set next_version 'v1.20.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 + +-- +ALTER TABLE IF EXISTS events.clicks + ALTER COLUMN normalized_x SET DATA TYPE decimal, + ALTER COLUMN normalized_y SET DATA TYPE decimal; + +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