fix(db): make migrations and glossary index SQLite-compatible
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 2m57s
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 2m57s
This commit is contained in:
@@ -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("""
|
||||
|
||||
Reference in New Issue
Block a user