aboutsummaryrefslogtreecommitdiffhomepage
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
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
-rw-r--r--bazarr/app/database.py6
-rw-r--r--migrations/versions/cee6a710cb71_.py54
-rw-r--r--migrations/versions/dc09994b7e65_.py10
3 files changed, 62 insertions, 8 deletions
diff --git a/bazarr/app/database.py b/bazarr/app/database.py
index b33bc0a40..08fcf7db4 100644
--- a/bazarr/app/database.py
+++ b/bazarr/app/database.py
@@ -9,7 +9,7 @@ import flask_migrate
from dogpile.cache import make_region
from datetime import datetime
-from sqlalchemy import create_engine, inspect, DateTime, ForeignKey, Integer, LargeBinary, Text, func, text
+from sqlalchemy import create_engine, inspect, DateTime, ForeignKey, Integer, LargeBinary, Text, func, text, BigInteger
# importing here to be indirectly imported in other modules later
from sqlalchemy import update, delete, select, func # noqa W0611
from sqlalchemy.orm import scoped_session, sessionmaker, mapped_column
@@ -128,7 +128,7 @@ class TableEpisodes(Base):
episode_file_id = mapped_column(Integer)
failedAttempts = mapped_column(Text)
ffprobe_cache = mapped_column(LargeBinary)
- file_size = mapped_column(Integer)
+ file_size = mapped_column(BigInteger)
format = mapped_column(Text)
missing_subtitles = mapped_column(Text)
monitored = mapped_column(Text)
@@ -201,7 +201,7 @@ class TableMovies(Base):
failedAttempts = mapped_column(Text)
fanart = mapped_column(Text)
ffprobe_cache = mapped_column(LargeBinary)
- file_size = mapped_column(Integer)
+ file_size = mapped_column(BigInteger)
format = mapped_column(Text)
imdbId = mapped_column(Text)
missing_subtitles = mapped_column(Text)
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 ###