From c8e34d424bf69d23534d81fc75ae02a092d43e39 Mon Sep 17 00:00:00 2001 From: morpheus65535 Date: Thu, 4 Jul 2024 22:59:33 -0400 Subject: [PATCH] no log: added new columns to database schema to support better upgrade process and languages profiles tag --- bazarr/app/database.py | 3 +++ migrations/versions/1e38aa77a491_.py | 39 ++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 migrations/versions/1e38aa77a491_.py diff --git a/bazarr/app/database.py b/bazarr/app/database.py index b3236fc90..fa612c4eb 100644 --- a/bazarr/app/database.py +++ b/bazarr/app/database.py @@ -172,6 +172,7 @@ class TableHistory(Base): video_path = mapped_column(Text) matched = mapped_column(Text) not_matched = mapped_column(Text) + upgradedFromId = mapped_column(Integer, ForeignKey('table_history.id')) class TableHistoryMovie(Base): @@ -190,6 +191,7 @@ class TableHistoryMovie(Base): video_path = mapped_column(Text) matched = mapped_column(Text) not_matched = mapped_column(Text) + upgradedFromId = mapped_column(Integer, ForeignKey('table_history_movie.id')) class TableLanguagesProfiles(Base): @@ -202,6 +204,7 @@ class TableLanguagesProfiles(Base): name = mapped_column(Text, nullable=False) mustContain = mapped_column(Text) mustNotContain = mapped_column(Text) + tag = mapped_column(Text) class TableMovies(Base): diff --git a/migrations/versions/1e38aa77a491_.py b/migrations/versions/1e38aa77a491_.py new file mode 100644 index 000000000..7e0c279c7 --- /dev/null +++ b/migrations/versions/1e38aa77a491_.py @@ -0,0 +1,39 @@ +"""empty message + +Revision ID: 1e38aa77a491 +Revises: 452dd0f0b578 +Create Date: 2024-07-04 22:40:35.056744 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '1e38aa77a491' +down_revision = '452dd0f0b578' +branch_labels = None +depends_on = None + + +def upgrade(): + with op.batch_alter_table('table_history', schema=None) as batch_op: + batch_op.add_column(sa.Column('upgradedFromId', sa.Integer(), nullable=True)) + batch_op.create_foreign_key(constraint_name='fk_history_upgradedFromId_id', + referent_table='table_history', + local_cols=['upgradedFromId'], + remote_cols=['id']) + + with op.batch_alter_table('table_history_movie', schema=None) as batch_op: + batch_op.add_column(sa.Column('upgradedFromId', sa.Integer(), nullable=True)) + batch_op.create_foreign_key(constraint_name='fk_history_movie_upgradedFromId_id', + referent_table='table_history_movie', + local_cols=['upgradedFromId'], + remote_cols=['id']) + + with op.batch_alter_table('table_languages_profiles', schema=None) as batch_op: + batch_op.add_column(sa.Column('tag', sa.Text(), nullable=True)) + + +def downgrade(): + pass