hapifhir / hapi-fhir

🔥 HAPI FHIR - Java API for HL7 FHIR Clients and Servers
http://hapifhir.io
Apache License 2.0
2.05k stars 1.33k forks source link

Fix Postgres migration when schema is not public. #6340

Closed adriennesox closed 1 month ago

adriennesox commented 1 month ago

https://github.com/hapifhir/hapi-fhir/issues/6339

If the schema being used for HAPI in Postgres is not the public schema, the 7.4.0 migrations fails because the new DeletePrimaryKeyTask assumes the active schema is public when it looks up the primary key name.

This changes it to use current_schema() if available (i.e. the HAPI user has a search_path set) and 'public' otherwise.

Tested by running the 7.4.2 migrations with this change incorporated against a database where the old migrations were failing.

tadgh commented 1 month ago

Heya! Sorry it has taken me so long to get to this. Will review it today!

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 83.53%. Comparing base (406db33) to head (e03af57). Report is 51 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #6340 +/- ## ============================================ - Coverage 83.54% 83.53% -0.01% - Complexity 27432 27628 +196 ============================================ Files 1707 1720 +13 Lines 106185 106943 +758 Branches 13397 13453 +56 ============================================ + Hits 88710 89339 +629 - Misses 11750 11827 +77 - Partials 5725 5777 +52 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.