Allow a camera to belong to multiple organizations #530
MateoLostanlen
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
We have a modeling question about cameras and organizations in the API.
Right now, a camera belongs to a single organization through a foreign key:
Our organizations represent geographic regions or departments:
We also have users tied to a single organization:
Problem
In some real deployments, a camera is located on the border between two regions or departments. Firefighters from both organizations would like to see and use the same camera in the interface.
With the current schema, a camera can only be attached to one organization. The only workaround would be to duplicate the camera entry, which would create several issues:
We would prefer to keep a single camera record and allow several organizations to have access to it.
Proposal
Introduce an association table to represent a many to many relation between cameras and organizations.
Example:
Then we could:
Cameraas the technical and physical entityCameraOrganizationCamera.organization_idas the primary organization for backward compatibility and default behavior, at least during a transition phaseAPI behavior for permissions could then be:
camera_organizationsCameraOrganizationrow for each camera using the currentorganization_idMigration plan
High level idea:
Add
camera_organizationstableBackfill it from existing data:
CameraOrganizationwithorganization_id = camera.organization_idandis_primary = TrueUpdate queries and permission checks to use the association table
Later, consider deprecating
Camera.organization_idonce the new relation is fully usedBeta Was this translation helpful? Give feedback.
All reactions