"""remove_underscore_naming_convention Revision ID: 04bdaa2ef7fc Revises: 382ec1d24c28 Create Date: 2022-09-22 13:00:22.138213 """ from alembic import op import sqlalchemy as sa from sqlalchemy.dialects import postgresql # revision identifiers, used by Alembic. revision = '04bdaa2ef7fc' down_revision = '382ec1d24c28' branch_labels = None depends_on = None def upgrade(): bind = op.get_bind() bind.execute(""" UPDATE "Campaign" SET naming_convention = null WHERE id IN ( SELECT C.id FROM "Campaign" AS C JOIN "Project" AS P ON C.project_id = P.id JOIN "Label" AS L ON P.label_id = L.id where L.country = 'UK' AND (C.source = 'dec' OR C.source is null) AND C.naming_convention = '_' ) """) def downgrade(): pass