morpheus65535 / bazarr

Bazarr is a companion application to Sonarr and Radarr. It manages and downloads subtitles based on your requirements. You define your preferences by TV show or movie and Bazarr takes care of everything for you.
https://www.bazarr.media
GNU General Public License v3.0
2.78k stars 218 forks source link

Missing SQL columns after an upgrade #2430

Closed kulisau closed 6 months ago

kulisau commented 6 months ago

I upgraded linuxserver/bazarr container to the latest version (1.4.2) and started getting exception log entries in docker logs. I can't tell the exact version I've upgraded from, but it was installed probably around a year ago.

The docker logs:

2024-03-15 08:42:21,347 - apscheduler.executors.default    (7fcec3af0b38) :  ERROR (base:131) - Job "update_series (trigger: date[2024-03-15 08:42:21 UTC], next run at: 2024-03-15 08:42:21 UTC)" raised an exception
Connection to localhost (127.0.0.1) 6767 port [tcp/*] succeeded!
[ls.io-init] done.
2024-03-15 08:42:21,775 - apscheduler.executors.default    (7fcec3d02b38) :  ERROR (base:131) - Job "update_movies (trigger: date[2024-03-15 08:42:21 UTC], next run at: 2024-03-15 08:42:21 UTC)" raised an exception
2024-03-15 08:50:01,865 - app.app                          (7fcecfa04b38) :  ERROR (app:1741) - Exception on /api/system/languages/profiles [GET]

Traces after the job: update_movies:

sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such column: table_languages_profiles.originalFormat

update_series:

sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such column: table_languages_profiles.originalFormat

Exception on /api/system/languages/profiles [GET]:

sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such column: table_languages_profiles.mustContain

Software (please complete the following information):

kulisau commented 6 months ago

Running the below script seems to have revived the functionality. Not sure if that's the proper way to deal this it, though... Another question if the column type is correct...

import sqlite3

db_path = 'bazarr.db'
conn = sqlite3.connect(db_path)
cursor = conn.cursor()

try:
    cursor.execute('''ALTER TABLE table_languages_profiles
                      ADD COLUMN originalFormat TEXT''')
    cursor.execute('''ALTER TABLE table_languages_profiles
                      ADD COLUMN mustNotContain TEXT''')
    conn.commit()
    print("Columns added successfully!")
except sqlite3.OperationalError as e:
    print(f"Error adding columns: {e}")

conn.close()
morpheus65535 commented 6 months ago

Something failed during database migration from a version older than 1.3.0. Those column should have been created automatically.

originalFormat should be an Integer. mustNotContain is fine.

Thanks for reporting. If we get other reports, I'll create a fix for that.