Skip to content

[Port to dtq-dev] Issue dspace-customers#903: drop hardcoded public. schema prefix from CLARIN migrations - #1406

Open
jr-rk wants to merge 1 commit into
dtq-devfrom
903-be/remove-public-schema-prefix
Open

[Port to dtq-dev] Issue dspace-customers#903: drop hardcoded public. schema prefix from CLARIN migrations#1406
jr-rk wants to merge 1 commit into
dtq-devfrom
903-be/remove-public-schema-prefix

Conversation

@jr-rk

@jr-rk jr-rk commented Aug 11, 2026

Copy link
Copy Markdown

Problem

Two CLARIN Flyway migrations hardcode the public. schema prefix in their ALTER TABLE … OWNER TO dspace statements. Instances whose DSpace tables live in a non-public schema cannot run these migrations.

Port of dataquest-dev/dspace-customers#903 (item 5). Source: customer/vsb-tuo e2fb08358e.

Root cause

ALTER TABLE public.<name> OWNER TO dspace binds the statement to the public schema instead of the connection's search_path. Dropping the qualifier lets each statement resolve against whatever schema the DSpace role actually uses.

Change set

  • V7.2_2022.07.28__Upgrade_to_Lindat_Clarin_schema.sql — 14 ALTER TABLE public.XALTER TABLE X.
  • V7.6_2024.08.05__Added_Preview_Tables.sql — 3 ALTER TABLE public.XALTER TABLE X.

Only the public.-qualified ALTER TABLE statements change; -- … Schema: public comments are untouched. The unrelated bitstore.xml hunk in the source commit (BitstreamStorageServiceImplSyncBitstreamStorageServiceImpl) is excluded — it is a storage-bean swap unrelated to schema qualification, and dtq-dev already uses SyncBitstreamStorageServiceImpl.

Test evidence

Static: git diff = 17 insertions / 17 deletions across the two migration files,
each an `ALTER TABLE public.X` -> `ALTER TABLE X` removal (no other lines touched;
`-- Schema: public` comments and legit `ALTER TABLE handle/...` statements unchanged).

Runtime before/after was NOT captured locally in this environment: the docker daemon is unavailable and the DSpace test-kernel cannot bootstrap in a standalone single-module run here (a pre-existing `ReportResultService` bean-wiring gap outside the full assembly, unrelated to this change -- it reproduces on a clean checkout). Runtime validation is delegated to this PR's CI Integration suite, which builds the full Spring context.

Risk & rollback — ⚠️ FLYWAY CHECKSUM, NEEDS HUMAN REVIEW

These are already-applied migrations, so editing their content changes their Flyway checksum. Instances that already ran V7.2 / V7.6 with the old text will fail flyway validate on next startup unless a flyway repair is run there. Please confirm before merge:

  • New / non-public-schema installs: safe and required (statements now resolve correctly).
  • Existing public-schema installs (dtq-dev/ufal): will need a one-time flyway repair (checksum re-baseline). No data change — only the recorded checksum.

Per reference/backend-stack.md, Flyway migrations are append-only; this edit is an intentional, reviewed exception matching the customer report's "unconditionally safe" assessment for the affected instances. Flagging explicitly rather than assuming.

Required upgrade step (existing installs)

Any instance that already ran V7.2 / V7.6 (dtq-dev, ufal, downstream CLARIN) must run a one-time Flyway repair after deploying this change, so the recorded checksums are re-baselined to the edited files:

./dspace database repair

This rewrites only the checksums in the flyway_schema_history table — no schema or data change. Without it, the next startup that carries any pending migration fails flyway validate on V7.2 / V7.6. Fresh installs need no action.

Notes / assumptions

Pure DDL-qualifier change; no schema/data semantics change.

The V7.2 Lindat/Clarin and V7.6 Preview migrations qualified their
`ALTER TABLE ... OWNER TO dspace` statements with `public.`, so instances
whose DSpace tables live in a non-public schema could not run them. Remove
the qualifier (17 statements across the two files) so each resolves against
the connection's search_path.

The unrelated bitstore.xml storage-bean swap from the source commit is
omitted -- dtq-dev already uses SyncBitstreamStorageServiceImpl.

Port of dataquest-dev/dspace-customers#903 (item 5). Source: customer/vsb-tuo e2fb083.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@jr-rk
jr-rk requested a lite review from Copilot and removed request for Copilot August 12, 2026 13:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates two CLARIN-specific PostgreSQL Flyway migrations to avoid hardcoding the public. schema in ALTER TABLE … OWNER TO dspace statements, allowing the migrations to run correctly when DSpace tables live in a non-public schema (via the connection search_path).

Changes:

  • Removed public. schema qualification from 14 ALTER TABLE … OWNER TO dspace statements in the Lindat/Clarin upgrade migration (V7.2).
  • Removed public. schema qualification from 3 ALTER TABLE … OWNER TO dspace statements in the preview tables migration (V7.6).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/postgres/V7.2_2022.07.28__Upgrade_to_Lindat_Clarin_schema.sql Drops public. qualifiers from ALTER TABLE … OWNER TO dspace so ownership changes resolve via search_path.
dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/postgres/V7.6_2024.08.05__Added_Preview_Tables.sql Drops public. qualifiers from ALTER TABLE … OWNER TO dspace for preview tables/sequences to support non-public schemas.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@jr-rk jr-rk self-assigned this Aug 13, 2026
@jr-rk
jr-rk requested a review from milanmajchrak August 13, 2026 07:40

@milanmajchrak milanmajchrak left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot update already existing flyway scripts because there will be mismatch with the Flyway checksum. You need to create a new Flyway script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants