# `Tempo.SQL.SQLite.Migration`
[🔗](https://github.com/elixir-tempo/tempo_sql/blob/v0.4.0/lib/tempo/sql/sqlite/migration.ex#L1)

Ecto migration helpers for `Tempo.Ecto.SQLite.TempoRange` columns.

    import Tempo.SQL.SQLite.Migration

    create table(:meetings) do
      add_tempo_range :window
    end

    create_tempo_range_index :meetings, :window

The column is `TEXT`, holding the JSON document
`Tempo.SQL.SQLite.Document` writes, whichever frame the field is on.
The index is a pair of expression indexes on the document's lower and
upper bounds, which the comparisons `Tempo.Ecto.SQLite.QueryAPI`
writes are answered from.

# `add_tempo_range`
*macro* 

Adds a `TEXT` column for a `Tempo.Ecto.SQLite.TempoRange` field.

### Arguments

* `field` is the column name as an atom.

* `options` is a keyword list of options.

### Options

* `:frame` is the field's frame, `:utc` (the default) or `:floating`.
  The column is `TEXT` on either; the option is checked and taken out.

* Every other option is passed through to `Ecto.Migration.add/3`.

### Returns

* The column declaration, as `Ecto.Migration.add/3` returns it. Call
  it inside a `create table` block.

### Examples

    add_tempo_range :window
    add_tempo_range :opening_hours, frame: :floating, null: false

# `create_tempo_range_index`

```elixir
@spec create_tempo_range_index(atom(), atom()) :: :ok
```

Creates the expression indexes on the bounds of a
`Tempo.Ecto.SQLite.TempoRange` column.

Two indexes are created, `<table>_<column>_lo_index` on the lower
bound and `<table>_<column>_hi_index` on the upper, so that a query
bounding either end of the column's spans is answered by an index.

### Arguments

* `table` is the table name as an atom.

* `column` is the column name as an atom.

### Returns

* The two `CREATE INDEX` statements, as `Ecto.Migration.execute/2`
  returns them. Both are reversible.

### Examples

    create_tempo_range_index :meetings, :window

---

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