fix(postgres): keep every organisation an active owner

This commit is contained in:
sam committed 2026-10-17 10:07:45 +11:00
1 parent 41199b1bc4
commit c99e09d665
8 files changed
+95 -4

No files matched your search

+2 -1
View File
@@ -10,6 +10,7 @@ import (
"github.com/samcharles93/archie-core/internal/domain/access"
"github.com/samcharles93/archie-core/internal/domain/identity"
"github.com/samcharles93/archie-core/internal/domain/org"
)
type identityRequest struct {
@@ -112,7 +113,7 @@ func writeIdentityError(w http.ResponseWriter, err error) {
switch {
case errors.Is(err, identity.ErrNotFound):
code = http.StatusNotFound
case errors.Is(err, identity.ErrConflict):
case errors.Is(err, identity.ErrConflict), errors.Is(err, org.ErrLastOwner):
code = http.StatusConflict
case errors.Is(err, identity.ErrInvalid), errors.Is(err, identity.ErrIllegalTransition), errors.Is(err, identity.ErrSystemImmutable):
code = http.StatusBadRequest
+2 -1
View File
@@ -399,7 +399,8 @@ func writeOrgError(w http.ResponseWriter, err error) {
http.Error(w, err.Error(), http.StatusBadRequest)
case errors.Is(err, org.ErrOrgNotFound):
http.Error(w, err.Error(), http.StatusNotFound)
case errors.Is(err, org.ErrOrgExists), errors.Is(err, org.ErrWorkspaceExists), errors.Is(err, org.ErrMembershipExists):
case errors.Is(err, org.ErrOrgExists), errors.Is(err, org.ErrWorkspaceExists), errors.Is(err, org.ErrMembershipExists),
errors.Is(err, org.ErrLastOwner):
http.Error(w, err.Error(), http.StatusConflict)
default:
writeControlPlaneError(w, err)