From a11b4135fcf8fbfe3e633b6e1ff418a9fbec73db Mon Sep 17 00:00:00 2001 From: "kodiakhq[bot]" <49736102+kodiakhq[bot]@users.noreply.github.com> Date: Thu, 24 Jun 2021 02:19:14 +0000 Subject: [PATCH] Use exceptions to handle compatibility with pg 9.6 in 2.0 upgrade migration https://github.com/hasura/graphql-engine-mono/pull/1651 Co-authored-by: Rakesh Emmadi <12475069+rakeshkky@users.noreply.github.com> Co-authored-by: Brandon Simmons <210815+jberryman@users.noreply.github.com> GitOrigin-RevId: cdb4a33cbb1a136bc30e8f0dd59aaae584d3a636 --- .circleci/server-upgrade-downgrade/run.sh | 9 +++++++++ CHANGELOG.md | 2 ++ server/src-rsr/migrations/43_to_44.sql | 12 ++++++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/.circleci/server-upgrade-downgrade/run.sh b/.circleci/server-upgrade-downgrade/run.sh index 1d8284a9b02..c65cdda9c72 100755 --- a/.circleci/server-upgrade-downgrade/run.sh +++ b/.circleci/server-upgrade-downgrade/run.sh @@ -154,9 +154,16 @@ get_server_upgrade_tests() { cd $RELEASE_PYTEST_DIR tmpfile="$(mktemp --dry-run)" set -x + # NOTE: any tests deselected in run_server_upgrade_pytest need to be filtered out here too + # # FIX ME: Deselecting some introspection tests and event trigger tests from the previous test suite # which throw errors on the latest build. Even when the output of the current build is more accurate. # Remove these deselects after the next stable release + # + # NOTE: test_events.py involves presistent state and probably isn't + # feasible to run here + # FIXME: re-enable test_graphql_queries.py::TestGraphQLQueryFunctions + # (fixing "already exists" error) if possible python3 -m pytest -q --collect-only --collect-upgrade-tests-to-file "$tmpfile" \ -m 'allow_server_upgrade_test and not skip_server_upgrade_test' \ --deselect test_schema_stitching.py::TestRemoteSchemaBasic::test_introspection \ @@ -170,6 +177,8 @@ get_server_upgrade_tests() { --deselect test_events.py::TestUpdateEvtQuery::test_update_basic \ --deselect test_schema_stitching.py::TestAddRemoteSchemaTbls::test_add_schema \ --deselect test_schema_stitching.py::TestAddRemoteSchemaTbls::test_add_conflicting_table \ + --deselect test_events.py \ + --deselect test_graphql_queries.py::TestGraphQLQueryFunctions \ "${args[@]}" 1>/dev/null 2>/dev/null set +x cat "$tmpfile" diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c371ea3037..61c79ade1a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ ## Next release (Add entries below in the order of server, console, cli, docs, others) +- server: fix resetting metadata catalog version to 43 while initializing postgres source with v1.0 catalog + ## v2.0.1 diff --git a/server/src-rsr/migrations/43_to_44.sql b/server/src-rsr/migrations/43_to_44.sql index 1092b6de8b7..02aa4ee4331 100644 --- a/server/src-rsr/migrations/43_to_44.sql +++ b/server/src-rsr/migrations/43_to_44.sql @@ -1,5 +1,13 @@ -- This migration adds versioning to metadata, used for optimistic locking in UIs. -- TODO: Are there changes required in catalog_versions.txt -ALTER TABLE hdb_catalog.hdb_metadata -ADD COLUMN IF NOT EXISTS "resource_version" INTEGER NOT NULL DEFAULT 1 UNIQUE; +DO $$ + BEGIN + BEGIN + ALTER TABLE hdb_catalog.hdb_metadata ADD COLUMN "resource_version" INTEGER NOT NULL DEFAULT 1 UNIQUE; + EXCEPTION + -- For pg 9.6 compatibility + WHEN duplicate_column THEN RAISE NOTICE 'column resource_version already exists in hdb_metadata'; + END; + END; +$$