Uni Ecto Plugin [ 8K 2027 ]
Alternatively, use the plugin's CLI:
If you are an Elixir developer using Phoenix Framework and Ecto, you have likely heard the siren call of the .
The uni_ecto_plugin provides a migration helper: uni ecto plugin
In the modern landscape of Software as a Service (SaaS), multi-tenancy is no longer a luxury—it’s a necessity. Whether you are building a white-label CRM, an enterprise ERP, or a simple API for startups, you need a way to isolate customer data securely.
def call(conn, _opts) do # Extract subdomain or API key tenant = get_tenant_from_subdomain(conn) Alternatively, use the plugin's CLI: If you are
conn end
pipeline :api do plug :accepts, ["json"] plug MyApp.Plugs.TenantResolver end Create the resolver: def call(conn, _opts) do # Extract subdomain or
defmodule MyApp.Repo do use Ecto.Repo, otp_app: :my_app use UniEcto.Plugin, prefix_key: :tenant_prefix def all_tenants do # Could be a DB query or a static list ["public", "tenant_customer_a", "tenant_customer_b"] end end Step 3: Generate the Tenant Migrations The plugin usually provides a generator: