From 23cf8ec01ef258f354631b3f93b582e073e64c1d Mon Sep 17 00:00:00 2001 From: Taha Yassine Kraiem Date: Mon, 20 Mar 2023 13:31:35 +0100 Subject: [PATCH] feat(DB): stop upgrade on version hopping --- .../db/init_dbs/postgresql/1.10.0/1.10.0.sql | 17 +++++++++++++++++ .../db/init_dbs/postgresql/1.5.0/1.5.0.sql | 17 +++++++++++++++++ .../db/init_dbs/postgresql/1.5.1/1.5.1.sql | 17 +++++++++++++++++ .../db/init_dbs/postgresql/1.5.2/1.5.2.sql | 17 +++++++++++++++++ .../db/init_dbs/postgresql/1.5.3/1.5.3.sql | 17 +++++++++++++++++ .../db/init_dbs/postgresql/1.5.4/1.5.4.sql | 17 +++++++++++++++++ .../db/init_dbs/postgresql/1.6.0/1.6.0.sql | 17 +++++++++++++++++ .../db/init_dbs/postgresql/1.7.0/1.7.0.sql | 17 +++++++++++++++++ .../db/init_dbs/postgresql/1.8.0/1.8.0.sql | 17 +++++++++++++++++ .../db/init_dbs/postgresql/1.8.1/1.8.1.sql | 17 +++++++++++++++++ .../db/init_dbs/postgresql/1.9.0/1.9.0.sql | 17 +++++++++++++++++ .../db/init_dbs/postgresql/1.10.0/1.10.0.sql | 17 +++++++++++++++++ .../db/init_dbs/postgresql/1.5.0/1.5.0.sql | 17 +++++++++++++++++ .../db/init_dbs/postgresql/1.5.1/1.5.1.sql | 17 +++++++++++++++++ .../db/init_dbs/postgresql/1.5.2/1.5.2.sql | 17 +++++++++++++++++ .../db/init_dbs/postgresql/1.5.3/1.5.3.sql | 17 +++++++++++++++++ .../db/init_dbs/postgresql/1.5.4/1.5.4.sql | 17 +++++++++++++++++ .../db/init_dbs/postgresql/1.6.0/1.6.0.sql | 17 +++++++++++++++++ .../db/init_dbs/postgresql/1.7.0/1.7.0.sql | 17 +++++++++++++++++ .../db/init_dbs/postgresql/1.8.0/1.8.0.sql | 17 +++++++++++++++++ .../db/init_dbs/postgresql/1.8.1/1.8.1.sql | 17 +++++++++++++++++ .../db/init_dbs/postgresql/1.9.0/1.9.0.sql | 17 +++++++++++++++++ 22 files changed, 374 insertions(+) diff --git a/ee/scripts/schema/db/init_dbs/postgresql/1.10.0/1.10.0.sql b/ee/scripts/schema/db/init_dbs/postgresql/1.10.0/1.10.0.sql index 0950ce407..ac1bfa2de 100644 --- a/ee/scripts/schema/db/init_dbs/postgresql/1.10.0/1.10.0.sql +++ b/ee/scripts/schema/db/init_dbs/postgresql/1.10.0/1.10.0.sql @@ -1,3 +1,20 @@ +DO +$$ + DECLARE + previous_version CONSTANT text := 'v1.9.0-ee'; + next_version CONSTANT text := 'v1.10.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 diff --git a/ee/scripts/schema/db/init_dbs/postgresql/1.5.0/1.5.0.sql b/ee/scripts/schema/db/init_dbs/postgresql/1.5.0/1.5.0.sql index 03af6067f..a73032e41 100644 --- a/ee/scripts/schema/db/init_dbs/postgresql/1.5.0/1.5.0.sql +++ b/ee/scripts/schema/db/init_dbs/postgresql/1.5.0/1.5.0.sql @@ -1,3 +1,20 @@ +DO +$$ + DECLARE + previous_version CONSTANT text := 'v1.4.0-ee'; + next_version CONSTANT text := 'v1.5.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 diff --git a/ee/scripts/schema/db/init_dbs/postgresql/1.5.1/1.5.1.sql b/ee/scripts/schema/db/init_dbs/postgresql/1.5.1/1.5.1.sql index de01efd53..e5f19444c 100644 --- a/ee/scripts/schema/db/init_dbs/postgresql/1.5.1/1.5.1.sql +++ b/ee/scripts/schema/db/init_dbs/postgresql/1.5.1/1.5.1.sql @@ -1,3 +1,20 @@ +DO +$$ + DECLARE + previous_version CONSTANT text := 'v1.5.0-ee'; + next_version CONSTANT text := 'v1.5.1-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 diff --git a/ee/scripts/schema/db/init_dbs/postgresql/1.5.2/1.5.2.sql b/ee/scripts/schema/db/init_dbs/postgresql/1.5.2/1.5.2.sql index 8ec804b02..675ecb871 100644 --- a/ee/scripts/schema/db/init_dbs/postgresql/1.5.2/1.5.2.sql +++ b/ee/scripts/schema/db/init_dbs/postgresql/1.5.2/1.5.2.sql @@ -1,3 +1,20 @@ +DO +$$ + DECLARE + previous_version CONSTANT text := 'v1.5.1-ee'; + next_version CONSTANT text := 'v1.5.2-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 diff --git a/ee/scripts/schema/db/init_dbs/postgresql/1.5.3/1.5.3.sql b/ee/scripts/schema/db/init_dbs/postgresql/1.5.3/1.5.3.sql index 0d68e46b9..55494b9c9 100644 --- a/ee/scripts/schema/db/init_dbs/postgresql/1.5.3/1.5.3.sql +++ b/ee/scripts/schema/db/init_dbs/postgresql/1.5.3/1.5.3.sql @@ -1,3 +1,20 @@ +DO +$$ + DECLARE + previous_version CONSTANT text := 'v1.5.2-ee'; + next_version CONSTANT text := 'v1.5.3-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 diff --git a/ee/scripts/schema/db/init_dbs/postgresql/1.5.4/1.5.4.sql b/ee/scripts/schema/db/init_dbs/postgresql/1.5.4/1.5.4.sql index 1a640b4be..fcb9cd832 100644 --- a/ee/scripts/schema/db/init_dbs/postgresql/1.5.4/1.5.4.sql +++ b/ee/scripts/schema/db/init_dbs/postgresql/1.5.4/1.5.4.sql @@ -1,4 +1,21 @@ \set ON_ERROR_STOP true +DO +$$ + DECLARE + previous_version CONSTANT text := 'v1.5.3-ee'; + next_version CONSTANT text := 'v1.5.4-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; + SET client_min_messages TO NOTICE; BEGIN; CREATE OR REPLACE FUNCTION openreplay_version() diff --git a/ee/scripts/schema/db/init_dbs/postgresql/1.6.0/1.6.0.sql b/ee/scripts/schema/db/init_dbs/postgresql/1.6.0/1.6.0.sql index bb0d7b7c0..1f545b1d6 100644 --- a/ee/scripts/schema/db/init_dbs/postgresql/1.6.0/1.6.0.sql +++ b/ee/scripts/schema/db/init_dbs/postgresql/1.6.0/1.6.0.sql @@ -1,3 +1,20 @@ +DO +$$ + DECLARE + previous_version CONSTANT text := 'v1.5.4-ee'; + next_version CONSTANT text := 'v1.6.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 diff --git a/ee/scripts/schema/db/init_dbs/postgresql/1.7.0/1.7.0.sql b/ee/scripts/schema/db/init_dbs/postgresql/1.7.0/1.7.0.sql index cdf316fa4..fc62e3767 100644 --- a/ee/scripts/schema/db/init_dbs/postgresql/1.7.0/1.7.0.sql +++ b/ee/scripts/schema/db/init_dbs/postgresql/1.7.0/1.7.0.sql @@ -1,3 +1,20 @@ +DO +$$ + DECLARE + previous_version CONSTANT text := 'v1.6.0-ee'; + next_version CONSTANT text := 'v1.7.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() diff --git a/ee/scripts/schema/db/init_dbs/postgresql/1.8.0/1.8.0.sql b/ee/scripts/schema/db/init_dbs/postgresql/1.8.0/1.8.0.sql index 8347a5c78..aeb87b3ff 100644 --- a/ee/scripts/schema/db/init_dbs/postgresql/1.8.0/1.8.0.sql +++ b/ee/scripts/schema/db/init_dbs/postgresql/1.8.0/1.8.0.sql @@ -1,3 +1,20 @@ +DO +$$ + DECLARE + previous_version CONSTANT text := 'v1.7.0-ee'; + next_version CONSTANT text := 'v1.8.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 diff --git a/ee/scripts/schema/db/init_dbs/postgresql/1.8.1/1.8.1.sql b/ee/scripts/schema/db/init_dbs/postgresql/1.8.1/1.8.1.sql index f02f9e0a8..59c8819a7 100644 --- a/ee/scripts/schema/db/init_dbs/postgresql/1.8.1/1.8.1.sql +++ b/ee/scripts/schema/db/init_dbs/postgresql/1.8.1/1.8.1.sql @@ -1,3 +1,20 @@ +DO +$$ + DECLARE + previous_version CONSTANT text := 'v1.8.0-ee'; + next_version CONSTANT text := 'v1.8.1-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 diff --git a/ee/scripts/schema/db/init_dbs/postgresql/1.9.0/1.9.0.sql b/ee/scripts/schema/db/init_dbs/postgresql/1.9.0/1.9.0.sql index c3483579d..8e969aeb6 100644 --- a/ee/scripts/schema/db/init_dbs/postgresql/1.9.0/1.9.0.sql +++ b/ee/scripts/schema/db/init_dbs/postgresql/1.9.0/1.9.0.sql @@ -1,3 +1,20 @@ +DO +$$ + DECLARE + previous_version CONSTANT text := 'v1.8.1-ee'; + next_version CONSTANT text := 'v1.9.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 diff --git a/scripts/schema/db/init_dbs/postgresql/1.10.0/1.10.0.sql b/scripts/schema/db/init_dbs/postgresql/1.10.0/1.10.0.sql index 3b085e1a9..d7a6af576 100644 --- a/scripts/schema/db/init_dbs/postgresql/1.10.0/1.10.0.sql +++ b/scripts/schema/db/init_dbs/postgresql/1.10.0/1.10.0.sql @@ -1,3 +1,20 @@ +DO +$$ + DECLARE + previous_version CONSTANT text := 'v1.9.0'; + next_version CONSTANT text := 'v1.10.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 diff --git a/scripts/schema/db/init_dbs/postgresql/1.5.0/1.5.0.sql b/scripts/schema/db/init_dbs/postgresql/1.5.0/1.5.0.sql index fa72d27da..f0a3203b7 100644 --- a/scripts/schema/db/init_dbs/postgresql/1.5.0/1.5.0.sql +++ b/scripts/schema/db/init_dbs/postgresql/1.5.0/1.5.0.sql @@ -1,3 +1,20 @@ +DO +$$ + DECLARE + previous_version CONSTANT text := 'v1.4.0'; + next_version CONSTANT text := 'v1.5.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 diff --git a/scripts/schema/db/init_dbs/postgresql/1.5.1/1.5.1.sql b/scripts/schema/db/init_dbs/postgresql/1.5.1/1.5.1.sql index 92fc44afe..c637b072d 100644 --- a/scripts/schema/db/init_dbs/postgresql/1.5.1/1.5.1.sql +++ b/scripts/schema/db/init_dbs/postgresql/1.5.1/1.5.1.sql @@ -1,3 +1,20 @@ +DO +$$ + DECLARE + previous_version CONSTANT text := 'v1.5.0'; + next_version CONSTANT text := 'v1.5.1'; + 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 diff --git a/scripts/schema/db/init_dbs/postgresql/1.5.2/1.5.2.sql b/scripts/schema/db/init_dbs/postgresql/1.5.2/1.5.2.sql index f4e26f93a..a94c1c3e9 100644 --- a/scripts/schema/db/init_dbs/postgresql/1.5.2/1.5.2.sql +++ b/scripts/schema/db/init_dbs/postgresql/1.5.2/1.5.2.sql @@ -1,3 +1,20 @@ +DO +$$ + DECLARE + previous_version CONSTANT text := 'v1.5.1'; + next_version CONSTANT text := 'v1.5.2'; + 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 diff --git a/scripts/schema/db/init_dbs/postgresql/1.5.3/1.5.3.sql b/scripts/schema/db/init_dbs/postgresql/1.5.3/1.5.3.sql index 159761b74..5b5bb92c4 100644 --- a/scripts/schema/db/init_dbs/postgresql/1.5.3/1.5.3.sql +++ b/scripts/schema/db/init_dbs/postgresql/1.5.3/1.5.3.sql @@ -1,3 +1,20 @@ +DO +$$ + DECLARE + previous_version CONSTANT text := 'v1.5.2'; + next_version CONSTANT text := 'v1.5.3'; + 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 diff --git a/scripts/schema/db/init_dbs/postgresql/1.5.4/1.5.4.sql b/scripts/schema/db/init_dbs/postgresql/1.5.4/1.5.4.sql index e7be94997..68aa530d3 100644 --- a/scripts/schema/db/init_dbs/postgresql/1.5.4/1.5.4.sql +++ b/scripts/schema/db/init_dbs/postgresql/1.5.4/1.5.4.sql @@ -1,4 +1,21 @@ \set ON_ERROR_STOP true +DO +$$ + DECLARE + previous_version CONSTANT text := 'v1.5.3'; + next_version CONSTANT text := 'v1.5.4'; + 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; + SET client_min_messages TO NOTICE; BEGIN; CREATE OR REPLACE FUNCTION openreplay_version() diff --git a/scripts/schema/db/init_dbs/postgresql/1.6.0/1.6.0.sql b/scripts/schema/db/init_dbs/postgresql/1.6.0/1.6.0.sql index d11cad5be..cf5c88eab 100644 --- a/scripts/schema/db/init_dbs/postgresql/1.6.0/1.6.0.sql +++ b/scripts/schema/db/init_dbs/postgresql/1.6.0/1.6.0.sql @@ -1,3 +1,20 @@ +DO +$$ + DECLARE + previous_version CONSTANT text := 'v1.5.4'; + next_version CONSTANT text := 'v1.6.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 diff --git a/scripts/schema/db/init_dbs/postgresql/1.7.0/1.7.0.sql b/scripts/schema/db/init_dbs/postgresql/1.7.0/1.7.0.sql index edc751da9..88a7acca7 100644 --- a/scripts/schema/db/init_dbs/postgresql/1.7.0/1.7.0.sql +++ b/scripts/schema/db/init_dbs/postgresql/1.7.0/1.7.0.sql @@ -1,3 +1,20 @@ +DO +$$ + DECLARE + previous_version CONSTANT text := 'v1.6.0'; + next_version CONSTANT text := 'v1.7.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 diff --git a/scripts/schema/db/init_dbs/postgresql/1.8.0/1.8.0.sql b/scripts/schema/db/init_dbs/postgresql/1.8.0/1.8.0.sql index b14b14f91..93e05f01f 100644 --- a/scripts/schema/db/init_dbs/postgresql/1.8.0/1.8.0.sql +++ b/scripts/schema/db/init_dbs/postgresql/1.8.0/1.8.0.sql @@ -1,3 +1,20 @@ +DO +$$ + DECLARE + previous_version CONSTANT text := 'v1.7.0'; + next_version CONSTANT text := 'v1.8.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 diff --git a/scripts/schema/db/init_dbs/postgresql/1.8.1/1.8.1.sql b/scripts/schema/db/init_dbs/postgresql/1.8.1/1.8.1.sql index c621da9c7..3b906c9ea 100644 --- a/scripts/schema/db/init_dbs/postgresql/1.8.1/1.8.1.sql +++ b/scripts/schema/db/init_dbs/postgresql/1.8.1/1.8.1.sql @@ -1,3 +1,20 @@ +DO +$$ + DECLARE + previous_version CONSTANT text := 'v1.8.0'; + next_version CONSTANT text := 'v1.8.1'; + 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 diff --git a/scripts/schema/db/init_dbs/postgresql/1.9.0/1.9.0.sql b/scripts/schema/db/init_dbs/postgresql/1.9.0/1.9.0.sql index 20a8bab1f..1b483432c 100644 --- a/scripts/schema/db/init_dbs/postgresql/1.9.0/1.9.0.sql +++ b/scripts/schema/db/init_dbs/postgresql/1.9.0/1.9.0.sql @@ -1,3 +1,20 @@ +DO +$$ + DECLARE + previous_version CONSTANT text := 'v1.8.1'; + next_version CONSTANT text := 'v1.9.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