condo v0.2.4 Condo View Source
Main functions for Condo.
Link to this section Summary
Functions
Creates a schema.
Drops a schema.
Upwards migration. First checks for a change/0
function and then checks for
an up/0
function.
Creates a new tenant. It will first start by creating the schema, then it will ensure that there is a schema_migrations table. Once that has happened, each migration in your migration namespace will run and also write to the schema_migrations table that it has ran.
Set a prefix for a query or for a tenant. If one arity is provided, we assume that the prefix is for an ID or for a struct.
Rollsback the latest migration. First checks for a change/0
function and
then checks for a down/0
function.
Link to this section Types
query()
View Sourcequery() :: {:ok, %{ :rows => nil | [[term()] | binary()], :num_rows => non_neg_integer(), optional(atom()) => any() }} | {:error, Exception.t()}
Link to this section Functions
Creates a schema.
Drops a schema.
migrate_tenant(repo, tenant)
View Sourcemigrate_tenant(queryable(), tenant()) :: [{:ok, non_neg_integer()}]
Upwards migration. First checks for a change/0
function and then checks for
an up/0
function.
new_tenant(repo, tenant)
View Sourcenew_tenant(queryable(), tenant()) :: {:ok, String.t(), [{:ok, non_neg_integer()}]}
Creates a new tenant. It will first start by creating the schema, then it will ensure that there is a schema_migrations table. Once that has happened, each migration in your migration namespace will run and also write to the schema_migrations table that it has ran.
Set a prefix for a query or for a tenant. If one arity is provided, we assume that the prefix is for an ID or for a struct.
Examples
iex> Condo.prefix("public")
"public"
iex> Condo.prefix(:public)
"public"
iex> Condo.prefix(123)
"tenant_123"
iex> Condo.prefix("abc")
"tenant_abc"
iex> Condo.prefix(:abc)
"tenant_abc"
iex> Condo.prefix(%{id: 123})
"tenant_123"
iex> Condo.prefix("users", :abc)
#Ecto.Query<from u0 in "users">
rollback_tenant(repo, tenant)
View Sourcerollback_tenant(queryable(), tenant()) :: {:ok, non_neg_integer()}
Rollsback the latest migration. First checks for a change/0
function and
then checks for a down/0
function.