Skip to content

Commit

Permalink
Alembic DB upgrade for name change WFS3 to OGCFeat add-on for #431 (#432
Browse files Browse the repository at this point in the history
)
  • Loading branch information
justb4 committed Aug 10, 2022
1 parent d2209a3 commit b470680
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions GeoHealthCheck/migrations/versions/933717a14052_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
"""empty message
Revision ID: 933717a14052
Revises: 3381760e2a8c
Create Date: 2022-08-10 15:26:38.960066
DB Upgrade for name changes OGC API Features components.
Finalizes name-changes in PR
https://github.com/geopython/GeoHealthCheck/pull/431
Basically this SQL:
UPDATE resource SET resource_type = 'OGCFeat' WHERE resource_type = 'OGC:WFS3';
UPDATE probe_vars SET probe_class = 'GeoHealthCheck.plugins.probe.ogcfeat.OGCFeatCaps' WHERE probe_class = 'GeoHealthCheck.plugins.probe.wfs3.WFS3Caps';
UPDATE probe_vars SET probe_class = 'GeoHealthCheck.plugins.probe.ogcfeat.OGCFeatDrilldown' WHERE probe_class = 'GeoHealthCheck.plugins.probe.wfs3.WFS3Drilldown';
UPDATE probe_vars SET probe_class = 'GeoHealthCheck.plugins.probe.ogcfeat.OGCFeatOpenAPIValidator' WHERE probe_class = 'GeoHealthCheck.plugins.probe.wfs3.WFS3OpenAPIValidator';
"""
from alembic import op
from sqlalchemy.sql import table, column
from sqlalchemy import String

# revision identifiers, used by Alembic.
revision = '933717a14052'
down_revision = '3381760e2a8c'
branch_labels = None
depends_on = None


def upgrade():
print('Update (upgrade) records refering to OGC:WFS3 and WFS3 names to OGCFeat')

resource = table('resource',
column('resource_type', String)
)

op.execute(
resource.update().
where(resource.c.resource_type == op.inline_literal('OGC:WFS3')).
values({'resource_type': op.inline_literal('OGCFeat')})
)

probe_vars = table('probe_vars',
column('probe_class', String)
)

op.execute(
probe_vars.update().
where(probe_vars.c.probe_class == op.inline_literal('GeoHealthCheck.plugins.probe.wfs3.WFS3Caps')).
values({'probe_class': op.inline_literal('GeoHealthCheck.plugins.probe.ogcfeat.OGCFeatCaps')})
)

op.execute(
probe_vars.update().
where(probe_vars.c.probe_class == op.inline_literal('GeoHealthCheck.plugins.probe.wfs3.WFS3Drilldown')).
values({'probe_class': op.inline_literal('GeoHealthCheck.plugins.probe.ogcfeat.OGCFeatDrilldown')})
)

op.execute(
probe_vars.update().
where(probe_vars.c.probe_class == op.inline_literal('GeoHealthCheck.plugins.probe.wfs3.WFS3OpenAPIValidator')).
values({'probe_class': op.inline_literal('GeoHealthCheck.plugins.probe.ogcfeat.OGCFeatOpenAPIValidator')})
)


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
print('Update (downgrade) records refering to OGCFeat to OGC:WFS3 and WFS3')
resource = table('resource',
column('resource_type', String)
)

op.execute(
resource.update().
where(resource.c.resource_type == op.inline_literal('OGCFeat')).
values({'resource_type': op.inline_literal('OGC:WFS3')})
)

# ### end Alembic commands ###

0 comments on commit b470680

Please sign in to comment.