refactor: sqlalchemy-independence for the DB 102 migration

This commit is contained in:
Jann Stute
2026-09-03 20:14:04 +02:00
parent eed336b8fe
commit 4496754f49
@@ -297,12 +297,16 @@ class MigrationTo102(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 102."""
# delete TagParents with a dangling parent reference
stmt = delete(TagParent).where(TagParent.parent_id.not_in(select(Tag.id).distinct()))
session.execute(stmt)
session.flush()
conn.execute("""
DELETE FROM tag_parents
WHERE NOT parent_id IN (
SELECT id
FROM tags
)
""")
logger.info(fmt_log("Verified TagParent table data"))