Fixes #471 - Tolerate absent duplicate indexes - #472
Open
jakduch wants to merge 1 commit into
Open
Conversation
Migration 020 now treats an already missing duplicate index as the desired state and continues removing the remaining redundant indexes. Assisted-By: Codex 5.6 Sol High
adamruzicka
reviewed
Aug 20, 2026
adamruzicka
left a comment
Contributor
There was a problem hiding this comment.
471? Now this is some stuff of the legend.
One comment inline
| up do | ||
| alter_table(:dynflow_actions) do | ||
| drop_index [:execution_plan_uuid, :id] | ||
| if indexes(:dynflow_actions).key?(:dynflow_actions_execution_plan_uuid_id_index) |
Contributor
There was a problem hiding this comment.
For the actual dropping, we rely on sequel to derive the index name from the table and the columns. Could we reuse that function rather than using the exact index name?
Author
There was a problem hiding this comment.
Yes, good point. default_index_name(table, Array(columns)).to_sym will keep the existence check aligned with the name Sequel uses in drop_index. I’ll update it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #471.
Related: Foreman Redmine #31736.
Migration 020 unconditionally dropped indexes that duplicate primary-key constraints. When one of those indexes was already absent, the migration aborted instead of accepting the schema as already being in the desired state.
Check the indexes reported by Sequel before dropping each duplicate. This keeps the migration portable across the supported PostgreSQL and SQLite adapters and allows it to continue removing the remaining duplicate indexes.
Add a regression test that migrates through version 19, removes one duplicate index, and verifies that migration 20 succeeds and removes the other two.
Testing
test/persistence_migrations_test.rb: 1 run, 6 assertions, 0 failures, 0 errorsAI usage disclosure
Per the community discussion on AI policy, the issue was investigated and the changes, tests, and PR wording were prepared with the assistance of Codex 5.6 Sol High. The resulting changes were reviewed before submitting. The commit also includes an
Assisted-Bytrailer.