Uni | Ecto Plugin
defmodule MyApp.Repo.Migrations.AddNotesToOrders do use Ecto.Migration import UniEcto.MigrationHelpers def up do # Runs on all existing tenants + public for tenant <- UniEcto.Plugin.all_tenants() do execute("SET search_path TO #tenant") alter table(:orders) do add :notes, :text end end end end
| Library | Strategy | Best For | | :--- | :--- | :--- | | | PostgreSQL Schemas | Most Elixir SaaS apps (Gold standard) | | Uni Ecto Plugin | Custom (Configurable) | Developers needing fine-grained control | | Apartment (Rails) | Row-level (Legacy) | Not recommended for Elixir | | Ash Framework Multi-Tenancy | Resource Layer | Large, complex domain models | uni ecto plugin
defmodule MyApp.Plugs.TenantResolver do import Plug.Conn import UniEcto.Plugin, only: [set_tenant_prefix: 1] def init(default), do: default defmodule MyApp