Mutiny (mutiny v0.1.0) View Source
Functions for generating database commands that enforce immutability.
Link to this section Summary
Functions
Injects shorthand Mutiny functions that implicitly pass the specified
adapter. These functions include
Returns a function that can be executed to prevent UPDATEs to a database
table. This function only needs to be executed once per database.
Drops the function created by create_prevent_update_function/0, if it
exists. Useful when rolling back a migration.
Returns a command to create a database trigger that prevents UPDATEs to the
given Ecto.Migration.Table.
Returns a command to create a database trigger that prevents UPDATEs to the
given columns of the Ecto.Migration.Table.
Link to this section Functions
Specs
Injects shorthand Mutiny functions that implicitly pass the specified
adapter. These functions include:
protect/1- Makes a table immutableprotect/3- Makes specific columns of a table immutablecreate_prevent_update_function/0- Creates the database function Mutiny callsdrop_prevent_update_function/0- Drops the database function Mutiny calls
When useing this module, a database adapter module should be specified. The
currently available modules are:
Note that Mutiny exposes public versions of all these functions, should you
desire to call them directly.
Options
adapter- The Mutiny database adapter to use
Examples
defmodule MyApp.Repo.Migrations.CreateSnapshots do
use Ecto.Migration
use Mutiny, adapter: Mutiny.Adapter.Postgres
create table("snapshots") do
add :data, :map
end
protect(table("snapshots"))
end Specs
Returns a function that can be executed to prevent UPDATEs to a database
table. This function only needs to be executed once per database.
Examples
iex> Mutiny.Adapters.Postgres ...> |> create_prevent_update_function() ...> |> execute() :ok
Specs
Drops the function created by create_prevent_update_function/0, if it
exists. Useful when rolling back a migration.
Examples
iex> Mutiny.Adapters.Postgres ...> |> drop_prevent_update_function() ...> |> execute() :ok
Specs
protect(Ecto.Migration.Table.t(), atom()) :: String.t()
Returns a command to create a database trigger that prevents UPDATEs to the
given Ecto.Migration.Table.
An adapter module that implements Mutiny.Adapter should be specified in
correspondence with your Ecto adapter.
Examples
iex> table("users")
...> |> protect(Mutiny.Postgres)
...> |> execute()
:ok Specs
protect( Ecto.Migration.Table.t(), Mutiny.Adapter.columns(), atom(), Mutiny.Adapter.opts() ) :: String.t()
Returns a command to create a database trigger that prevents UPDATEs to the
given columns of the Ecto.Migration.Table.
An adapter module that implements Mutiny.Adapter should be specified in
correspondence with your Ecto adapter.
Options may be specified as an opts list that will be passed to the given
adapter.
Examples
iex> table("users")
...> |> protect([:uuid, :birthdate], Mutiny.Adapters.Postgres)
...> |> execute()
:ok
iex> table("users")
...> |> protect([:uuid], Mutiny.Adapters.Postgres, nullable: true)
...> |> execute()
:ok