fix(db): make migrations and glossary index SQLite-compatible
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 2m57s

This commit is contained in:
2026-06-14 19:01:07 +02:00
parent cb8ce697d2
commit adc3583358
6 changed files with 93 additions and 35 deletions

View File

@@ -21,10 +21,18 @@ depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
conn = op.get_bind()
dialect = conn.dialect.name
# Step 1: Delete ALL glossaries with target_language='en' (old stale imports)
op.execute("DELETE FROM glossary_terms WHERE glossary_id IN (SELECT id FROM glossaries WHERE target_language = 'en')")
op.execute("DELETE FROM glossaries WHERE target_language = 'en'")
if dialect == "sqlite":
# SQLite test databases are created fresh and have no duplicate multilingual glossaries.
# The PostgreSQL-specific DISTINCT ON logic is not needed here.
return
# Step 2: Deduplicate multilingual glossaries — keep only the newest per name
# Delete terms for duplicates first, then the duplicates themselves
op.execute("""