refactor(slm): consolidate User models to single UUID-PK (#1900)#1921
Merged
mrveiss merged 1 commit intoDev_new_guifrom Mar 16, 2026
Merged
refactor(slm): consolidate User models to single UUID-PK (#1900)#1921mrveiss merged 1 commit intoDev_new_guifrom
mrveiss merged 1 commit intoDev_new_guifrom
Conversation
Remove the legacy integer-PK User class from models/database.py and consolidate all auth onto the user_management UUID-PK User model. - Remove User class from models/database.py (was slm_users table) - Update services/auth.py to import from user_management.models.user - Update main.py _ensure_admin_user to use UserService - Update api/auth.py to use slm_users database session - Update models/schemas.py UserResponse for UUID compatibility - Add consolidate_slm_users_to_uuid migration to move legacy rows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Usermodels (integer PK vs UUID PK) into a single UUID-PK modelUserclass frommodels/database.py(wasslm_userstable)user_management.models.user.Usermodelslm_usersrows into UUIDuserstableFiles Changed
models/database.pyUserclass (19 lines)services/auth.pyuser_management.models.user;is_admin→is_platform_admin,last_login→last_login_atmain.py_ensure_admin_user()rewritten to useUserService+get_slm_session()api/auth.pyget_dbtoget_slm_dbfor user operationsmodels/schemas.pyUserResponse.idaccepts UUID; addedmodel_validateoverride for field mappingmigrations/consolidate_slm_users_to_uuid.pyslm_usersrows to UUIDuserstable, dropsslm_usersmigrations/runner.pyConsolidated User Model (UUID PK)
Single source:
user_management/models/user.pywith fields:id(UUID),email,username,password_hash,display_name,is_active,is_verified,mfa_enabled,is_platform_admin,preferences(JSONB),last_login_at,created_at,updated_at,deleted_atMigration Strategy
rename_users_to_slm_users(existing) — renames integer-PKusers→slm_usersconsolidate_slm_users_to_uuid(new) — readsslm_usersrows, inserts into UUIDuserstable, dropsslm_usersSafe to re-run. Fresh installs skip automatically (no
slm_userstable exists).Notes
slm_usersdatabase) remains as correct architecture — not a workaround/api/auth/login+/api/slm-auth/login) — dedup is a separate taskPOST /api/auth/usersshould be checked for integer-id assumptions (now returns UUID strings)Test plan
slm_userstable (fresh install)_ensure_admin_user()/api/auth/loginworks with consolidated modelUserResponseserializes UUID id correctlyCloses #1900