docs/v3/api-ref/python/prefect-server-database-alembic_commands.mdx
prefect.server.database.alembic_commandswith_alembic_lock <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/database/alembic_commands.py#L22" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>with_alembic_lock(fn: Callable[P, R]) -> Callable[P, R]
Decorator that prevents alembic commands from running concurrently. This is necessary because alembic uses a global configuration object that is not thread-safe.
This issue occurred in https://github.com/PrefectHQ/prefect-dask/pull/50, where
dask threads were simultaneously performing alembic upgrades, and causing
cryptic KeyError: 'config' when del globals_[attr_name].
alembic_config <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/database/alembic_commands.py#L41" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>alembic_config() -> 'Config'
alembic_upgrade <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/database/alembic_commands.py#L54" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>alembic_upgrade(revision: str = 'head', dry_run: bool = False) -> None
Run alembic upgrades on Prefect REST API database
Args:
revision: The revision passed to alembic downgrade. Defaults to 'head', upgrading all revisions.dry_run: Show what migrations would be made without applying them. Will emit sql statements to stdout.alembic_downgrade <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/database/alembic_commands.py#L76" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>alembic_downgrade(revision: str = '-1', dry_run: bool = False) -> None
Run alembic downgrades on Prefect REST API database
Args:
revision: The revision passed to alembic downgrade. Defaults to 'base', downgrading all revisions.dry_run: Show what migrations would be made without applying them. Will emit sql statements to stdout.alembic_revision <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/database/alembic_commands.py#L91" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>alembic_revision(message: Optional[str] = None, autogenerate: bool = False, **kwargs: Any) -> None
Create a new revision file for the database.
Args:
message: string message to apply to the revision.autogenerate: whether or not to autogenerate the script from the database.alembic_stamp <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/database/alembic_commands.py#L110" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>alembic_stamp(revision: Union[str, list[str], tuple[str, ...]]) -> None
Stamp the revision table with the given revision; don't run any migrations
Args:
revision: The revision passed to alembic stamp.