Skip to content

Commit 71d0425

Browse files
authored
fix: properly delete tag_parents row when deleting tag (#1107)
1 parent b216490 commit 71d0425

File tree

4 files changed

+90
-62
lines changed

4 files changed

+90
-62
lines changed

docs/updates/schema_changes.md

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ Legacy (JSON) library save format versions were tied to the release version of t
1414

1515
### Versions 1.0.0 - 9.4.2
1616

17-
| Used From | Used Until | Format | Location |
18-
| --------- | ----------------------------------------------------------------------- | ------ | --------------------------------------------- |
19-
| v1.0.0 | [v9.4.2](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.4.2) | JSON | `<Library Folder>`/.TagStudio/ts_library.json |
17+
| Used From | Format | Location |
18+
| --------- | ------ | --------------------------------------------- |
19+
| v1.0.0 | JSON | `<Library Folder>`/.TagStudio/ts_library.json |
2020

2121
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.
2222

@@ -48,9 +48,9 @@ These versions were used while developing the new SQLite file format, outside an
4848

4949
### Version 6
5050

51-
| Used From | Used Until | Format | Location |
52-
| ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------ | ----------------------------------------------- |
53-
| [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 |
51+
| Used From | Format | Location |
52+
| ------------------------------------------------------------------------------- | ------ | ----------------------------------------------- |
53+
| [v9.5.0-pr1](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.5.0-pr1) | SQLite | `<Library Folder>`/.TagStudio/ts_library.sqlite |
5454

5555
The first public version of the SQLite save file format.
5656

@@ -60,9 +60,9 @@ Migration from the legacy JSON format is provided via a walkthrough when opening
6060

6161
### Version 7
6262

63-
| Used From | Used Until | Format | Location |
64-
| ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------ | ----------------------------------------------- |
65-
| [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 |
63+
| Used From | Format | Location |
64+
| ------------------------------------------------------------------------------- | ------ | ----------------------------------------------- |
65+
| [v9.5.0-pr2](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.5.0-pr2) | SQLite | `<Library Folder>`/.TagStudio/ts_library.sqlite |
6666

6767
- Repairs "Description" fields to use a TEXT_LINE key instead of a TEXT_BOX key.
6868
- Repairs tags that may have a disambiguation_id pointing towards a deleted tag.
@@ -71,9 +71,9 @@ Migration from the legacy JSON format is provided via a walkthrough when opening
7171

7272
### Version 8
7373

74-
| Used From | Used Until | Format | Location |
75-
| ------------------------------------------------------------------------------- | ----------------------------------------------------------------------- | ------ | ----------------------------------------------- |
76-
| [v9.5.0-pr4](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.5.0-pr4) | [v9.5.1](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.5.1) | SQLite | `<Library Folder>`/.TagStudio/ts_library.sqlite |
74+
| Used From | Format | Location |
75+
| ------------------------------------------------------------------------------- | ------ | ----------------------------------------------- |
76+
| [v9.5.0-pr4](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.5.0-pr4) | SQLite | `<Library Folder>`/.TagStudio/ts_library.sqlite |
7777

7878
- Adds the `color_border` column to the `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.
7979
- Adds three new default colors: "Burgundy (TagStudio Shades)", "Dark Teal (TagStudio Shades)", and "Dark Lavender (TagStudio Shades)".
@@ -83,30 +83,30 @@ Migration from the legacy JSON format is provided via a walkthrough when opening
8383

8484
### Version 9
8585

86-
| Used From | Used Until | Format | Location |
87-
| ----------------------------------------------------------------------- | ----------------------------------------------------------------------- | ------ | ----------------------------------------------- |
88-
| [v9.5.2](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.5.2) | [v9.5.3](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.5.3) | SQLite | `<Library Folder>`/.TagStudio/ts_library.sqlite |
86+
| Used From | Format | Location |
87+
| ----------------------------------------------------------------------- | ------ | ----------------------------------------------- |
88+
| [v9.5.2](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.5.2) | SQLite | `<Library Folder>`/.TagStudio/ts_library.sqlite |
8989

9090
- Adds the `filename` column to the `entries` table. Used for sorting entries by filename in search results.
9191

9292
---
9393

9494
### Version 100
9595

96-
| Used From | Used Until | Format | Location |
97-
| ---------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- | ------ | ----------------------------------------------- |
98-
| [74383e3](https://github.com/TagStudioDev/TagStudio/commit/74383e3c3c12f72be1481ab0b86c7360b95c2d85) | [v9.5.4](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.5.4) | SQLite | `<Library Folder>`/.TagStudio/ts_library.sqlite |
96+
| Used From | Format | Location |
97+
| ---------------------------------------------------------------------------------------------------- | ------ | ----------------------------------------------- |
98+
| [74383e3](https://github.com/TagStudioDev/TagStudio/commit/74383e3c3c12f72be1481ab0b86c7360b95c2d85) | SQLite | `<Library Folder>`/.TagStudio/ts_library.sqlite |
9999

100100
- Introduces built-in minor versioning
101101
- The version number divided by 100 (and floored) constitutes the **major** version. Major version indicate breaking changes that prevent libraries from being opened in TagStudio versions older than the ones they were created in.
102102
- Values more precise than this ("ones" through "tens" columns) constitute the **minor** version. These indicate minor changes that don't prevent a newer library from being opened in an older version of TagStudio, as long as the major version is not also increased.
103-
- Swaps `parent_id` and `child_id` values in the `tag_parents` table, which have erroneously been flipped since the first SQLite DB version.
103+
- Swaps `parent_id` and `child_id` values in the `tag_parents` table
104104

105105
#### Version 101
106106

107-
| Used From | Used Until | Format | Location |
108-
| ----------------------------------------------------------------------- | ---------- | ------ | ----------------------------------------------- |
109-
| [v9.5.4](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.5.4) | _Current_ | SQLite | `<Library Folder>`/.TagStudio/ts_library.sqlite |
107+
| Used From | Format | Location |
108+
| ----------------------------------------------------------------------- | ------ | ----------------------------------------------- |
109+
| [v9.5.4](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.5.4) | SQLite | `<Library Folder>`/.TagStudio/ts_library.sqlite |
110110

111111
- Deprecates the `preferences` table, set to be removed in a future TagStudio version.
112112
- Introduces the `versions` table
@@ -115,3 +115,11 @@ Migration from the legacy JSON format is provided via a walkthrough when opening
115115
- `'INITIAL'` stores the database version number in which in was created
116116
- Pre-existing databases set this number to `100`
117117
- `'CURRENT'` stores the current database version number
118+
119+
#### Version 102
120+
121+
| Used From | Format | Location |
122+
| ----------------------------------------------------------------------- | ------ | ----------------------------------------------- |
123+
| [v9.5.4](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.5.4) | SQLite | `<Library Folder>`/.TagStudio/ts_library.sqlite |
124+
125+
- Applies repairs to the `tag_parents` table created in [version 100](#version-100), removing rows that reference tags that have been deleted.

src/tagstudio/core/library/alchemy/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
DB_VERSION_LEGACY_KEY: str = "DB_VERSION"
1212
DB_VERSION_CURRENT_KEY: str = "CURRENT"
1313
DB_VERSION_INITIAL_KEY: str = "INITIAL"
14-
DB_VERSION: int = 101
14+
DB_VERSION: int = 102
1515

1616
TAG_CHILDREN_QUERY = text("""
1717
WITH RECURSIVE ChildTags AS (

0 commit comments

Comments
 (0)