ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 9m19s
ci / test (pull_request) Successful in 9m25s
ci / build (pull_request) Successful in 15m40s
ci / image (pull_request) Successful in 4m26s
An organization may now have several owners; the unique index allowing only one is gone. Owners make members owners or take it back, their own included, through PUT /api/v1/org/members/:user/owner; handing an organization over is making someone else owner and stepping down. The last owner cannot step down, and changes serialize on a per-organization lock so two owners stepping down at once cannot leave none. A former owner without roles keeps working as Admin. Owners still cannot be removed while they are owners. Deleting an account now takes along only the organizations it is the last owner of, counted under the same lock; it just leaves those with further owners. The members page offers "Make owner", "Remove as owner" and "Step down as owner" to owners. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
13 lines
493 B
SQL
13 lines
493 B
SQL
-- +goose Up
|
|
-- An organization may have several owners; the API keeps at least one.
|
|
DROP INDEX memberships_one_owner_idx;
|
|
|
|
-- +goose Down
|
|
-- Keeps the longest-standing owner of each organization.
|
|
UPDATE memberships m SET is_owner = false
|
|
WHERE m.is_owner AND EXISTS (
|
|
SELECT 1 FROM memberships o
|
|
WHERE o.org_id = m.org_id AND o.is_owner AND (o.created_at, o.user_id) < (m.created_at, m.user_id)
|
|
);
|
|
CREATE UNIQUE INDEX memberships_one_owner_idx ON memberships (org_id) WHERE is_owner;
|