pub async fn delete(
pool: &PgPool,
actor: &Actor,
item_id: Uuid,
) -> AppResult<String>Expand description
Deletes an item created by mistake. Only allowed while it has a single in-work revision, is not used in any BOM, not part of any change, no simulation basis, no design that units were built to and – in a restricted group – no affected item of a change request.
§Invariants
- Permission: editor role (403); the item is visible to the actor (“not found” otherwise); only its creator (as a member of the group) or an admin may delete it (403).
- Locks: the item row (
FOR UPDATE); the project group row (FOR SHARE) when the item has one. - Audit:
item.delete; in an unrestricted group alsochange_request.remove_itemfor every change request that named the item. - Notifications: the people of those change requests (unrestricted groups only).
- Webhooks: none.
- Refused with 409: more than one revision or one not in work, used in a BOM, part of a change, basis of a simulation, units were recorded as built to it (a build record names one of its revisions), or (restricted group) an affected item of a change request.
- Atomic: one transaction.