feat(DB): stop upgrade on version hopping

This commit is contained in:
Taha Yassine Kraiem 2023-03-20 13:39:50 +01:00
parent e69bcbeff8
commit 13986a3c55
2 changed files with 34 additions and 0 deletions

View file

@ -1,3 +1,20 @@
DO
$$
DECLARE
previous_version CONSTANT text := 'v1.10.0-ee';
next_version CONSTANT text := 'v1.11.0-ee';
BEGIN
IF (SELECT openreplay_version()) = previous_version THEN
raise notice 'valid previous DB version';
ELSEIF (SELECT openreplay_version()) = next_version THEN
raise notice 'new version detected, nothing to do';
ELSE
RAISE EXCEPTION 'upgrade to % failed, invalid previous version, expected %, got %', next_version,previous_version,(SELECT openreplay_version());
END IF;
END ;
$$
LANGUAGE plpgsql;
BEGIN;
CREATE OR REPLACE FUNCTION openreplay_version()
RETURNS text AS

View file

@ -1,3 +1,20 @@
DO
$$
DECLARE
previous_version CONSTANT text := 'v1.10.0';
next_version CONSTANT text := 'v1.11.0';
BEGIN
IF (SELECT openreplay_version()) = previous_version THEN
raise notice 'valid previous DB version';
ELSEIF (SELECT openreplay_version()) = next_version THEN
raise notice 'new version detected, nothing to do';
ELSE
RAISE EXCEPTION 'upgrade to % failed, invalid previous version, expected %, got %', next_version,previous_version,(SELECT openreplay_version());
END IF;
END ;
$$
LANGUAGE plpgsql;
BEGIN;
CREATE OR REPLACE FUNCTION openreplay_version()
RETURNS text AS