Tempo.SQL.SQLite.Migration (Tempo SQL v0.4.0)

Copy Markdown View Source

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.

Summary

Functions

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

Functions

add_tempo_range(field, options \\ [])

(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

Examples

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

create_tempo_range_index(table, column)

@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

Examples

create_tempo_range_index :meetings, :window