Is this code regular elixir code or ecto DSL code?
If it is regular Elixir code then what is the type of structure being passed to
defmodule Sipusers.Repo.Migrations.CreateCustomers do
def change do
create table(:customers) do
add :custname, :string
add :email, :string
add :account_id, :string
add :first_device, :string
add :first_tel_no, :string
add :active, :boolean
It’s both at the same time!
Ecto.Migration.change/2 is a macro that takes a block (the bit between
end) and transforms the AST in order to ensure certain behaviors (such as adding a primary key if you haven’t defined one).
You can take a look at how it’s implemented here:
Ecto.Migration.add/3 which is used inside that block is just a regular function that takes a field name, a type and a Keyword list of options. You could also write it like this:
Ecto.Migration.add(:name, :type, [key: val]).