Skip to content

[Bug]: Version migrations should handle exceptions #1428

Description

@mm12

Checklist

  • I am using an up-to-date version.
  • I have read the documentation.
  • I have searched existing issues.

TagStudio Version

Alpha 9.6.0

Operating System & Version

Win11

Description

When migrations for versions are ran, they should take into account the possibility that the migration was already ran but the database version wasn't updated properly.
For example, drop table preferences may fail, because the table preferences no longer exists. In that case, since the table is already dropped, there is no reason to fail, and the program can simply continue.

Expected Behavior

TagStudio should catch errors with migrations and handle them, rather than aborting. Users can potentially be locked out of their libraries unless they are comfortable modifying the SQL database directly, which may also leave them in a different type of broken state.

Steps to Reproduce

To reproduce this naturally is difficult but can happen in a variety of circumstances. To artificially reproduce this issue:

  1. Open a library in the latest version and close tagstudio
  2. Edit the sql database to revert the current version table down to a previous number (ie, from 201 to 103)
  3. Open tagstudio and attempt to load the library

Logs

Logs did not catch any errors that occurred.

Log
2026-07-04 19:57:36 [info     ] [FFmpeg] Using FFprobe location: ffprobe (Found)
2026-07-04 19:57:36 [info     ] [FFmpeg] Using FFmpeg location: ffmpeg (Found)
2026-07-04 19:57:37 [info     ] [ResourceManager] Resources Registered: count=37
2026-07-04 19:57:37 [info     ] [Settings] Global Settings File Path not specified, using default
2026-07-04 19:57:37 [info     ] [Settings] Reading Global Settings File path=WindowsPath('C:/Users/USER/Appdata/Roaming/TagStudio/settings.toml')
2026-07-04 19:57:37 [info     ] [Cache] Cache File not specified, using default one filename=C:/Users/USER/AppData/Roaming/TagStudio/TagStudio.ini
2026-07-04 19:57:39 [error    ] Path does not exist.           open_path=None
2026-07-04 19:57:39 [info     ] [Library] Opening SQLite Library connection_string=sqlite:///D:\Files\MemesByDate\.TagStudio\ts_library.sqlite library_dir=WindowsPath('D:/Files/MemesByDate')
2026-07-04 19:57:42 [info     ] [Config] Thumbnail Cache Size: 500 MB
2026-07-04 19:58:26 [info     ] No Library to Close
2026-07-04 19:58:26 [info     ] [SHUTDOWN] Ending Thumbnail Threads...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugSomething isn't working as intended

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions