Uni Ecto Plugin [best]
def perform(%Oban.Jobargs: %"tenant_id" => tenant_id) do tenant = Repo.get_by!(Tenant, tenant_id: tenant_id) Uni.Ecto.put_prefix(tenant.schema_prefix)
: The plugin's database-agnostic approach provides developers with the flexibility to choose the best database solution for their applications, without being locked into a specific database system. uni ecto plugin
is a specific visual effects plugin included in the Red Giant Universe def perform(%Oban
def create_tenant(attrs) do # 1. Generate a safe schema name schema_name = "tenant_#attrs.tenant_id" |> String.replace("-", "_") When you write MyApp
The plugin perfectly maps Ecto’s prefix option. When you write MyApp.Repo.all(User, prefix: "tenant_foo") , uni_ecto translates that to the PostgreSQL schema tenant_foo . This means your standard Ecto queries don't change; only the tenant resolution logic does.
The transforms how Elixir developers implement multi-tenancy. By leveraging PostgreSQL schemas and providing clean abstractions for migration and resolution, it removes the cognitive overhead of tenant scoping.