Error during database upgrade

OS: Fedora release 24

Tx for any help.

18:46:27 INFO::CORE::Performing disk space checks
18:46:27 INFO::CORE::Performing integrity check on config database
18:46:27 INFO::CORE::Performing upgrades on config database
18:46:27 INFO::CORE::Performing initialization on config database
18:46:27 INFO::CORE::Performing migrations on config database
18:46:27 INFO::CORE::Performing cleanup on config database
18:46:27 INFO::CORE::Performing vacuum on config database
18:46:27 INFO::CORE::Performing integrity check on main database
18:46:27 INFO::CORE::Performing upgrades on main database
18:46:27 INFO::CORE::Backing up main database
18:46:27 INFO::CORE::Backing up main database table alembic_version schema
18:46:27 INFO::CORE::Backing up main database table blacklist schema
18:46:27 INFO::CORE::Backing up main database table failed_snatch_history schema
18:46:27 INFO::CORE::Backing up main database table failed_snatches schema
18:46:27 INFO::CORE::Backing up main database table history schema
18:46:27 INFO::CORE::Backing up main database table imdb_info schema
18:46:27 INFO::CORE::Backing up main database table tv_shows schema
18:46:27 INFO::CORE::Backing up main database table indexer_mapping schema
18:46:27 INFO::CORE::Backing up main database table tv_episodes schema
18:46:28 INFO::CORE::Backing up main database table whitelist schema
18:46:28 INFO::CORE::Upgrading main database to v21
Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py”, line 1278, in _execute_context
cursor, statement, parameters, context
File “/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/default.py”, line 593, in do_execute
cursor.execute(statement, parameters)
sqlite3.OperationalError: near “indexer_id”: syntax error

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “/root/sickrage/sickrage/init.py”, line 401, in main
app.start()
File “/root/sickrage/sickrage/core/init.py”, line 316, in start
db.upgrade()
File “/root/sickrage/sickrage/core/databases/init.py”, line 193, in upgrade
alembic.command.upgrade(self.get_alembic_config(), ‘head’)
File “/root/.local/lib/python3.7/site-packages/alembic/command.py”, line 298, in upgrade
script.run_env()
File “/root/.local/lib/python3.7/site-packages/alembic/script/base.py”, line 489, in run_env
util.load_python_file(self.dir, “env.py”)
File “/root/.local/lib/python3.7/site-packages/alembic/util/pyfiles.py”, line 98, in load_python_file
module = load_module_py(module_id, path)
File “/root/.local/lib/python3.7/site-packages/alembic/util/compat.py”, line 184, in load_module_py
spec.loader.exec_module(module)
File “”, line 728, in exec_module
File “”, line 219, in _call_with_frames_removed
File “/root/sickrage/sickrage/core/databases/main/migrations/env.py”, line 77, in
run_migrations_online()
File “/root/sickrage/sickrage/core/databases/main/migrations/env.py”, line 71, in run_migrations_online
context.run_migrations()
File “”, line 8, in run_migrations
File “/root/.local/lib/python3.7/site-packages/alembic/runtime/environment.py”, line 846, in run_migrations
self.get_context().run_migrations(**kw)
File “/root/.local/lib/python3.7/site-packages/alembic/runtime/migration.py”, line 520, in run_migrations
step.migration_fn(**kw)
File “/root/sickrage/sickrage/core/databases/main/migrations/versions/021_Upgrade_To_SiCKRAGE_v10.py”, line 54, in upgrade
op.alter_column(‘tv_shows’, ‘indexer_id’, new_column_name=‘series_id’)
File “”, line 8, in alter_column
File “”, line 3, in alter_column
File “/root/.local/lib/python3.7/site-packages/alembic/operations/ops.py”, line 1779, in alter_column
return operations.invoke(alt)
File “/root/.local/lib/python3.7/site-packages/alembic/operations/base.py”, line 374, in invoke
return fn(self, operation)
File “/root/.local/lib/python3.7/site-packages/alembic/operations/toimpl.py”, line 56, in alter_column
**operation.kw
File “/root/.local/lib/python3.7/site-packages/alembic/ddl/impl.py”, line 232, in alter_column
existing_nullable=existing_nullable,
File “/root/.local/lib/python3.7/site-packages/alembic/ddl/impl.py”, line 140, in _exec
return conn.execute(construct, *multiparams, **params)
File “/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py”, line 1014, in execute
return meth(self, multiparams, params)
File “/usr/local/lib/python3.7/site-packages/sqlalchemy/sql/ddl.py”, line 72, in _execute_on_connection
return connection._execute_ddl(self, multiparams, params)
File “/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py”, line 1076, in _execute_ddl
compiled,
File “/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py”, line 1318, in execute_context
e, statement, parameters, cursor, context
File “/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py”, line 1512, in handle_dbapi_exception
sqlalchemy_exception, with_traceback=exc_info[2], from
=e
File “/usr/local/lib/python3.7/site-packages/sqlalchemy/util/compat.py”, line 178, in raise

raise exception
File “/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py”, line 1278, in _execute_context
cursor, statement, parameters, context
File “/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/default.py”, line 593, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) near “indexer_id”: syntax error
[SQL: ALTER TABLE tv_shows RENAME indexer_id TO series_id]
(Background on this error at: http://sqlalche.me/e/13/e3q8)
Sentry is attempting to send 0 pending error messages
Waiting up to 2 seconds
Press Ctrl-C to quit

Can you please email me the backup it made prior to this database v21 upgrade, it’ll be in your SR data folder and be called main_db_backup_{timestamp}.json

You can email it to [email protected] please

It’s in your mailbox.
Tx for the reply.

received, working on this now, will reply back once done.

thanks!

I just restored the database and upgraded it to v21 without any issue, all I did was renamed the file to main_db_backup.json and placed it in a folder called restore inside my SR data folder, then started up SR and let it perform the required restore and migration operations.

what operating system are you attempting this on ?

I’m on Fedora 24. Pretty old, I know. But as long as I have no reason to upgrade…

Try the steps I outlined above and let me know if that works or not please?

The restore was succesful. Restore folder was removed. But when the upgrade starts I get the same error.

what version of python is installed ?

$ /usr/local/bin/python3.7 --version
Python 3.7.3

latest version of SR ? should be 10.0.7

version.txt in sickrage folder says 10.0.2

I upgraded manually to 10.0.7. But the same error remains. I also tried the restore steps.

Suppose I install a new Fedora instance on the latest release, can I use the above procedure to restore my current SR DB on a fresh SR install?

Yes, that would work just fine.

Just finished it on a brand new Fedora 33 installation. Restore was OK, upgrade worked this time. Something on my Fedora 24 is too old I guess.
Do I have to restore the config.db too? I seem to be missing some configuration.
Or rather, what would be the full procedure to migrate an existing SR installation to another host?

Shutdown SR, copy your old config.ini to the data folder, start SR, config migration should happen automatically

Thanks a lot! I’m going to try to upgrade the old host first. I have other packages running there. If that fails, I’ll migrate everything to the new host.

FYI.
I just went through a long process of Fedora upgrades. The issue disappeared as of Fedora 30. All versions between Fedora 24 and 29 had the issue.
Not sure what causes it. It’s definitely not python, because I’m still using the locally installed 3.7 version, not the OS supplied one. Maybe sqlite?

Anyway, SR works again and I have finally upgraded the OS on one of my virtuals. So I’m happy. Corona lockdown without SR is unthinkable ;-).

Yeah, I am not sure how it would be OS related unless the OS version it self held back a version that resolved a bug, but glad to hear things are back to working order, stay safe and thanks!