From 5c207e879dacc331047bcc21e9c5951983b20db7 Mon Sep 17 00:00:00 2001 From: Jann Stute Date: Thu, 3 Sep 2026 20:08:12 +0200 Subject: [PATCH] refactor: sqlalchemy-independence for the DB 100 migration --- src/tagstudio/core/library/alchemy/migrations.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/tagstudio/core/library/alchemy/migrations.py b/src/tagstudio/core/library/alchemy/migrations.py index be5ae9c0..8d4b1cd1 100644 --- a/src/tagstudio/core/library/alchemy/migrations.py +++ b/src/tagstudio/core/library/alchemy/migrations.py @@ -264,15 +264,10 @@ class MigrationTo100(DBMigration): @override @classmethod - def run(cls, session: Session, library_dir: Path, fmt_log: LoggingMethod): + def run(cls, conn: Connection, library_dir: Path, fmt_log: LoggingMethod): """Migrate DB to DB_VERSION 100.""" # Repair parent-child tag relationships that are the wrong way around. - stmt = update(TagParent).values( - parent_id=TagParent.child_id, - child_id=TagParent.parent_id, - ) - session.execute(stmt) - session.flush() + conn.execute("UPDATE tag_parents SET parent_id = child_id, child_id = parent_id") logger.info(fmt_log("Refactored TagParent table"))