BullMQ.Backends.Postgres.Migrator (BullMQ v2.0.2)

View Source

Runs the PostgreSQL backend's schema migrations, mirroring the Node.js migrator.ts.

All objects are created in schema (default bullmq), the connection-level namespace that replaces Redis's per-queue key prefix. The whole run happens inside a single transaction guarded by a transaction-scoped advisory lock, so concurrent starters across processes migrate exactly once.

Summary

Functions

Verifies the server meets the minimum major version (raises otherwise) and warns once when below the recommended version. No-op when skip_version_check.

The default schema (namespace) the backend lives in.

The highest schema version this build knows how to produce.

Validates a schema name and returns it double-quoted for safe DDL interpolation (schema names cannot be bind parameters).

Runs pending migrations for schema, returning the resulting schema version.

Functions

assert_postgres_version(pool, arg2)

@spec assert_postgres_version(term(), boolean()) :: :ok

Verifies the server meets the minimum major version (raises otherwise) and warns once when below the recommended version. No-op when skip_version_check.

default_schema()

The default schema (namespace) the backend lives in.

latest_schema_version()

The highest schema version this build knows how to produce.

quote_schema_name(schema)

@spec quote_schema_name(String.t()) :: String.t()

Validates a schema name and returns it double-quoted for safe DDL interpolation (schema names cannot be bind parameters).

run_migrations(pool, schema \\ "bullmq", opts \\ [])

@spec run_migrations(term(), String.t(), keyword()) ::
  {:ok, integer()} | {:error, term()}

Runs pending migrations for schema, returning the resulting schema version.

Runs inside a single Postgrex transaction guarded by a transaction-scoped advisory lock (serializing concurrent migrators for this schema).