View Source EctoTemp.Macros (ecto_temp v0.1.3)

Link to this section Summary

Functions

Add a column to a table definition.

Runs through previously defined @ecto_temporary_tables to insert temporary tables. This should be called in a setup block, which needs to be defined after all deftemptable definitions.

Creates a temporary table that will be rolled back at the end of the current test transaction. If the table name is given as :thing, then the actual temporary table will be created as thing_temp.

Adds inserted_at and updated_at to a table definition.

Link to this section Functions

Link to this macro

column(name, type, opts \\ [])

View Source (macro)

Add a column to a table definition.

This must be called within a deftemptable block, or a CompileError will be raised.

Link to this macro

create_temp_tables()

View Source (macro)

Runs through previously defined @ecto_temporary_tables to insert temporary tables. This should be called in a setup block, which needs to be defined after all deftemptable definitions.

Link to this macro

deftemptable(table_name, opts \\ [], list)

View Source (macro)

Creates a temporary table that will be rolled back at the end of the current test transaction. If the table name is given as :thing, then the actual temporary table will be created as thing_temp.

examples

Examples

deftemptable :cycles do
  column :athlete_plan_id, :integer, null: false
  deftimestamps()
end

deftemptable :scan, primary_key: false do
  column :scan_sha, :string, null: false
  column :comment, :string
end

opts

Opts

nametypedefaultdescription
primary_keybooleantrueWhen true, adds an :id field of type :bigserial
Link to this macro

deftimestamps()

View Source (macro)

Adds inserted_at and updated_at to a table definition.

This must be called within a deftemptable block, or a CompileError will be raised.