Skip to content

fix(db): reject invalid and duplicate migration identifiers - #63539

Open
joshtrichards wants to merge 5 commits into
jtr/test-fix-db-migration-version-handlingfrom
jtr/fix-db-migration-versioning-hardening
Open

fix(db): reject invalid and duplicate migration identifiers#63539
joshtrichards wants to merge 5 commits into
jtr/test-fix-db-migration-version-handlingfrom
jtr/fix-db-migration-versioning-hardening

Conversation

@joshtrichards

Copy link
Copy Markdown
Member
  • Resolves: #

Summary

This hardens migrations by preventing invalid or duplicate migration identifiers from producing an incorrect or ambiguous migration order.

Specifically:

  • Migration ordering depends on the documented <version>Date<YYYYMMDDHHMMSS> identifier format.
  • The parser accepts partial or malformed identifiers and otherwise falls back to natural string sorting.
  • Recursive migration discovery can silently overwrite one file (migration) when multiple files use the same identifier across subdirectories.

Changes:

  • Validate migration names against the supported version and timestamp format.
  • Reject overlapping identifiers discovered in multiple migration files instead of silently overwriting one of them.
  • Add test coverage for malformed filenames, stored identifiers, explicit targets, and duplicates.

TODO

  • Backport?

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@joshtrichards joshtrichards added this to the Nextcloud 35 milestone Aug 24, 2026
@joshtrichards
joshtrichards requested a review from a team as a code owner August 24, 2026 14:38
@joshtrichards
joshtrichards removed the request for review from a team August 24, 2026 14:38
@joshtrichards joshtrichards added the 2. developing Work in progress label Aug 24, 2026
@joshtrichards
joshtrichards requested a review from come-nc August 24, 2026 14:38
@joshtrichards joshtrichards added the feature: database Database related DB label Aug 24, 2026
@joshtrichards
joshtrichards requested review from a team and nickvergessen August 24, 2026 14:38
Validate migration names against the supported version and timestamp format.

Reject overlapping identifiers discovered in multiple migration files instead of silently overwriting one of them.

This hardens migrations by preventing them from running in a non-deterministic order when an unsupported migration identifier mix might produce a plausible but incorrect migration order.

Assisted-by: GitHubCopilot:gpt-5.6-sol

Signed-off-by: Josh <josh.t.richards@gmail.com>
Assisted-by: Copilot:gpt-5.6-sol

Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
For sortMigrations()

Assisted-by: Copilot:gpt-5.6-sol

Signed-off-by: Josh <josh.t.richards@gmail.com>
@joshtrichards
joshtrichards force-pushed the jtr/fix-db-migration-versioning-hardening branch from 7bb7445 to a8f1397 Compare August 24, 2026 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants