Skip to content

[blocker] Dapper PostgreSQL migrations skip all create-table branches with FluentMigrator 7.2 ("PostgreSQL" vs "Postgres") #255

Description

@sfmskywalker

Found by Code Review while testing #251 / #252.

Summary

The Dapper migrations gate every create-table branch on IfDatabase("SqlServer", "Oracle", "MySql", "Postgres"). With FluentMigrator 7.2, the PostgreSQL processor never reports "Postgres": AddPostgres() registers Postgres15_0Processor, which reports DatabaseType = "PostgreSQL15_0" and aliases { "PostgreSQL15_0", "PostgreSQL" }. IfDatabase does an exact (case-insensitive) match against the processor's DatabaseType plus DatabaseTypeAliases, so "Postgres" never matches. Every create-table branch (both the SQL Server/Oracle/MySql/Postgres branch and the Sqlite branch) is skipped on PostgreSQL.

Result: on a fresh Dapper + PostgreSQL install, migration 10001 (Elsa:Management:V3.0) creates nothing and then 10002 (Elsa:Management:V3.1) fails, because it runs Alter.Table("WorkflowDefinitions").AddColumn("IsSystem") against a table that doesn't exist.

This already fails on release/3.9.0 before #251, so #251 didn't cause it.

Affected files / pattern

Same on release/3.9.0, main and release/3.8.4 (the files are identical across these branches):

  • src/modules/persistence/Elsa.Persistence.Dapper.Migrations/Management/Initial.cs (migration 10001): 2× IfDatabase("SqlServer", "Oracle", "MySql", "Postgres") (tables WorkflowDefinitions, WorkflowInstances)
  • src/modules/persistence/Elsa.Persistence.Dapper.Migrations/Runtime/Initial.cs (migration 20001): 4× the same IfDatabase(...) create-table branches
  • src/modules/persistence/Elsa.Persistence.Dapper.Migrations/Runtime/V3_3.cs (migration 20004): 1× the same pattern
  • Failure surfaces at src/modules/persistence/Elsa.Persistence.Dapper.Migrations/Management/V3_1.cs (migration 10002), the first migration that assumes the tables exist.

The Identity migrations don't use IfDatabase.

FluentMigrator 7.2.0 references:

Is 3.8.4 affected?

FluentMigrator versions in Directory.Packages.props (central package management; the Dapper csproj files don't override versions):

Ref FluentMigrator / Runner / Runner.Core / Runner.SqlServer / Runner.SQLite
main 7.2.0
release/3.9.0 7.2.0
release/3.8.4 (branch) 7.2.0
3.8.4 (tag) 7.2.0
release/3.8.1, release/3.8.2, release/3.7.0, release/3.6.0 7.2.0

Conclusion: FluentMigrator 7.2 did not come in with 3.9. It has been pinned at 7.2.0 since at least 3.6.0, and the affected migration files on release/3.8.4 are identical to release/3.9.0. So 3.8.4 (and earlier 3.6–3.8 releases) are very likely affected too, which makes this a pre-existing bug rather than a 3.9 regression.

Caveat: this repo doesn't reference FluentMigrator.Runner.Postgres. The host adds it and calls AddPostgres() in DapperMigrationsFeature.ConfigureRunner, so the processor that actually runs depends on the host's runner package. Any 7.x Runner.Postgres (which is what FluentMigrator 7.2.0 core pairs with) defaults to Postgres15_0Processor and is affected. I haven't reproduced this on 3.8.4 at runtime. This conclusion comes from reading the code and package versions.

Suggested fix

  • Make the PostgreSQL gate match the processor's current identifiers, e.g. IfDatabase("SqlServer", "Oracle", "MySql", "Postgres", "PostgreSQL"), preferably via ProcessorIdConstants rather than string literals. Another option is the predicate overload (IfDatabase(t => t.StartsWith("Postgres", StringComparison.OrdinalIgnoreCase))), which also covers PostgreSQL15_0, Postgres92, and so on. Apply this to all occurrences in Management/Initial.cs, Runtime/Initial.cs and Runtime/V3_3.cs.
  • Add a test that runs the full Dapper migration set against a fresh PostgreSQL database (e.g. Testcontainers) using AddPostgres(), and asserts that all migrations apply and the expected tables exist. The current Elsa.Persistence.Dapper.UnitTests only reference FluentMigrator.Runner.SQLite, which is why this went unnoticed.

Target

ext 3.9 blocker. Fix on release/3.9.0 and main.

Activity

  1. added this to the 3.9 milestone on Sep 28, 2026
  2. added theissue type on Sep 28, 2026
  3. sfmskywalker commented on Sep 28, 2026

    @sfmskywalker
    MemberAuthor

    Starting on this. The Postgres checks in Management/Initial.cs (10001), Runtime/Initial.cs (20001) and Runtime/V3_3.cs (20004) will match both Postgres and FluentMigrator's PostgreSQL* processor names. Existing PG databases that are already past those versions won't be affected. A fresh-database PG migration test runs through Testcontainers. PRs go into release/3.9.0 and main.

  4. sfmskywalker commented on Sep 28, 2026

    @sfmskywalker
    MemberAuthor

    Delivered in #258 (release/3.9.0, merge 9d9049e6) and #259 (main, merge 212dc558). Dapper on PostgreSQL now works on fresh databases, and existing ones heal on their next migrate.

    For PostgreSQL databases from 3.6–3.8 that are stuck at migration 10002, run DELETE FROM "VersionInfo" WHERE "Version"=10001; and then migrate again. Hand-made lowercase PostgreSQL schemas aren't supported. The ID to Id change also fixes instance search on case-sensitive SQL Server.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriaged

    Type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions