Commit eb968340 authored by echel0n's avatar echel0n
Browse files

Added check for scene_numbering table existence when upgrading main database to v16

parent 90b3a672
...@@ -16,17 +16,17 @@ down_revision = '15' ...@@ -16,17 +16,17 @@ down_revision = '15'
def upgrade(): def upgrade():
conn = op.get_bind() conn = op.get_bind()
meta = sa.MetaData(bind=conn) meta = sa.MetaData(bind=conn)
tv_episodes = sa.Table('tv_episodes', meta, autoload=True)
scene_numbering = sa.Table('scene_numbering', meta, autoload=True)
with op.get_context().begin_transaction(): if conn.engine.dialect.has_table(conn.engine, 'scene_numbering'):
for row in conn.execute(scene_numbering.select()): scene_numbering = sa.Table('scene_numbering', meta, autoload=True)
conn.execute('UPDATE tv_episodes SET scene_season = {} WHERE tv_episodes.showid = {}, tv_episodes.season = {}, tv_episodes.episode = {}' with op.get_context().begin_transaction():
.format(row.scene_season, row.indexer_id, row.season, row.episode)) for row in conn.execute(scene_numbering.select()):
conn.execute('UPDATE tv_episodes SET scene_episode = {} WHERE tv_episodes.showid = {}, tv_episodes.season = {}, tv_episodes.episode = {}' conn.execute('UPDATE tv_episodes SET scene_season = {} WHERE tv_episodes.showid = {}, tv_episodes.season = {}, tv_episodes.episode = {}'
.format(row.scene_episode, row.indexer_id, row.season, row.episode)) .format(row.scene_season, row.indexer_id, row.season, row.episode))
conn.execute('UPDATE tv_episodes SET scene_episode = {} WHERE tv_episodes.showid = {}, tv_episodes.season = {}, tv_episodes.episode = {}'
.format(row.scene_episode, row.indexer_id, row.season, row.episode))
op.drop_table('scene_numbering') op.drop_table('scene_numbering')
def downgrade(): def downgrade():
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment