Skip to content

[Bug]: PostgresStorage::setup() conflicts with user migrations sharing the same _sqlx_migrations table #64

@ALAWIII

Description

@ALAWIII

What happened?

Description:

When using PostgresStorage::setup() alongside application-level sqlx migrations on the same database, the two migrators share the same _sqlx_migrations table. Apalis's internal migrator only knows its own 2 migrations, so when it encounters user-defined migration entries in the table, it panics with:

migration XXXXXXXXXXXXXXX was previously applied but is missing in the resolved migrations

Suggested fix:

  • Expose a way to pass a custom migrations table name or schema to PostgresStorage::setup(), or
  • Internally call .set_ignore_missing(true) on Apalis's sqlx Migrator, or
  • Document that a separate database/schema is required when coexisting with user migrations

Expected behavior

Apalis should ignore migration entries it doesn't own, similar to sqlx's --ignore-missing / .set_ignore_missing(true) flag.

Steps to reproduce

  1. Run app migrations via sqlx::migrate!().run(&pool) — records N migrations in _sqlx_migrations
  2. Call PostgresStorage::setup(&pool) — Apalis sees unknown entries and errors out

Version

1.0.0-rc.x

Environment

  • OS: Linux sandwitch 6.19.2-2-cachyos V0.3 apalis#1 SMP PREEMPT_DYNAMIC Mon, 16 Feb 2026 20:41:55 +0000 x86_64 GNU/Linux
  • Rust version: 1.90
  • Cargo version: 1.90

Relevant log output

{"timestamp":"2026-02-28T11:56:24.712192Z","level":"ERROR","fields":{"message":"failed to establish connection to db: migration 20260106165349 was previously applied but is missing in the resolved migrations"},"target":"family_cloud::jobs"}
    test delete::delete_list_of_folders ... FAILED

Additional context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions