aboutsummaryrefslogtreecommitdiffhomepage
path: root/migrations
diff options
context:
space:
mode:
authormorpheus65535 <[email protected]>2024-10-20 17:20:57 -0400
committermorpheus65535 <[email protected]>2024-10-20 17:20:57 -0400
commit5934d1b7ab63ace42d6cf4995637882199067f86 (patch)
tree8840c2e062c74cc0cc248d067f55ca2d662567be /migrations
parenta9243c6c03fd7d24eb522231cf899d25aa850b66 (diff)
downloadbazarr-5934d1b7ab63ace42d6cf4995637882199067f86.tar.gz
bazarr-5934d1b7ab63ace42d6cf4995637882199067f86.zip
no log: fixed latest db migration
Diffstat (limited to 'migrations')
-rw-r--r--migrations/versions/8baf97427327_.py29
1 files changed, 23 insertions, 6 deletions
diff --git a/migrations/versions/8baf97427327_.py b/migrations/versions/8baf97427327_.py
index bb6c7274a..1ee67b1f9 100644
--- a/migrations/versions/8baf97427327_.py
+++ b/migrations/versions/8baf97427327_.py
@@ -16,18 +16,35 @@ branch_labels = None
depends_on = None
+bind = op.get_context().bind
+insp = sa.inspect(bind)
+tables = insp.get_table_names()
+sqlite = bind.engine.name == 'sqlite'
+
+
+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():
with op.batch_alter_table('table_episodes', schema=None) as batch_op:
- batch_op.add_column(sa.Column('created_at_timestamp', sa.DateTime(), nullable=True))
- batch_op.add_column(sa.Column('updated_at_timestamp', sa.DateTime(), nullable=True))
+ if not column_exists('table_episodes', 'created_at_timestamp'):
+ batch_op.add_column(sa.Column('created_at_timestamp', sa.DateTime(), nullable=True))
+ if not column_exists('table_episodes', 'updated_at_timestamp'):
+ batch_op.add_column(sa.Column('updated_at_timestamp', sa.DateTime(), nullable=True))
with op.batch_alter_table('table_movies', schema=None) as batch_op:
- batch_op.add_column(sa.Column('created_at_timestamp', sa.DateTime(), nullable=True))
- batch_op.add_column(sa.Column('updated_at_timestamp', sa.DateTime(), nullable=True))
+ if not column_exists('table_movies', 'created_at_timestamp'):
+ batch_op.add_column(sa.Column('created_at_timestamp', sa.DateTime(), nullable=True))
+ if not column_exists('table_movies', 'updated_at_timestamp'):
+ batch_op.add_column(sa.Column('updated_at_timestamp', sa.DateTime(), nullable=True))
with op.batch_alter_table('table_shows', schema=None) as batch_op:
- batch_op.add_column(sa.Column('created_at_timestamp', sa.DateTime(), nullable=True))
- batch_op.add_column(sa.Column('updated_at_timestamp', sa.DateTime(), nullable=True))
+ if not column_exists('table_shows', 'created_at_timestamp'):
+ batch_op.add_column(sa.Column('created_at_timestamp', sa.DateTime(), nullable=True))
+ if not column_exists('table_shows', 'updated_at_timestamp'):
+ batch_op.add_column(sa.Column('updated_at_timestamp', sa.DateTime(), nullable=True))
def downgrade():