anymodel.utilities.migrations

Database migration utilities.

This module provides utilities for automatic database schema migrations using Alembic.

Functions

anymodel.utilities.migrations.automigrate(engine, metadata)[source]

Automatically migrate database schema to match metadata.

Detects differences between the current database schema and the provided metadata, then applies the necessary migrations.

Parameters:
  • engine – SQLAlchemy engine connected to the database

  • metadata – SQLAlchemy metadata describing the desired schema

See: https://alembic.sqlalchemy.org/en/latest/cookbook.html#run-alembic-operation-objects-directly-as-in-from-autogenerate