Skip to content

[Mocha] Support out-of-band PostgreSQL schema migrations - #10486

Merged
PascalSenn merged 9 commits into
mainfrom
tte/postgres-transport-migrations
Oct 6, 2026
Merged

PascalSenn merged 9 commits into
mainfrom
tte/postgres-transport-migrations

Conversation

@tobias-tengler

Copy link
Copy Markdown
Member

Add explicit transport schema migration, offline SQL export, and an AutoMigrate switch that skips schema work when disabled. Preserve existing topology provisioning and migration history compatibility.

@github-actions github-actions Bot added 📚 documentation This issue is about working on our documentation. 🌶️ mocha labels Oct 6, 2026
@tobias-tengler
tobias-tengler force-pushed the tte/postgres-transport-migrations branch from eb9d0bb to 1cfa319 Compare October 6, 2026 07:35
@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Patch coverage

93.0% of changed lines covered (185/199)

File Covered Changed Patch %
…/Descriptors/PostgresQueueDescriptor.cs 0 1 0.0% 🔴
src/Mocha/src/Mocha.Transport.Postgres/ThrowHelper.cs 0 2 0.0% 🔴
…/src/Mocha.Transport.Postgres/PostgresTransportSchema.cs 23 30 76.7% 🔴
…/src/Mocha.Transport.Postgres/Connection/PostgresSchemaSql.cs 37 41 90.2% 🟡
…/Configurations/PostgresTransportConfiguration.cs 1 1 100.0% 🟢
…/Connection/PostgresConnectionManager.cs 1 1 100.0% 🟢
…/Connection/PostgresSchemaSql.Migrations.cs 114 114 100.0% 🟢
…/Descriptors/PostgresMessagingTransportDescriptor.cs 4 4 100.0% 🟢
…/src/Mocha.Transport.Postgres/PostgresMessagingTransport.cs 5 5 100.0% 🟢
Uncovered changed lines (JSON)
{
  "sha": "300213df86fcbceec9727083dfb58be72e15dc9d",
  "files": [
    { "path": "src/Mocha/src/Mocha.Transport.Postgres/Descriptors/PostgresQueueDescriptor.cs", "ranges": [[128, 128]] },
    { "path": "src/Mocha/src/Mocha.Transport.Postgres/ThrowHelper.cs", "ranges": [[6, 6], [9, 9]] },
    { "path": "src/Mocha/src/Mocha.Transport.Postgres/PostgresTransportSchema.cs", "ranges": [[26, 27], [31, 32], [41, 43]] },
    { "path": "src/Mocha/src/Mocha.Transport.Postgres/Connection/PostgresSchemaSql.cs", "ranges": [[39, 42]] }
  ]
}

Project coverage: 58.5% (313828/536115 lines)

@tobias-tengler
tobias-tengler marked this pull request as ready for review October 6, 2026 13:53
Copilot AI balanced review requested due to automatic review settings October 6, 2026 13:53
Add explicit transport schema migration, offline SQL export, and an AutoMigrate switch that skips schema work when disabled. Preserve existing topology provisioning and migration history compatibility.

Cover restricted runtime users, migration concurrency and rollback, SQL artifact execution, and EF outbox persistence with fresh and template databases. Document setup and export commands.
@tobias-tengler
tobias-tengler force-pushed the tte/postgres-transport-migrations branch from 3216cb5 to c259daa Compare October 6, 2026 13:54

Copilot AI 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.

Copilot review overview

🔵 Needs a closer look

The transactional database migration and restricted-permission behavior warrant final human validation against supported PostgreSQL environments.

Review effort: Balanced
Findings: None

What changed in this PR

Adds explicit PostgreSQL schema migration APIs so restricted runtime users can start the transport without schema permissions.

Changes:

  • Adds runtime and offline SQL migration APIs with transaction and advisory-lock protection.
  • Adds AutoMigrate configuration while preserving topology provisioning.
  • Adds migration, compatibility, rollback, and restricted-user tests and documentation.
File Description
website/​content/​docs/​mocha/​transports/​postgres.md Documents startup migration and manual setup.
src/​Mocha/​test/​Mocha.Transport.Postgres.Tests/​Connection/​PostgresTransportSchemaTests.cs Tests migration APIs and restricted users.
src/​Mocha/​test/​Mocha.Transport.Postgres.Tests/​Behaviors/​AutoProvisionIntegrationTests.cs Uses the public migration API.
src/​Mocha/​src/​Mocha.Transport.Postgres/​ThrowHelper.cs Centralizes migration exceptions.
src/​Mocha/​src/​Mocha.Transport.Postgres/​PostgresTransportSchema.cs Exposes migration and SQL-generation APIs.
src/​Mocha/​src/​Mocha.Transport.Postgres/​PostgresMessagingTransport.cs Honors AutoMigrate during startup.
src/​Mocha/​src/​Mocha.Transport.Postgres/​Descriptors/​PostgresQueueDescriptor.cs Qualifies the shared throw helper.
src/​Mocha/​src/​Mocha.Transport.Postgres/​Descriptors/​PostgresMessagingTransportDescriptor.cs Implements AutoMigrate configuration.
src/​Mocha/​src/​Mocha.Transport.Postgres/​Descriptors/​IPostgresMessagingTransportDescriptor.cs Adds the public descriptor contract.
src/​Mocha/​src/​Mocha.Transport.Postgres/​Connection/​PostgresSchemaSql.Migrations.cs Defines migration DDL.
src/​Mocha/​src/​Mocha.Transport.Postgres/​Connection/​PostgresSchemaSql.cs Generates guarded migration SQL.
src/​Mocha/​src/​Mocha.Transport.Postgres/​Connection/​PostgresSchemaMigrator.cs Removes the superseded migrator.
src/​Mocha/​src/​Mocha.Transport.Postgres/​Connection/​PostgresConnectionManager.cs Delegates to the public schema API.
src/​Mocha/​src/​Mocha.Transport.Postgres/​Configurations/​PostgresTransportConfiguration.cs Adds the migration setting and default.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@tobias-tengler tobias-tengler changed the title [Mocha] Fix PostgreSQL transport startup with restricted database users [Mocha] Support out-of-band PostgreSQL schema migrations Oct 6, 2026
@PascalSenn
PascalSenn merged commit faaea84 into main Oct 6, 2026
8 checks passed
@PascalSenn
PascalSenn deleted the tte/postgres-transport-migrations branch October 6, 2026 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📚 documentation This issue is about working on our documentation. 🌶️ mocha

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants