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 create table?
defmodule Sipusers.Repo.Migrations.CreateCustomers do
use Ecto.Migration
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
timestamps
end
end
end
Ecto.Migration.change/2 is a macro that takes a block (the bit between do and 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: https://github.com/elixir-ecto/ecto/blob/master/lib/ecto/migration.ex#LL259
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]).