Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions documentation/topics/advanced/multitenancy.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ In Ash, there are two primary strategies for implementing multitenancy. The firs
## Attribute Multitenancy

```elixir
defmodule MyApp.Users do
defmodule MyApp.User do
use Ash.Resource, ...

multitenancy do
Expand Down Expand Up @@ -124,9 +124,25 @@ User

## Context Multitenancy

```elixir
defmodule MyApp.Project do
use Ash.Resource, data_layer: AshPostgres.DataLayer

multitenancy do
strategy :context
end

...

relationships do
belongs_to :organization, MyApp.Organization
end
end
```

Context multitenancy allows for the data layer to dictate how multitenancy works. For example, a csv data layer might implement multitenancy via saving the file with different suffixes, or an API wrapping data layer might use different subdomains for the tenant.

For `AshPostgres` context multitenancy, which uses postgres schemas and is referred to ash "Schema Based Multitenancy", see the [guide](https://hexdocs.pm/ash_postgres/schema-based-multitenancy.html)
For `AshPostgres` context multitenancy, which uses Postgres schemas and is referred to Ash "Schema Based Multitenancy", see the [guide](https://hexdocs.pm/ash_postgres/schema-based-multitenancy.html)

## Possible Values for tenant

Expand Down
Loading