Add UserRole model with 1:1 relationship to User#26
Open
Conversation
Co-authored-by: karastoyanov <86146020+karastoyanov@users.noreply.github.com>
Co-authored-by: karastoyanov <86146020+karastoyanov@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add user model for application
Add UserRole model with 1:1 relationship to User
Jan 30, 2026
added 2 commits
January 31, 2026 00:13
- added class model UserRoles with 1-to-1 relationship with User - new users get User role by default - added pytest tests Signed-off-by: Aleksandar Karastoyanov <a.karastoyanov@utp.bg>
…killforge into copilot/add-user-model Signed-off-by: Aleksandar Karastoyanov <a.karastoyanov@utp.bg>
karastoyanov
approved these changes
Jan 30, 2026
4 tasks
karastoyanov
approved these changes
Jan 31, 2026
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.
Implements role-based access control foundation by adding a
UserRolemodel with a 1:1 relationship toUser. The problem statement showed a type mismatch (db.Integerforeign key againstdb.String(36)primary key) which would fail at runtime.Changes
Created
UserRolemodel following theUserStatspattern:db.String(36)for primary key and foreign key (matches User.id UUID type)Updated
Usermodel:rolerelationship withuselist=Falsefor 1:1 semanticsAdded test coverage for creation, relationship bidirectionality, cascade delete, defaults, and type validation
Implementation
Access pattern:
user.role.rolereturns the role string;user_role.userreturns the User instance.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.