# `Money.DDL`
[🔗](https://github.com/ex-money/money_sql/blob/v2.1.0/lib/money/ddl.ex#L1)

Functions to return SQL DDL commands that support the
creation and deletion of the `money_with_currency` database
type and associated aggregate functions.

The SQL is generated by `Localize.Ecto.TaggedDecimal.DDL` from the
money specification below. A money amount is a tagged decimal — a
currency code paired with an amount — so it shares the composite type,
aggregate and operator machinery with other tagged decimals such as
units, rather than defining its own.

# `create_money_with_currency`

Returns the SQL string which when executed will
define the `money_with_currency` data type.

## Arguments

* `db_type`: the type of the database for which the SQL
  string should be returned.  Defaults to `:postgres` which
  is currently the only supported database type.

# `define_avg_function`

Returns the SQL string which when executed will
define the avg function for the `money_with_currency`
data type.

## Arguments

* `db_type`: the type of the database for which the SQL
  string should be returned.  Defaults to `:postgres` which
  is currently the only supported database type.

# `define_minmax_functions`

Returns the SQL string which when executed will
define min and max functions for the `money_with_currency`
data type.

## Arguments

* `db_type`: the type of the database for which the SQL
  string should be returned.  Defaults to `:postgres` which
  is currently the only supported database type.

# `define_minus_operator`

Returns the SQL string which when executed will
define an infix `-` operator for the `money_with_currency`
data type.

## Arguments

* `db_type`: the type of the database for which the SQL
  string should be returned.  Defaults to `:postgres` which
  is currently the only supported database type.

# `define_negate_operator`

Returns the SQL string which when executed will
define a unary `-` operator for the `money_with_currency`
data type.

## Arguments

* `db_type`: the type of the database for which the SQL
  string should be returned.  Defaults to `:postgres` which
  is currently the only supported database type.

# `define_plus_operator`

Returns the SQL string which when executed will
define a `+` operator for the `money_with_currency`
data type.

## Arguments

* `db_type`: the type of the database for which the SQL
  string should be returned.  Defaults to `:postgres` which
  is currently the only supported database type.

# `define_sum_function`

Returns the SQL string which when executed will
define sum functions for the `money_with_currency`
data type.

## Arguments

* `db_type`: the type of the database for which the SQL
  string should be returned.  Defaults to `:postgres` which
  is currently the only supported database type.

# `drop_avg_function`

Returns the SQL string which when executed will
drop the avg function for the `money_with_currency`
data type.

## Arguments

* `db_type`: the type of the database for which the SQL
  string should be returned.  Defaults to `:postgres` which
  is currently the only supported database type.

# `drop_minmax_functions`

Returns the SQL string which when executed will
drop the min and max functions for the `money_with_currency`
data type.

## Arguments

* `db_type`: the type of the database for which the SQL
  string should be returned.  Defaults to `:postgres` which
  is currently the only supported database type.

# `drop_minus_operator`

Returns the SQL string which when executed will
drop the infix `-` operator for the `money_with_currency`
data type.

## Arguments

* `db_type`: the type of the database for which the SQL
  string should be returned.  Defaults to `:postgres` which
  is currently the only supported database type.

# `drop_money_with_currency`

Returns the SQL string which when executed will
drop the `money_with_currency` data type.

## Arguments

* `db_type`: the type of the database for which the SQL
  string should be returned.  Defaults to `:postgres` which
  is currently the only supported database type.

# `drop_negate_operator`

Returns the SQL string which when executed will
drop the unary `-` operator for the `money_with_currency`
data type.

## Arguments

* `db_type`: the type of the database for which the SQL
  string should be returned.  Defaults to `:postgres` which
  is currently the only supported database type.

# `drop_plus_operator`

Returns the SQL string which when executed will
drop the `+` operator for the `money_with_currency`
data type.

## Arguments

* `db_type`: the type of the database for which the SQL
  string should be returned.  Defaults to `:postgres` which
  is currently the only supported database type.

# `drop_sum_function`

Returns the SQL string which when executed will
drop the sum functions for the `money_with_currency`
data type.

## Arguments

* `db_type`: the type of the database for which the SQL
  string should be returned.  Defaults to `:postgres` which
  is currently the only supported database type.

# `execute`

Returns a string that will Ecto `execute` a single SQL
command.

## Arguments

* `sql` is a single SQL command

## Example

    iex> Money.DDL.execute "SELECT name FROM customers;"
    "execute \"SELECT name FROM customers;\""

# `execute_each`

Returns a string that will Ecto `execute` each SQL
command.

## Arguments

* `sql` is a string of SQL commands that are
  separated by three newlines ("\\n"),
  that is to say two blank lines between commands
  in the file.

## Example

    iex> Money.DDL.execute "SELECT name FROM customers;\n\n\nSELECT id FROM orders;"
    "execute \"\"\"\nSELECT name FROM customers;\n\n\nSELECT id FROM orders;\n\"\"\""

---

*Consult [api-reference.md](api-reference.md) for complete listing*
