Mutiny.Adapters.Postgres (mutiny v0.1.0) View Source

Implements Mutiny.Adapter to provide commands for PostgreSQL.

Link to this section Summary

Functions

Returns a PostgreSQL function that can be triggered to prevent UPDATEs to a database table.

Returns a PostgreSQL command that drops the function created by create_prevent_update_function/0, if it exists.

Returns a PostgreSQL command to create a database trigger that prevents UPDATEs to the given Ecto.Migration.Table.

Returns a PostgreSQL command to create a database trigger that prevents UPDATEs to the given columns of the Ecto.Migration.Table.

Link to this section Functions

Link to this function

create_prevent_update_function()

View Source

Returns a PostgreSQL function that can be triggered to prevent UPDATEs to a database table.

Examples

iex> create_prevent_update_function()
"CREATE OR REPLACE FUNCTION prevent_update()..."
Link to this function

drop_prevent_update_function()

View Source

Returns a PostgreSQL command that drops the function created by create_prevent_update_function/0, if it exists.

Examples

iex> drop_prevent_update_function()
"DROP FUNCTION IF EXISTS prevent_update();"

Returns a PostgreSQL command to create a database trigger that prevents UPDATEs to the given Ecto.Migration.Table.

Examples

iex> protect(table("users"))
"CREATE OR REPLACE TRIGGER prevent_update..."
Link to this function

protect(table, columns, opts \\ [])

View Source

Returns a PostgreSQL command to create a database trigger that prevents UPDATEs to the given columns of the Ecto.Migration.Table.

Examples

iex> protect(table("users"), [:uuid, :birthdate])
"DO $$..."

iex> protect(table("users"), [:uuid], nullable: true)
"DO $$..."

Options

  • nullable - Whether the columns can be set to NULL; defaults to false