Alembic helpers¶
Some helpers to use with Alembic migration tool.
-
class
geoalchemy2.alembic_helpers.
AddGeospatialColumnOp
(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 theOperations.add_geospatial_column()
method.
-
classmethod
-
class
geoalchemy2.alembic_helpers.
CreateGeospatialIndexOp
(index_name: str, table_name: str, columns: Sequence[Union[str, TextClause, ColumnElement[Any]]], schema: Optional[str] = None, unique: bool = False, **kw)[source]¶ Bases:
alembic.operations.ops.CreateIndexOp
-
classmethod
batch_create_geospatial_index
(operations, index_name, columns, **kw)[source]¶ This method is proxied on the
BatchOperations
class, via theBatchOperations.create_geospatial_index()
method.
-
classmethod
-
class
geoalchemy2.alembic_helpers.
CreateGeospatialTableOp
(table_name: str, columns: Sequence[Union[Column, Constraint]], schema: Optional[str] = None, _namespace_metadata: Optional[MetaData] = None, _constraints_included: bool = False, **kw)[source]¶ Bases:
alembic.operations.ops.CreateTableOp
Create a Geospatial Table in an Alembic migration context. This methodology originates from: https://alembic.sqlalchemy.org/en/latest/api/operations.html#operation-plugins
-
class
geoalchemy2.alembic_helpers.
DropGeospatialColumnOp
(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
batch_drop_geospatial_column
(operations, column_name, **kw)[source]¶ This method is proxied on the
BatchOperations
class, via theBatchOperations.drop_geospatial_column()
method.
-
classmethod
-
class
geoalchemy2.alembic_helpers.
DropGeospatialIndexOp
(*args, column_name, **kwargs)[source]¶ Bases:
alembic.operations.ops.DropIndexOp
-
classmethod
batch_drop_geospatial_index
(operations, index_name, **kw)[source]¶ This method is proxied on the
BatchOperations
class, via theBatchOperations.drop_geospatial_index()
method.
-
classmethod
-
class
geoalchemy2.alembic_helpers.
DropGeospatialTableOp
(table_name: str, schema: Optional[str] = None, table_kw: Optional[MutableMapping[Any, Any]] = None, _reverse: Optional[CreateTableOp] = None)[source]¶ Bases:
alembic.operations.ops.DropTableOp
-
geoalchemy2.alembic_helpers.
add_geo_column
(context, revision, op)[source]¶ Replace the default AddColumnOp by a geospatial-specific one.
-
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 – AddGeospatialColumnOp call, with attributes for table_name, column_name, column_type, and optional keywords.
-
geoalchemy2.alembic_helpers.
create_geo_index
(context, revision, op)[source]¶ Replace the default CreateIndexOp by a geospatial-specific one.
-
geoalchemy2.alembic_helpers.
create_geo_table
(context, revision, op)[source]¶ Replace the default CreateTableOp by a geospatial-specific one.
-
geoalchemy2.alembic_helpers.
create_geospatial_index
(operations, operation)[source]¶ Handle the actual index creation according to the dialect backend.
Parameters: - operations – Operations object from alembic base, defining high level migration operations.
- operation – CreateGeospatialIndexOp call, with attributes for table_name, column_name, column_type, and optional keywords.
-
geoalchemy2.alembic_helpers.
create_geospatial_table
(operations, operation)[source]¶ Handle the actual table creation according to the dialect backend.
Parameters: - operations – Operations object from alembic base, defining high level migration operations.
- operation – CreateGeospatialTableOp call, with attributes for table_name, column_name, column_type, and optional keywords.
-
geoalchemy2.alembic_helpers.
drop_geo_column
(context, revision, op)[source]¶ Replace the default DropColumnOp by a geospatial-specific one.
-
geoalchemy2.alembic_helpers.
drop_geo_index
(context, revision, op)[source]¶ Replace the default DropIndexOp by a geospatial-specific one.
-
geoalchemy2.alembic_helpers.
drop_geo_table
(context, revision, op)[source]¶ Replace the default DropTableOp by a geospatial-specific one.
-
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 – AddGeospatialColumnOp call, with attributes for table_name, column_name, column_type, and optional keywords.
-
geoalchemy2.alembic_helpers.
drop_geospatial_index
(operations, operation)[source]¶ Handle the actual index drop according to the dialect backend.
Parameters: - operations – Operations object from alembic base, defining high level migration operations.
- operation – DropGeospatialIndexOp call, with attributes for table_name, column_name, column_type, and optional keywords.
-
geoalchemy2.alembic_helpers.
drop_geospatial_table
(operations, operation)[source]¶ Handle the actual table removal according to the dialect backend.
Parameters: - operations – Operations object from alembic base, defining high level migration operations.
- operation – DropGeospatialTableOp call, with attributes for table_name, column_name, column_type, and optional keywords.
-
geoalchemy2.alembic_helpers.
render_add_geo_column
(autogen_context, op)[source]¶ Render the add_geospatial_column operation in migration script.
-
geoalchemy2.alembic_helpers.
render_create_geo_index
(autogen_context, op)[source]¶ Render the create_geospatial_index operation in migration script.
-
geoalchemy2.alembic_helpers.
render_create_geo_table
(autogen_context, op)[source]¶ Render the create_geospatial_table 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_drop_geo_index
(autogen_context, op)[source]¶ Render the drop_geospatial_index operation in migration script.
-
geoalchemy2.alembic_helpers.
render_drop_geo_table
(autogen_context, op)[source]¶ Render the drop_geospatial_table operation in migration script.
-
geoalchemy2.alembic_helpers.
render_item
(obj_type, obj, autogen_context)[source]¶ Add proper imports for spatial types.