diff options
author | morpheus65535 <[email protected]> | 2023-07-27 17:51:03 -0400 |
---|---|---|
committer | morpheus65535 <[email protected]> | 2023-07-27 17:51:03 -0400 |
commit | 6bc46fe4e97a3127b3baab1373bb2111b57f7ec4 (patch) | |
tree | 36a54f34b73ff5b3d25c2439ba1c82a70f3eed2c | |
parent | c9ced5719168605b2012bef2bf9fc360b9f9f701 (diff) | |
download | bazarr-6bc46fe4e97a3127b3baab1373bb2111b57f7ec4.tar.gz bazarr-6bc46fe4e97a3127b3baab1373bb2111b57f7ec4.zip |
Fixed issue with unused rowid columns and removed custom score profiles tables as they aren't used anymore.
-rw-r--r-- | bazarr/app/database.py | 22 | ||||
-rw-r--r-- | migrations/versions/195144da1f7e_.py | 45 |
2 files changed, 45 insertions, 22 deletions
diff --git a/bazarr/app/database.py b/bazarr/app/database.py index 2a8791b88..645276ea5 100644 --- a/bazarr/app/database.py +++ b/bazarr/app/database.py @@ -119,15 +119,6 @@ class TableBlacklistMovie(Base): timestamp = mapped_column(DateTime, default=datetime.now) -class TableCustomScoreProfiles(Base): - __tablename__ = 'table_custom_score_profiles' - - id = mapped_column(Integer, primary_key=True) - name = mapped_column(Text) - media = mapped_column(Text) - score = mapped_column(Integer) - - class TableEpisodes(Base): __tablename__ = 'table_episodes' @@ -289,19 +280,6 @@ class TableShowsRootfolder(Base): path = mapped_column(Text) -class TableCustomScoreProfileConditions(Base): - __tablename__ = 'table_custom_score_profile_conditions' - - id = mapped_column(Integer, primary_key=True) - profile_id = mapped_column(Integer, ForeignKey('table_custom_score_profiles.id'), nullable=False) - type = mapped_column(Text) - value = mapped_column(Text) - required = mapped_column(Integer, nullable=False) - negate = mapped_column(Integer, nullable=False) - - profile = relationship('TableCustomScoreProfiles') - - def init_db(): database.begin() diff --git a/migrations/versions/195144da1f7e_.py b/migrations/versions/195144da1f7e_.py new file mode 100644 index 000000000..9d31259b6 --- /dev/null +++ b/migrations/versions/195144da1f7e_.py @@ -0,0 +1,45 @@ +"""empty message + +Revision ID: 195144da1f7e +Revises: 95cd4cf40d7a +Create Date: 2023-07-27 13:14:08.825037 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '195144da1f7e' +down_revision = '95cd4cf40d7a' +branch_labels = None +depends_on = None + +bind = op.get_context().bind +insp = sa.inspect(bind) +tables = insp.get_table_names() + + +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') as batch_op: + if column_exists('table_episodes', 'rowid'): + batch_op.drop_column(column_name='rowid') + + with op.batch_alter_table('table_movies') as batch_op: + if column_exists('table_movies', 'rowid'): + batch_op.drop_column(column_name='rowid') + + if 'table_custom_score_profiles' in tables: + op.drop_table('table_custom_score_profiles') + + if 'table_custom_score_profile_conditions' in tables: + op.drop_table('table_custom_score_profile_conditions') + + +def downgrade(): + pass |