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
This commit is contained in:
kodiakhq[bot] 2021-06-24 02:19:14 +00:00 committed by hasura-bot
parent 345cf8fe4c
commit a11b4135fc
3 changed files with 21 additions and 2 deletions

View File

@ -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"

View File

@ -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

View File

@ -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;
$$