Skip to content

feat: expose MIGRATION_TABLE constant on PactBroker::DB#906

Draft
impurist wants to merge 3 commits intomasterfrom
feat/explicit-migration-table-constant
Draft

feat: expose MIGRATION_TABLE constant on PactBroker::DB#906
impurist wants to merge 3 commits intomasterfrom
feat/explicit-migration-table-constant

Conversation

@impurist
Copy link
Copy Markdown
Contributor

Summary

  • Adds PactBroker::DB::MIGRATION_TABLE = :schema_migrations as an explicit public constant
  • Documents that run_migrations, is_current?, and check_current all accept a table: option for a custom tracking table
  • Includes a test script (script/test_migration_table_constant.rb) demonstrating migration with a custom table against postgres

Motivation

When consumers run pact_broker alongside their own proprietary migrations they need to keep migration state isolated. The existing code already forwards the options hash to Sequel::TimestampMigrator so custom table: works — this PR makes that API explicit and discoverable via the constant.

Test plan

  • DATABASE_URL=postgres://... BUNDLE_WITH=pg bundle exec ruby script/test_migration_table_constant.rb — should print === PASS ===
  • Existing test suite unchanged

🤖 Generated with Claude Code

impurist and others added 2 commits March 20, 2026 17:08
Adds an explicit MIGRATION_TABLE constant (:schema_migrations) to
PactBroker::DB so that consumers running pact_broker alongside their
own migrations can reference the default tracking table by name and
supply a different table: option to keep migration state isolated.

The existing run_migrations/is_current?/check_current methods already
forward the options hash to Sequel::TimestampMigrator, so no behaviour
change — this is purely a public API clarification.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…n tables

- Version.call prefers :pact_broker_schema_migrations when present,
  falls back to :schema_migrations then :schema_info — supports both
  the new split-table setup and existing single-table deployments
- TableDependencyCalculator excludes :pact_broker_schema_migrations and
  :pactflow_schema_migrations alongside the existing exclusions so
  migration tracking tables are never returned as truncatable tables

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@impurist impurist marked this pull request as draft March 20, 2026 08:03
Extracts tracking_tables into a named variable in TableDependencyCalculator
and ensures both pact_broker_schema_migrations and pactflow_schema_migrations
are excluded from ordered_tables (truncation) and explicitly dropped in
drop_tables alongside the legacy schema_migrations table.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant