Organization must have at least one owner
Prevent removal of all organization owners.
Note that the relationship between organizations and users is defined with a loose foreign key through the organization_users
join table.
There is also the inverse problem: User must always belong to at least one organiz... (#443873 - closed).
Proposal
Related design issue #441282.
There's two cases here:
- User can be removed from
users
table -> that is difficult to address: With a database constraint. - User can be removed from
organizations_users
table -> more trivial: There's alreadyensure_user_has_an_organization
before destroy which is very similar to the work required here.
Edited by Christina Lohr