Repository navigation
Open
Labels
status:ideaProposed feature, discuss if its usefulProposed feature, discuss if its usefultype:enhancementImprovement of an existing functionImprovement of an existing function
Description
The problem
As reported in #1761 and multiple previous issues sometimes database migrations seem to be only half way done. This leads to consequent error messages like
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/vorta/__main__.py", line 66, in main
init_db(sqlite_db)
File "/usr/lib/python3/dist-packages/vorta/store/connection.py", line 83, in init_db
run_migrations(current_schema, con)
File "/usr/lib/python3/dist-packages/vorta/store/migrations.py", line 190, in run_migrations
_apply_schema_update(
File "/usr/lib/python3/dist-packages/vorta/store/migrations.py", line 225, in _apply_schema_update
migrate(*operations)
File "/usr/lib/python3/dist-packages/playhouse/migrate.py", line 886, in migrate
operation.run()
File "/usr/lib/python3/dist-packages/peewee.py", line 3177, in execute_sql
cursor.execute(sql, params or ())
sqlite3.OperationalError: duplicate column name: schedule_interval_unitRequested Solution
Instead of failing vorta could only do those migrations actually needed by comparing the state of the database with the expected state. This will also help when testing PRs that add db migrations.
However this isn't straightforward at all as far as I can tell at the moment. These are possible roadblockers:
- peewee doesn't provide such features and their might not be a viable third party library we can use together with peewee.
- We sometimes have special data altering migrations steps like the following and I don't know how those could be implemented with the approach requested in this FR.
vorta/src/vorta/store/migrations.py
Lines 99 to 106 in 567a354
if current_schema.version < 11: _apply_schema_update(current_schema, 11) for profile in BackupProfileModel: if profile.compression == 'zstd': profile.compression = 'zstd,3' if profile.compression == 'lzma,6': profile.compression = 'auto,lzma,6' profile.save()
Alternatives
- Catch error and ignore it.
- Find cause of incomplete migrations.
Metadata
Metadata
Assignees
Labels
status:ideaProposed feature, discuss if its usefulProposed feature, discuss if its usefultype:enhancementImprovement of an existing functionImprovement of an existing function
Activity
lapineige commentedon Jan 9, 2025
I'm affected by this issue. That would be a nice improvement :)