run_migrations_online

safir.database.run_migrations_online(metadata, url, password)

Run Alembic migrations online using an async backend.

This function may only be called from the Alembic env.py file.

Parameters:
  • metadata (MetaData) – Schema metadata object for the current schema.

  • url (str | Url) – Database connection URL, not including the password.

  • password (str | SecretStr | None) – Database connection password.

Return type:

None

Examples

Normally this is called from alembic/env.py with code similar to the following:

from alembic import context
from safir.database import run_migrations_offline

from example.config import config
from example.schema import Base

if not context.is_offline_mode():
    run_migrations_online(
        Base.metadata, config.database_url, config.database_password
    )