"""add_labels_abbreviations Revision ID: f97d95643973 Revises: b46b611aebf1 Create Date: 2022-04-06 09:13:37.589748 """ from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. revision = 'f97d95643973' down_revision = 'ee9d964c5966' branch_labels = None depends_on = None labels = [ { "name": "Columbia Records UK", "abbreviation": "COL", }, { "name": "RCA UK", "abbreviation": "RCA", }, { "name": "Black Butter Records UK", "abbreviation": "BB", }, { "name": "Dreamlife Records UK", "abbreviation": "DL", }, { "name": "Commercial Group UK", "abbreviation": "CMG", }, { "name": "Insanity UK", "abbreviation": "INS", }, { "name": "Since ''93 UK", "abbreviation": "S93", }, { "name": "5K Records UK", "abbreviation": "5k", }, { "name": "MagicStar UK", "abbreviation": "MGS", }, { "name": "Masterworks UK", "abbreviation": "MSW", }, { "name": "Ministry of Sound UK", "abbreviation": "MOS", }, { "name": "Music For Nations UK", "abbreviation": "MFN", }, { "name": "SME International UK", "abbreviation": "INTL", }, { "name": "Relentless Records UK", "abbreviation": "RR", }, { "name": "SME UK Limited", "abbreviation": "LIM", }, { "name": "WEAREBLK UK", "abbreviation": "WRB", }, ] def upgrade(): bind = op.get_bind() meta = sa.MetaData(bind=bind) meta.reflect() op.add_column('Label', sa.Column('abbreviation', sa.String(), nullable=True)) op.add_column('Label', sa.Column('country', sa.String(), nullable=True)) for label in labels: bind.execute(f'''UPDATE "Label" set abbreviation = '{label["abbreviation"]}', country = 'UK' where name = '{label["name"]}' ''') def downgrade(): pass