aboutsummaryrefslogtreecommitdiffhomepage
path: root/migrations
diff options
context:
space:
mode:
authormorpheus65535 <[email protected]>2023-09-20 23:35:44 -0400
committermorpheus65535 <[email protected]>2023-09-20 23:35:44 -0400
commite2d0647d550972aa28b6917c3d2faf6f000efe71 (patch)
treeed981dcbf804d2b8723ca839539f8db4b4610b12 /migrations
parente06aad7fc6658d7a04479e66b4efb3ce2626b3da (diff)
downloadbazarr-e2d0647d550972aa28b6917c3d2faf6f000efe71.tar.gz
bazarr-e2d0647d550972aa28b6917c3d2faf6f000efe71.zip
Fixed Postgres issues while creating new database with v1.3.0. #2249v1.3.1-beta.1
Diffstat (limited to 'migrations')
-rw-r--r--migrations/versions/cee6a710cb71_.py54
-rw-r--r--migrations/versions/dc09994b7e65_.py10
2 files changed, 59 insertions, 5 deletions
diff --git a/migrations/versions/cee6a710cb71_.py b/migrations/versions/cee6a710cb71_.py
new file mode 100644
index 000000000..944559d0b
--- /dev/null
+++ b/migrations/versions/cee6a710cb71_.py
@@ -0,0 +1,54 @@
+"""empty message
+
+Revision ID: cee6a710cb71
+Revises: 195144da1f7e
+Create Date: 2023-09-20 23:11:15.678439
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = 'cee6a710cb71'
+down_revision = '195144da1f7e'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('table_episodes', schema=None) as batch_op:
+ batch_op.alter_column('file_size',
+ existing_type=sa.INTEGER(),
+ type_=sa.BigInteger(),
+ existing_nullable=True,
+ existing_server_default=sa.text('0'))
+
+ with op.batch_alter_table('table_movies', schema=None) as batch_op:
+ batch_op.alter_column('file_size',
+ existing_type=sa.INTEGER(),
+ type_=sa.BigInteger(),
+ existing_nullable=True,
+ existing_server_default=sa.text('0'))
+
+ # ### end Alembic commands ###
+
+
+def downgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('table_movies', schema=None) as batch_op:
+ batch_op.alter_column('file_size',
+ existing_type=sa.BigInteger(),
+ type_=sa.INTEGER(),
+ existing_nullable=True,
+ existing_server_default=sa.text('0'))
+
+ with op.batch_alter_table('table_episodes', schema=None) as batch_op:
+ batch_op.alter_column('file_size',
+ existing_type=sa.BigInteger(),
+ type_=sa.INTEGER(),
+ existing_nullable=True,
+ existing_server_default=sa.text('0'))
+
+ # ### end Alembic commands ###
diff --git a/migrations/versions/dc09994b7e65_.py b/migrations/versions/dc09994b7e65_.py
index fd30258d8..7274f252f 100644
--- a/migrations/versions/dc09994b7e65_.py
+++ b/migrations/versions/dc09994b7e65_.py
@@ -72,7 +72,7 @@ def upgrade():
# Update series table
with op.batch_alter_table('table_shows', recreate=should_recreate) as batch_op:
if bind.engine.name == 'postgresql':
- batch_op.execute('ALTER TABLE table_shows DROP CONSTRAINT IF EXISTS table_shows_pkey;')
+ batch_op.execute('ALTER TABLE table_shows DROP CONSTRAINT IF EXISTS table_shows_pkey CASCADE;')
batch_op.execute(sa.update(TableShows)
.values({TableShows.profileId: None})
.where(TableShows.profileId.not_in(sa.select(TableLanguagesProfiles.profileId))))
@@ -101,7 +101,7 @@ def upgrade():
# Update episodes table
with op.batch_alter_table('table_episodes') as batch_op:
if bind.engine.name == 'postgresql':
- batch_op.execute('ALTER TABLE table_episodes DROP CONSTRAINT IF EXISTS table_episodes_pkey;')
+ batch_op.execute('ALTER TABLE table_episodes DROP CONSTRAINT IF EXISTS table_episodes_pkey CASCADE;')
batch_op.execute(sa.delete(TableEpisodes).where(TableEpisodes.sonarrSeriesId.not_in(
sa.select(TableShows.sonarrSeriesId))))
batch_op.alter_column(column_name='sonarrSeriesId', existing_type=sa.INTEGER(), nullable=True)
@@ -180,14 +180,14 @@ def upgrade():
with op.batch_alter_table('table_shows_rootfolder') as batch_op:
if bind.engine.name == 'postgresql':
batch_op.execute('ALTER TABLE table_shows_rootfolder DROP CONSTRAINT IF EXISTS '
- 'table_shows_rootfolder_pkey;')
+ 'table_shows_rootfolder_pkey CASCADE;')
batch_op.alter_column(column_name='id', existing_type=sa.INTEGER(), nullable=False, autoincrement=True)
batch_op.create_primary_key(constraint_name='pk_table_shows_rootfolder', columns=['id'])
# Update movies table
with op.batch_alter_table('table_movies', recreate=should_recreate) as batch_op:
if bind.engine.name == 'postgresql':
- batch_op.execute('ALTER TABLE table_movies DROP CONSTRAINT IF EXISTS table_movies_pkey;')
+ batch_op.execute('ALTER TABLE table_movies DROP CONSTRAINT IF EXISTS table_movies_pkey CASCADE;')
batch_op.execute(sa.update(TableMovies)
.values({TableMovies.profileId: None})
.where(TableMovies.profileId.not_in(sa.select(TableLanguagesProfiles.profileId))))
@@ -261,7 +261,7 @@ def upgrade():
with op.batch_alter_table('table_movies_rootfolder') as batch_op:
if bind.engine.name == 'postgresql':
batch_op.execute('ALTER TABLE table_movies_rootfolder DROP CONSTRAINT IF EXISTS '
- 'table_movies_rootfolder_pkey;')
+ 'table_movies_rootfolder_pkey CASCADE;')
batch_op.alter_column(column_name='id', existing_type=sa.INTEGER(), nullable=False, autoincrement=True)
batch_op.create_primary_key(constraint_name='pk_table_movies_rootfolder', columns=['id'])
# ### end Alembic commands ###