openreplay/ee/scripts/schema/db/rollback_dbs/postgresql/1.17.0/1.17.0.sql
Kraiem Taha Yassine d6c9f466e5
Dev (#1860)
* refactor(chalice): changed logging

* feat(DB): rollback scripts

* feat(DB): init&delta scripts
2024-01-26 18:03:00 +01:00

32 lines
No EOL
900 B
PL/PgSQL

\set previous_version 'v1.17.0-ee'
\set next_version 'v1.16.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
--
DROP TABLE IF EXISTS public.projects_conditions;
DROP TABLE IF EXISTS events.tags;
DROP TABLE IF EXISTS public.tags;
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