From 83bc1f5865ff9df88810a3cbdf9fee4535cca039 Mon Sep 17 00:00:00 2001 From: CCS Admin Date: Mon, 2 Mar 2026 08:30:08 +0000 Subject: [PATCH] fix: make index names unique across tables for PostgreSQL compatibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PostgreSQL requires globally unique index names (unlike MySQL which scopes them per table). Prefix generic names: idx_user→idx_al_user/idx_rt_user, idx_token→idx_rt_token, idx_case/idx_code/idx_haupt→idx_icd_*. Co-Authored-By: Claude Opus 4.6 --- backend/app/models/audit.py | 6 +++--- backend/app/models/case.py | 6 +++--- backend/app/models/user.py | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/backend/app/models/audit.py b/backend/app/models/audit.py index 4b7e90f..7790336 100644 --- a/backend/app/models/audit.py +++ b/backend/app/models/audit.py @@ -81,9 +81,9 @@ class AuditLog(Base): user: Mapped[Optional["User"]] = relationship(foreign_keys=[user_id]) __table_args__ = ( - Index("idx_user", "user_id"), - Index("idx_entity", "entity_type", "entity_id"), - Index("idx_created", "created_at"), + Index("idx_al_user", "user_id"), + Index("idx_al_entity", "entity_type", "entity_id"), + Index("idx_al_created", "created_at"), ) diff --git a/backend/app/models/case.py b/backend/app/models/case.py index 6e9f5d3..aeb7350 100644 --- a/backend/app/models/case.py +++ b/backend/app/models/case.py @@ -190,7 +190,7 @@ class CaseICDCode(Base): case: Mapped[Case] = relationship(back_populates="icd_codes") __table_args__ = ( - Index("idx_case", "case_id"), - Index("idx_code", "icd_code"), - Index("idx_haupt", "icd_hauptgruppe"), + Index("idx_icd_case", "case_id"), + Index("idx_icd_code", "icd_code"), + Index("idx_icd_haupt", "icd_hauptgruppe"), ) diff --git a/backend/app/models/user.py b/backend/app/models/user.py index 4ea0609..15910ba 100644 --- a/backend/app/models/user.py +++ b/backend/app/models/user.py @@ -102,8 +102,8 @@ class RefreshToken(Base): user: Mapped[User] = relationship(back_populates="refresh_tokens") __table_args__ = ( - Index("idx_user", "user_id"), - Index("idx_token", "token_hash"), + Index("idx_rt_user", "user_id"), + Index("idx_rt_token", "token_hash"), )