Uni Ecto Plugin Instant

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 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 . uni ecto plugin

conn end

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