Skip to content

Refactor: SLM has two conflicting users tables — Integer PK vs UUID PK #1900

@mrveiss

Description

@mrveiss

Problem

SLM has two User models both using __tablename__ = "users":

  1. Main SLM (models/database.py:198):

    id = Column(Integer, primary_key=True, autoincrement=True)
  2. User Management (user_management/models/user.py:48):

    id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), ...)

They use different SQLAlchemy Base classes, so SQLAlchemy doesn't detect the conflict at model definition time. But when both create tables on the same database, the Integer PK users table gets created first, and then user_mfa tries to FK to it with UUID — causing a DatatypeMismatchError.

Current Workaround

Separate slm_users database for user_management (PR #1886, Docker fix).

Root Cause Fix Options

  1. Consolidate — Merge both into one User model with UUID PK, migrate main SLM references
  2. Rename — Change main SLM table to slm_admins to avoid collision
  3. Keep separate DBs — Accept the dual-database design as intentional architecture

Discovered During

Working on #1809 (Docker containerization) — root cause of #1854

Impact

Medium — Currently masked by separate databases. Will bite again if someone connects both models to the same DB.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions