From b13f8d59bd6ccadf868ab3284117b271c283c9f9 Mon Sep 17 00:00:00 2001 From: Conor Brady Date: Fri, 3 Nov 2023 14:25:06 -0700 Subject: [PATCH 1/2] Remove fire zone shape --- .../8e85e2b291a9_remove_zone_shapes.py | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 api/alembic/versions/8e85e2b291a9_remove_zone_shapes.py diff --git a/api/alembic/versions/8e85e2b291a9_remove_zone_shapes.py b/api/alembic/versions/8e85e2b291a9_remove_zone_shapes.py new file mode 100644 index 000000000..630efb3b1 --- /dev/null +++ b/api/alembic/versions/8e85e2b291a9_remove_zone_shapes.py @@ -0,0 +1,44 @@ +"""remove zone shapes + +Revision ID: 8e85e2b291a9 +Revises: d5115b761e39 +Create Date: 2023-11-03 14:10:44.782737 + +""" +from alembic import op +import sqlalchemy as sa +import geoalchemy2 +from sqlalchemy.orm.session import Session + +# revision identifiers, used by Alembic. +revision = '8e85e2b291a9' +down_revision = 'd5115b761e39' +branch_labels = None +depends_on = None + +shape_type_table = sa.Table('advisory_shape_types', sa.MetaData(), + sa.Column('id', sa.Integer), + sa.Column('name', sa.String)) + +shape_table = sa.Table('advisory_shapes', sa.MetaData(), + sa.Column('id', sa.Integer), + sa.Column('source_identifier', sa.String), + sa.Column('shape_type', sa.Integer), + sa.Column('geom', geoalchemy2.Geometry)) + + +def upgrade(): + # ### commands auto generated by Alembic ### + session = Session(bind=op.get_bind()) + + statement = shape_type_table.select().where(shape_type_table.c.name == 'fire_zone') + result = session.execute(statement).fetchone() + fire_zone_id = result.id + session.execute(shape_table.delete().where(shape_table.c.shape_type == fire_zone_id)) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic ### + pass # reimport in seperate migration if needed + # ### end Alembic commands ### From 04b5855feb7056b0416564f9aba66cf907b5d5df Mon Sep 17 00:00:00 2001 From: Conor Brady Date: Fri, 3 Nov 2023 14:28:10 -0700 Subject: [PATCH 2/2] Update comment --- api/alembic/versions/8e85e2b291a9_remove_zone_shapes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/alembic/versions/8e85e2b291a9_remove_zone_shapes.py b/api/alembic/versions/8e85e2b291a9_remove_zone_shapes.py index 630efb3b1..37b537cc5 100644 --- a/api/alembic/versions/8e85e2b291a9_remove_zone_shapes.py +++ b/api/alembic/versions/8e85e2b291a9_remove_zone_shapes.py @@ -40,5 +40,5 @@ def upgrade(): def downgrade(): # ### commands auto generated by Alembic ### - pass # reimport in seperate migration if needed + pass # reimport fire zones in seperate migration if needed # ### end Alembic commands ###