Fixed database migration process causing UNIQUE constraint in some edge cases where duplicate ID root folders where stored. #2253

This commit is contained in:
morpheus65535 2023-09-25 19:42:19 -04:00
parent 84e8872652
commit 166d0ccc95
1 changed files with 3 additions and 1 deletions

View File

@ -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;')