Repository navigation
Skip migration steps that add an already existing column - #2587
Merged
Merged
Conversation
Vorta failed to start with "duplicate column name" when a schema migration tried to add a column that the database already had while its schema version was older, e.g. after an earlier migration was only partly applied. The user then had to repair settings.db by hand. _apply_schema_update() now runs the operations one by one and skips add_column operations whose column already exists, logging a warning. The schema version is still bumped, so the remaining migrations run as usual. This applies to all existing and future migrations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
m3nu
approved these changes
Nov 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
_apply_schema_update()now runs the migration operations one by one and skipsadd_columnoperations whose column already exists in the table (checked withget_columns()), logging a warning. The schema version is still bumped, so the remaining migrations run as usual. Because the check lives in_apply_schema_update(), it covers all existing and future migrations without changing them.The check works with peewee 3 (
Operation.methodholds the method name; uv.lock has 3.18.3, distros ship 3.x) and peewee 4 (Operation.fnholds the function; what an unpinnedpip installgets today).Only
add_columnis handled, since every reported failure is a "duplicate column name". The other non-additive steps were left alone:rename_column/drop_columnonly exist in the v7 migration, re-runningdrop_not_nullis already harmless, and the data migrations at v11/v13 are already safe to repeat. Existing columns are not backfilled, asapply_defaultwould overwrite existing values.Related Issue
Fixes #2275
Related to #1797
The same crash was reported before for other columns in #936 (
dir_size), #1117 (schedule_interval_unit), #1761 and #2253 (group), which were closed without a general fix.Motivation and Context
When
settings.dbalready contains a column of a newer schema while its schema version is older (e.g. after a partly applied migration), Vorta crashes on startup withsqlite3.OperationalError: duplicate column name: ...and users have to repair the database by hand. With this change, Vorta skips the redundant step and finishes the migration.How Has This Been Tested?
tests/unit/test_migrations.py: builds a database at schema version 19 that already hassettingsmodel.tooltip(from version 20) and lacks the v21–v23 columns, runsrun_migrations(), and checks that it reachesSCHEMA_VERSIONwith all columns present. Without the fix, it fails withduplicate column name: tooltip.test_settings_store.pyandtest_profile.py(Python 3.12, PyQt6 6.10.1,QT_QPA_PLATFORM=offscreen). I could only run part of the suite locally because I'm on Windows without Borg, so I'm relying on CI for the full run.ruff check,ruff format --checkandmypy src/vorta/store/ src/vorta/network_status/pass.Types of changes
Checklist:
I used Claude Code to help write this change and its test. I reviewed and tested it myself and can answer questions about it.
I provide my contribution under the terms of the license of this repository and I affirm the Developer Certificate of Origin.
🤖 Generated with Claude Code