[feature] Made RegisteredUser model support multi-tenancy #692#698
[feature] Made RegisteredUser model support multi-tenancy #692#698
Conversation
- Updated the RegisteredUser model to support organization-specific records. - Changed the primary key to UUID and added organization as a nullable ForeignKey. - Modified related code across the application to handle multiple registered users per organization. - Updated tests to reflect changes in the RegisteredUser model and ensure proper functionality. - Added migration scripts to handle the transition from the old model to the new schema. Closes #692
|
Caution Review failedAn error occurred during the review process. Please try again later. 📝 WalkthroughWalkthroughThis pull request refactors the Sequence Diagram(s)sequenceDiagram
autonumber
participant User
participant API as Authorization API
participant RegisteredUsers as RegisteredUser<br/>(multiple per org)
participant Org as Organization Context
rect rgba(100, 150, 200, 0.5)
Note over User,Org: Old Flow (One Global RegisteredUser)
User->>API: Request with org_id
API->>API: Check user.registered_user.is_verified
Note over API: Single global verification<br/>regardless of org
API->>User: Allow/Deny (global state)
end
rect rgba(150, 200, 100, 0.5)
Note over User,Org: New Flow (Org-Scoped RegisteredUsers)
User->>API: Request with org_id
API->>Org: Extract organization from request
API->>RegisteredUsers: Query registered_users.filter(organization=org_id)
RegisteredUsers->>RegisteredUsers: Return org-specific record<br/>or global (org_id=NULL)
RegisteredUsers->>API: is_verified, method for this org
API->>User: Allow/Deny (org-specific verification)
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~75 minutes ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
There was a problem hiding this comment.
SQLite cannot modify primary keys in place, so Django works around this by rebuilding the entire table when a PK or certain fields are altered. During your migration, the table rebuild temporarily ends up with both the old implicit PK and the new id column, which leads to the duplicate column name: id error. This typically happens when adding a new PK column and removing the old PK within the same schema transition. Splitting the operations into separate migrations avoids the conflict because each table rebuild sees a consistent schema.
Multiple Flake8 Violations and Test FailuresHello @pandafy,
|
Checklist
Reference to Existing Issue
Closes #692
Description of Changes