Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
70f1a3d
refactor: sqlalchemy-independence for _get_version
Computerdores Aug 28, 2026
e2b54ef
refactor: sqlalchemy-independence for _set_version
Computerdores Aug 28, 2026
27bd162
refactor: remove engine; breaks migrations until individual refactor
Computerdores Aug 28, 2026
50fded8
refactor: sqlalchemy-independence for the DB 7 migration
Computerdores Sep 3, 2026
df75731
refactor: sqlalchemy-independence for the DB 8 migration
Computerdores Sep 3, 2026
5a447a5
refactor: sqlalchemy-independence for the DB 9 migration
Computerdores Sep 3, 2026
5c207e8
refactor: sqlalchemy-independence for the DB 100 migration
Computerdores Sep 3, 2026
eed336b
refactor: sqlalchemy-independence for the DB 101 migration
Computerdores Sep 3, 2026
4496754
refactor: sqlalchemy-independence for the DB 102 migration
Computerdores Sep 3, 2026
98ae38f
refactor: sqlalchemy-independence for the DB 103 migration
Computerdores Sep 3, 2026
549f036
refactor: sqlalchemy-independence for the DB 104 migration
Computerdores Sep 3, 2026
c29a3a7
refactor: sqlalchemy-independence for the DB 200 migration
Computerdores Sep 3, 2026
890f1be
refactor: sqlalchemy-independence for the DB 201 migration
Computerdores Sep 3, 2026
83797bc
refactor: sqlalchemy-independence for the DB 202 migration
Computerdores Sep 3, 2026
cc84df0
refactor: sqlalchemy-independence for the DB 300 migration
Computerdores Sep 3, 2026
93c460d
refactor: sqlalchemy-independence for the DB 400 migration
Computerdores Sep 3, 2026
9e11b86
refactor: use executemany instead of loop in DB 8 migration
Computerdores Sep 3, 2026
2cdf6c3
refactor: use multiline strings consistenly
Computerdores Sep 3, 2026
0848d7c
fix: various small synatactic sql errors
Computerdores Sep 3, 2026
b11d4fe
refactor: introduce named placeholders and use executemany where it m…
Computerdores Sep 3, 2026
d9e4195
fix: make DBMigrations a context manager to correctly close connection
Computerdores Sep 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions src/tagstudio/core/library/alchemy/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,18 @@
""")


DEFAULT_FIELD_TEMPLATES = (
TextFieldTemplate(name="Title"),
TextFieldTemplate(name="Author"),
TextFieldTemplate(name="Artist"),
TextFieldTemplate(name="URL"),
TextFieldTemplate(name="Description", is_multiline=True),
TextFieldTemplate(name="Notes", is_multiline=True),
TextFieldTemplate(name="Comments", is_multiline=True),
DatetimeFieldTemplate(name="Date"),
DEFAULT_TEXT_FIELD_TEMPLATES = (
{"name": "Title", "is_multiline": False},
{"name": "Author", "is_multiline": False},
{"name": "Artist", "is_multiline": False},
{"name": "URL", "is_multiline": False},
{"name": "Description", "is_multiline": True},
{"name": "Notes", "is_multiline": True},
{"name": "Comments", "is_multiline": True},
)

DEFAULT_DATETIME_FIELD_TEMPLATES = ({"name": "Date"},)

DEFAULT_FIELD_TEMPLATES = [TextFieldTemplate(**p) for p in DEFAULT_TEXT_FIELD_TEMPLATES] + [
DatetimeFieldTemplate(**p) for p in DEFAULT_DATETIME_FIELD_TEMPLATES
]
17 changes: 8 additions & 9 deletions src/tagstudio/core/library/alchemy/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,20 +504,19 @@ def open_sqlite_library(
) -> LibraryStatus:
logger.info("[Library] Opening SQLite Library", library_dir=library_dir)

self.engine = self.__get_engine(library_dir, in_memory, sql_filename)

# migrate if necessary
try:
migrations = DBMigrations(library_dir, self.engine)

# save backup if patches will be applied
if migrations.required:
Library.save_library_backup_to_disk(library_dir)
with DBMigrations(library_dir, sql_filename) as migrations:
# save backup if patches will be applied
if migrations.required:
Library.save_library_backup_to_disk(library_dir)

migrations.run()
migrations.run()
except MigrationError as e:
return LibraryStatus(success=False, message=e.args[0])

# everything is fine, set the library path
# open up-to-date library
self.engine = self.__get_engine(library_dir, in_memory, sql_filename)
self.library_dir = library_dir
return LibraryStatus(success=True, library_path=library_dir)

Expand Down
Loading
Loading