Alembic helpers

Some helpers to use with Alembic migration tool.

class geoalchemy2.alembic_helpers.AddGeospatialColumn(table_name: str, column: Column, schema: Optional[str] = None, **kw)[source]

Bases: alembic.operations.ops.AddColumnOp

Add a Geospatial Column in an Alembic migration context. This methodology originates from: https://alembic.sqlalchemy.org/en/latest/api/operations.html#operation-plugins

classmethod add_geospatial_column(operations, table_name, column, schema=None)[source]

This method is proxied on the Operations class, via the Operations.add_geospatial_column() method.

reverse()[source]

Used to autogenerate the downgrade function.

class geoalchemy2.alembic_helpers.DropGeospatialColumn(table_name: str, column_name: str, schema: Optional[str] = None, _reverse: Optional[AddColumnOp] = None, **kw)[source]

Bases: alembic.operations.ops.DropColumnOp

Drop a Geospatial Column in an Alembic migration context.

classmethod drop_geospatial_column(operations, table_name, column_name, schema=None, **kw)[source]

This method is proxied on the Operations class, via the Operations.drop_geospatial_column() method.

reverse()[source]

Used to autogenerate the downgrade function.

geoalchemy2.alembic_helpers.add_geospatial_column(operations, operation)[source]

Handle the actual column addition according to the dialect backend.

Parameters:
  • operations – Operations object from alembic base, defining high level migration operations.
  • operation – AddGeospatialColumn call, with attributes for table_name, column_name, column_type, and optional keywords.
geoalchemy2.alembic_helpers.drop_geospatial_column(operations, operation)[source]

Handle the actual column removal according to the dialect backend.

Parameters:
  • operations – Operations object from alembic base, defining high level migration operations.
  • operation – AddGeospatialColumn call, with attributes for table_name, column_name, column_type, and optional keywords.
geoalchemy2.alembic_helpers.include_object(obj, name, obj_type, reflected, compare_to)[source]

Do not include spatial indexes if they are automatically created by GeoAlchemy2.

geoalchemy2.alembic_helpers.render_add_geo_column(autogen_context, op)[source]

Render the add_geospatial_column operation in migration script.

geoalchemy2.alembic_helpers.render_drop_geo_column(autogen_context, op)[source]

Render the drop_geospatial_column operation in migration script.

geoalchemy2.alembic_helpers.render_item(obj_type, obj, autogen_context)[source]

Apply custom rendering for selected items.