Skip to content

feat: add organizations and memberships - #14

Merged
vinimachadosantana merged 2 commits into
developfrom
feat/organizations
Aug 7, 2026
Merged

feat: add organizations and memberships#14
vinimachadosantana merged 2 commits into
developfrom
feat/organizations

Conversation

@vinimachadosantana

Copy link
Copy Markdown
Owner

What

Adds Organization and Membership models with roles, plus endpoints to list and create organisations.

Why

The tenancy boundary. Every resource from here belongs to an organisation, and membership is what grants access to it.

How

  • role is an integer enum with compact storage, plus generated predicates and scopes.
  • A composite unique index on [user_id, organization_id] stops duplicate memberships at the database level, where it can't be raced.
  • Creating an organisation and its first membership happens in a transaction.
  • index reads through current_user.organizations, so the association itself scopes the query.

Testing

  • Creator becomes an admin
  • Listing returns only the user's own organisations

@vinimachadosantana vinimachadosantana self-assigned this Aug 7, 2026
@vinimachadosantana
vinimachadosantana merged commit 20f5465 into develop Aug 7, 2026
3 checks passed
@vinimachadosantana
vinimachadosantana deleted the feat/organizations branch August 7, 2026 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant