Skip to content

Draft: Add organization associations to User

Abdul Wadood requested to merge 407837-organization-have-many-users into master

What does this MR do and why?

Add owner_organization and organizations associations to User.

Add owned_users and users associations to Organization::Organization

How to set up and validate locally

  1. Run the migrations
  2. Associate an owner organization for a user by running:
    1. user = User.last
    2. user.owner_organization_id = 1
    3. user.save!
    4. user.reload.owner_organization.owned_users
  3. Add organization_user and test the associations:
    1. organization_user = Organizations::OrganizationUser.new(organization_id: 1, user_id: <user-id>)
    2. organization_user.save!
    3. Organizations::Organization.find(1).users
    4. User.find(<user-id>).organizations

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #407837 (closed)

Merge request reports