def upgrade(): context = get_context() if isinstance(context.connection.engine.dialect, PGDialect): # add 'sync_type' column if missing op.add_column('services', sa.Column('sync_type', sa.UnicodeText(), nullable=True)) services = table( 'services', sa.Column('url', sa.UnicodeText()), sa.Column('type', sa.UnicodeText()), sa.Column('sync_type', sa.UnicodeText()), ) # transfer 'api' service types op.execute(services.update().where( services.c.type == op.inline_literal('project-api')).values({ 'type': op.inline_literal('api'), 'url': services.c.url + "/api", 'sync_type': op.inline_literal('project-api') })) op.execute(services.update().where( services.c.type == op.inline_literal('geoserver-api')).values({ 'type': op.inline_literal('api'), 'sync_type': op.inline_literal('geoserver-api') }))
def downgrade(): service = table( 'services', sa.Column('url', sa.UnicodeText()), sa.Column('type', sa.UnicodeText()), sa.Column('sync_type', sa.UnicodeText()), ) # transfer 'api' service types op.execute(service.update().where( service.c.sync_type == op.inline_literal('project-api')).values({ 'type': op.inline_literal('project-api'), 'url': func.replace(service.c.url, '/api', ''), })) op.execute(service.update().where( service.c.sync_type == op.inline_literal('geoserver-api')).values({ 'type': op.inline_literal('geoserver-api'), })) op.drop_column('services', 'sync_type')
def type(self): """ Identifier matching ``magpie.services.ServiceInterface.service_type``. """ # wps, wms, thredds,... return sa.Column(sa.UnicodeText())
def sync_type(self): """ Identifier matching ``magpie.helpers.SyncServiceInterface.sync_type``. """ # project-api, geoserver-api,... return sa.Column(sa.UnicodeText(), nullable=True)
def url(self): # http://localhost:8083 return sa.Column(sa.UnicodeText(), unique=True)