View Source EctoTemp.Macros (ecto_temp v1.2.0)
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 :things
, then
the actual temporary table will be created as things
. As this may
overlap with existing tables, it is recommended to use a temp
prefix
of suffix when defining temp tables.
Adds inserted_at
and updated_at
to a table definition.
Functions
Add a column to a table definition.
This must be called within a deftemptable
block, or a CompileError will be raised.
Opts
name | type | default | description |
default | term() | Provides a default value when none is provided. | |
null | boolean | true | Determines whether null values are allowed in a column. |
@spec create_temp_tables() :: Macro.t()
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 :things
, then
the actual temporary table will be created as things
. As this may
overlap with existing tables, it is recommended to use a temp
prefix
of suffix when defining temp tables.
Examples
deftemptable :person_temp do
column :thing_id, :integer, null: false
deftimestamps()
end
deftemptable :thing_temp, primary_key: false do
column :description, :string, null: false
column :comment, :string
end
Opts
name | type | default | description |
primary_key | boolean | true | When true, adds an :id field of type :bigserial |
@spec deftimestamps() :: Macro.t()
Adds inserted_at
and updated_at
to a table definition.
This must be called within a deftemptable
block, or a CompileError will be raised.