Repository navigation
Use shared-context helpers in migration specs - #5529
Open
philippthun wants to merge 1 commit into
Open
philippthun wants to merge 1 commit into
philippthun wants to merge 1 commit into
Conversation
jochenehret
previously approved these changes
Nov 3, 2026
philippthun
force-pushed
the
fix-migration-idempotency-tests
branch
from
November 12, 2026 08:57
d121ca4 to
6428955
Compare
philippthun
force-pushed
the
fix-migration-idempotency-tests
branch
2 times, most recently
from
November 13, 2026 11:09
07dbabe to
c5ef235
Compare
Replace raw Sequel::Migrator.run calls in migration specs with the run_migration and revert_migration helpers, and use the test_up_migration_idempotency / test_down_migration_idempotency helpers for idempotency checks. The idempotency helpers delete or insert the schema_migrations row before re-running, so the migration body is genuinely re-executed. Re-running the migrator to the same target only is a no-op and does not test idempotency. Apply each helper only where the migration body supports it: options like add_column(if_not_exists:) are honoured on PostgreSQL but ignored on MySQL, so such migrations assert idempotency in a database-gated context. Single-database migrations are exercised only there, and migrations with unguarded DDL or no reversible down assert only the steps that apply. Each added step asserts state in the same style as the rest of its spec. Update spec/migrations/Readme.md to document the four helpers. Add two custom cops: UseMigrationHelpers flags raw Sequel::Migrator.run calls in specs that include the shared context, and RequireMigrationSharedContext flags per-migration specs that omit it. Legacy and bigint-step specs are excluded via .rubocop_cc.yml.
philippthun
force-pushed
the
fix-migration-idempotency-tests
branch
from
November 13, 2026 11:10
c5ef235 to
5730218
Compare
This branch has not been deployed
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.
Replace raw
Sequel::Migrator.runcalls in migration specs with therun_migrationandrevert_migration helpers, and use thetest_up_migration_idempotency/test_down_migration_idempotencyhelpers for idempotency checks.The idempotency helpers delete or insert the
schema_migrationsrow before re-running, so the migration body is genuinely re-executed. Re-running the migrator to the same target only is a no-op and does not test idempotency.Apply each helper only where the migration body supports it: options like
add_column(if_not_exists:)are honoured on PostgreSQL but ignored on MySQL, so such migrations assert idempotency in a database-gated context. Single-database migrations are exercised only there, and migrations with unguarded DDL or no reversible down assert only the steps that apply. Each added step asserts state in the same style as the rest of its spec.Update
spec/migrations/Readme.mdto document the four helpers.Add two custom cops:
UseMigrationHelpersflags rawSequel::Migrator.runcalls in specs that include the shared context, andRequireMigrationSharedContextflags per-migration specs that omit it. Legacy and bigint-step specs are excluded via.rubocop_cc.yml.This change was developed with AI assistance; all code was reviewed and tested by me.
I have reviewed the contributing guide
I have viewed, signed, and submitted the Contributor License Agreement
I have made this pull request to the
mainbranchI have run all the unit tests using
bundle exec rakeI have run CF Acceptance Tests