From 166d0ccc95112173acf6f6967b2d13cbb5d662c9 Mon Sep 17 00:00:00 2001 From: morpheus65535 Date: Mon, 25 Sep 2023 19:42:19 -0400 Subject: [PATCH] Fixed database migration process causing UNIQUE constraint in some edge cases where duplicate ID root folders where stored. #2253 --- migrations/versions/dc09994b7e65_.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/migrations/versions/dc09994b7e65_.py b/migrations/versions/dc09994b7e65_.py index 7274f252f..6670852b1 100644 --- a/migrations/versions/dc09994b7e65_.py +++ b/migrations/versions/dc09994b7e65_.py @@ -14,7 +14,7 @@ except ImportError: pass from app.database import TableHistory, TableHistoryMovie, TableBlacklist, TableBlacklistMovie, TableEpisodes, \ - TableShows, TableMovies, TableLanguagesProfiles + TableShows, TableMovies, TableLanguagesProfiles, TableShowsRootfolder, TableMoviesRootfolder # revision identifiers, used by Alembic. revision = 'dc09994b7e65' @@ -178,6 +178,7 @@ def upgrade(): # Update series rootfolder table with op.batch_alter_table('table_shows_rootfolder') as batch_op: + batch_op.execute(sa.delete(TableShowsRootfolder)) if bind.engine.name == 'postgresql': batch_op.execute('ALTER TABLE table_shows_rootfolder DROP CONSTRAINT IF EXISTS ' 'table_shows_rootfolder_pkey CASCADE;') @@ -259,6 +260,7 @@ def upgrade(): # Update movies rootfolder table with op.batch_alter_table('table_movies_rootfolder') as batch_op: + batch_op.execute(sa.delete(TableMoviesRootfolder)) if bind.engine.name == 'postgresql': batch_op.execute('ALTER TABLE table_movies_rootfolder DROP CONSTRAINT IF EXISTS ' 'table_movies_rootfolder_pkey CASCADE;')