-
-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: open libraries from v9.5.0-pr1 in newer versions (#815)
* ui: show more informative library error messages * tests: add sqlite db migration tests * tests: fix and refactor migration tests * fix: apply db8 schema changes before repairing db6 * docs: add save file format change log * chore: remove db version explanations from docstrings
- Loading branch information
Showing
8 changed files
with
119 additions
and
21 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Save Format Changes | ||
|
||
This page outlines the various changes made the TagStudio save file format over time, sometimes referred to as the "database" or "database file". | ||
|
||
## JSON | ||
|
||
| First Used | Last Used | Format | Location | | ||
| ---------- | ----------------------------------------------------------------------- | ------ | --------------------------------------------- | | ||
| v1.0.0 | [v9.4.2](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.4.2) | JSON | `<Library Folder>`/.TagStudio/ts_library.json | | ||
|
||
The legacy database format for public TagStudio releases [v9.1](https://github.com/TagStudioDev/TagStudio/tree/Alpha-v9.1) through [v9.4.2](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.4.2). Variations of this format had been used privately since v1.0.0. | ||
|
||
Replaced by the new SQLite format introduced in TagStudio [v9.5.0 Pre-Release 1](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.5.0-pr1). | ||
|
||
## DB_VERSION 6 | ||
|
||
| First Used | Last Used | Format | Location | | ||
| ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------ | ----------------------------------------------- | | ||
| [v9.5.0-PR1](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.5.0-pr1) | [v9.5.0-PR1](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.5.0-pr1) | SQLite | `<Library Folder>`/.TagStudio/ts_library.sqlite | | ||
|
||
The first public version of the SQLite save file format. | ||
|
||
Migration from the legacy JSON format is provided via a walkthrough when opening a legacy library in TagStudio [v9.5.0 Pre-Release 1](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.5.0-pr1) or later. | ||
|
||
## DB_VERSION 7 | ||
|
||
| First Used | Last Used | Format | Location | | ||
| ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------ | ----------------------------------------------- | | ||
| [v9.5.0-PR2](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.5.0-pr2) | [v9.5.0-PR3](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.5.0-pr3) | SQLite | `<Library Folder>`/.TagStudio/ts_library.sqlite | | ||
|
||
### Changes | ||
|
||
- Repairs "Description" fields to use a TEXT_LINE key instead of a TEXT_BOX key. | ||
- Repairs tags that may have a disambiguation_id pointing towards a deleted tag. | ||
|
||
## DB_VERSION 8 | ||
|
||
| First Used | Last Used | Format | Location | | ||
| ------------------------------------------------------------------------------- | --------- | ------ | ----------------------------------------------- | | ||
| [v9.5.0-PR4](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.5.0-pr4) | _Current_ | SQLite | `<Library Folder>`/.TagStudio/ts_library.sqlite | | ||
|
||
### Changes | ||
|
||
- Adds the `color_border` column to `tag_colors` table. Used for instructing the [secondary color](../library/tag_color.md#secondary-color) to apply to a tag's border as a new optional behavior. | ||
- Adds three new default colors: "Burgundy (TagStudio Shades)", "Dark Teal (TagStudio Shades)", and "Dark Lavender (TagStudio Shades)". | ||
- Updates Neon colors to use the the new `color_border` property. |
This file contains 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
This file contains 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
This file contains 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
Binary file added
BIN
+96 KB
tagstudio/tests/fixtures/empty_libraries/DB_VERSION_6/.TagStudio/ts_library.sqlite
Binary file not shown.
Binary file added
BIN
+96 KB
tagstudio/tests/fixtures/empty_libraries/DB_VERSION_7/.TagStudio/ts_library.sqlite
Binary file not shown.
Binary file added
BIN
+96 KB
tagstudio/tests/fixtures/empty_libraries/DB_VERSION_8/.TagStudio/ts_library.sqlite
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Copyright (C) 2025 Travis Abendshien (CyanVoxel). | ||
# Licensed under the GPL-3.0 License. | ||
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio | ||
|
||
import shutil | ||
from pathlib import Path | ||
|
||
import pytest | ||
from src.core.constants import TS_FOLDER_NAME | ||
from src.core.library.alchemy.library import Library | ||
|
||
CWD = Path(__file__) | ||
FIXTURES = "fixtures" | ||
EMPTY_LIBRARIES = "empty_libraries" | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"path", | ||
[ | ||
str(Path(CWD.parent / FIXTURES / EMPTY_LIBRARIES / "DB_VERSION_6")), | ||
str(Path(CWD.parent / FIXTURES / EMPTY_LIBRARIES / "DB_VERSION_7")), | ||
str(Path(CWD.parent / FIXTURES / EMPTY_LIBRARIES / "DB_VERSION_8")), | ||
], | ||
) | ||
def test_library_migrations(path: str): | ||
library = Library() | ||
|
||
# Copy libraries to temp dir so modifications don't show up in version control | ||
original_path = Path(path) | ||
temp_path = Path(CWD.parent / FIXTURES / EMPTY_LIBRARIES / "DB_VERSION_TEMP") | ||
temp_path.mkdir(exist_ok=True) | ||
temp_path_ts = temp_path / TS_FOLDER_NAME | ||
temp_path_ts.mkdir(exist_ok=True) | ||
shutil.copy( | ||
original_path / TS_FOLDER_NAME / Library.SQL_FILENAME, | ||
temp_path / TS_FOLDER_NAME / Library.SQL_FILENAME, | ||
) | ||
|
||
try: | ||
status = library.open_library(library_dir=temp_path) | ||
library.close() | ||
shutil.rmtree(temp_path) | ||
assert status.success | ||
except Exception as e: | ||
library.close() | ||
shutil.rmtree(temp_path) | ||
raise (e) |