Uni Ecto Plugin Site

def call(conn, _opts) do # Extract subdomain or API key tenant = get_tenant_from_subdomain(conn)

:ok, prefix end The uni_ecto_plugin often bundles a caching mechanism. Setting a tenant prefix usually involves a database lookup to validate the tenant exists. This adds latency. uni ecto plugin

mix uni_ecto.gen.migration create_tenants_table This creates a migration that tracks tenants in a central tenants meta-table. Add the Plug to your router: def call(conn, _opts) do # Extract subdomain or

conn end

def get_orders_with_global_settings do query = from o in Order, join: s in Setting, on: true, # Global join select: o, s Repo.all(query, prefix: UniEcto.Plugin.get_tenant_prefix()) end Handling Migrations with The Plugin The trickiest part of multi-tenancy is database schema updates. You cannot just run mix ecto.migrate . mix uni_ecto

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 .