Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update license user association from has one to has many #768

Closed

Conversation

ezekg
Copy link
Member

@ezekg ezekg commented Nov 9, 2023

Closes #534.

Prerequisites

  • Add API endpoints for assigning/unassigning users to licenses. (Should we use attach/detach?)
  • Update user validation scope to look at License#users.
  • Add owner validation scope.
  • Rename License#user to License#owner.
  • Rename singular user relationship to owner in user serializer.
  • Add plural users relationship to license serializer.
  • Add migration to rename data.relationships.owner to data.relationship.user for licenses (with updated links).
  • Bump API version to v1.6.
  • Rename license.user.updated webhook event to license.owner.updated? (Or send both?)
  • Write integration tests for license owner vs license user authz.

Pre-deploy

  • Create license.owner.updated, license.users.attached, license.users.detached, machine.owner.updated event types.
  • Create license.owner.update, license.users.attach, license.users.detach, machine.owner.update permissions.

Post-deploy

  • Rename licenses.user_id to licenses.owner_id? (May want to do this during our next maintenance window.)
  • Rename license.user.update permission to license.owner.update?
  • Reseed database with new permissions/events.
  • Add license.owner.update, license.users.attach, license.users.detach, machine.owner.update permissions to relevant roles.

app/models/license.rb Outdated Show resolved Hide resolved
app/models/license.rb Outdated Show resolved Hide resolved
@ezekg ezekg force-pushed the feature/update-license-user-from-has-one-to-has-many-p1 branch from 3c8d7e7 to b759ca1 Compare November 16, 2023 17:10
@ezekg ezekg force-pushed the feature/update-license-user-from-has-one-to-has-many-p1 branch 7 times, most recently from 567d86d to a4b9b76 Compare December 11, 2023 21:54
@ezekg ezekg force-pushed the feature/update-license-user-from-has-one-to-has-many-p1 branch 2 times, most recently from acbdde0 to 42fe29d Compare December 11, 2023 22:27
@ezekg ezekg force-pushed the feature/update-license-user-from-has-one-to-has-many-p1 branch 2 times, most recently from a13d73f to b4ca925 Compare December 12, 2023 18:37
@ezekg ezekg force-pushed the feature/update-license-user-from-has-one-to-has-many-p1 branch 9 times, most recently from 47ba74f to da06f95 Compare December 12, 2023 22:50
@ezekg ezekg force-pushed the feature/update-license-user-from-has-one-to-has-many-p1 branch 5 times, most recently from a537bb1 to d88c8af Compare December 14, 2023 22:44
@ezekg ezekg force-pushed the feature/update-license-user-from-has-one-to-has-many-p1 branch from d88c8af to 02d5f60 Compare December 14, 2023 22:45
app/models/license.rb Outdated Show resolved Hide resolved
@ezekg
Copy link
Member Author

ezekg commented Jan 3, 2024

New plan: with the proof of concept union_of gem, we're able to create associations that union across multiple associations. This allows us to really clean up our implementation here, and gets rid of the need to do a multi-part PR.

Let's clean up union_of and add more exhaustive tests, and go in the direction mentioned in #534 (comment).

@ezekg ezekg force-pushed the feature/update-license-user-from-has-one-to-has-many-p1 branch from 3d5aa06 to d6183bc Compare January 10, 2024 16:45
@ezekg
Copy link
Member Author

ezekg commented Jan 11, 2024

Should a machine belong to an owner? Right now, it doesn't make sense that a machine always belongs to the owner of the license, since in reality, it could belong to any of the license's licensees, not necessarily the license's owner.

@ezekg ezekg closed this Jan 12, 2024
@ezekg ezekg deleted the feature/update-license-user-from-has-one-to-has-many-p1 branch January 12, 2024 21:04
@ezekg ezekg mentioned this pull request Jan 12, 2024
25 tasks
@ezekg ezekg restored the feature/update-license-user-from-has-one-to-has-many-p1 branch January 14, 2024 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A license should have multiple users
1 participant