Skip to content

fix(core): skip existing columns and indexes in re-run migrations - #65783

Open
MarioPym wants to merge 2 commits into
nextcloud:masterfrom
MarioPym:fix/guard-repeated-migration-schema-steps
Open

MarioPym wants to merge 2 commits into
nextcloud:masterfrom
MarioPym:fix/guard-repeated-migration-schema-steps

Conversation

@MarioPym

@MarioPym MarioPym commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Some core migrations add columns and indexes without checking first whether they already exist. On a clean upgrade this is fine, but when a migration runs again (for example after an interrupted upgrade, in our case from 29 to 33, or on a schema that already has these columns), the upgrade stops with "already exists" errors and the migration is never recorded as done.

This adds hasColumn() / hasIndex() checks to:

  • Version30000Date20240815080800 (webauthn.user_verification)
  • Version31000Date20240814184402 (preferences lazy/type/flags/indexed columns and their indexes)
  • Version33000Date20251023120529 (unique_bucket_store index on preview_locations)

This follows the same pattern already used in Version30000Date20240717111406 and in the files_trashbin migrations.

Checklist

AI (if applicable)

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

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Mario Alfonso Pym Mejía <pymm@hitss.com>
@MarioPym
MarioPym requested a review from a team as a code owner October 22, 2026 08:27
@MarioPym
MarioPym requested review from come-nc, icewind1991, leftybournes and salmart-dev and removed request for a team October 22, 2026 08:27
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

@come-nc come-nc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would say the tests for migrations are overkill, migration code is not expected to change that much, we should not add a test for each migration like this.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Mario Alfonso Pym Mejía <pymm@hitss.com>
@MarioPym

Copy link
Copy Markdown
Contributor Author

I would say the tests for migrations are overkill, migration code is not expected to change that much, we should not add a test for each migration like this.

Makes sense, I removed the migration tests.

@MarioPym
MarioPym requested a review from come-nc November 11, 2026 18:50
@come-nc come-nc added this to the Nextcloud 36 milestone Nov 12, 2026
@come-nc come-nc added the 3. to review Waiting for reviews label Nov 12, 2026

This branch has not been deployed

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants