aboutsummaryrefslogtreecommitdiffhomepage
path: root/migrations/versions/452dd0f0b578_.py
blob: 13e6239889448f7f9448bcc882a4cf8d7e9046e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""empty message

Revision ID: 452dd0f0b578
Revises: 30f37e2e15e1
Create Date: 2024-05-06 20:27:15.618027

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '452dd0f0b578'
down_revision = '30f37e2e15e1'
branch_labels = None
depends_on = None

bind = op.get_context().bind
insp = sa.inspect(bind)


def column_exists(table_name, column_name):
    columns = insp.get_columns(table_name)
    return any(c["name"] == column_name for c in columns)


def upgrade():
    if column_exists('table_shows', 'alternativeTitle'):
        with op.batch_alter_table('table_shows', schema=None) as batch_op:
            batch_op.drop_column('alternativeTitle')

    if not column_exists('table_languages_profiles', 'originalFormat'):
        with op.batch_alter_table('table_languages_profiles', schema=None) as batch_op:
            batch_op.add_column(sa.Column('originalFormat', sa.Integer(), server_default='0'))

    if not column_exists('table_languages_profiles', 'mustContain'):
        with op.batch_alter_table('table_languages_profiles', schema=None) as batch_op:
            batch_op.add_column(sa.Column('mustContain', sa.Text(), server_default='[]'))

    if not column_exists('table_languages_profiles', 'mustNotContain'):
        with op.batch_alter_table('table_languages_profiles', schema=None) as batch_op:
            batch_op.add_column(sa.Column('mustNotContain', sa.Text(), server_default='[]'))


def downgrade():
    pass