Modify how we distinguish between application and instance assigned devices in DB
- Dominant language
- JavaScript
- Stars
- 400
- Forks
- 89
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 146
Description
The Devices table has the columns:
- `ApplicationId`
- `ProjectId`
If a Device is assigned to an Instance, then only `ProjectId` is set.
If a Device is assigned to an Application, then only the `ApplicationId` value is set.
A device assigned to an instance in an application is still 'within' that application - and it would be reasonable for it to be included in counts of devices associated with the application. This is not currently the case and can cause misleading status in the UI.
There are two possible fixes;
- Make the relevant queries more complex with joins across Application/Instance tables to get the full list of possible device owners.
- Ensure the ApplicationId column is always set.
Given we have both columns already, my preference is option 2. It makes more sense to ensure `ApplicationId` is always set when the Device is assigned to something, and set `ProjectId` when that something is an instance.
Instances cannot move between Applications, so there is no data consistency issue here.
There are a few places where the code determines the assignment of a device based on whether ApplicationId is set or not - they will need to be updated.
Contributor guide
Assessment
This issue has not been assessed yet.