condo v0.1.3 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() :: {: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(queryable(), tenant_id()) :: [{:ok, non_neg_integer()}]
Upwards migration. First checks for a change/0
function and then checks for
an up/0
function.
new_tenant(queryable(), tenant_id()) :: {: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> prefix(123)
"tenant_123"
iex> prefix("abc")
"tenant_abc"
iex> prefix(%Blog{id: 123})
"tenant_123"
iex> from(b in Blog) |> prefix("abc")
rollback_tenant(queryable(), tenant_id()) :: {:ok, non_neg_integer()}
Rollsback the latest migration. First checks for a change/0
function and
then checks for a down/0
function.