Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove fire zone shape #3210

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions api/alembic/versions/8e85e2b291a9_remove_zone_shapes.py
Original file line number Diff line number Diff line change
@@ -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 fire zones in seperate migration if needed
# ### end Alembic commands ###