Problem
You would like to use a legacy or a database you don’t have control over, with Phoenix, but the primary key of the table it is not named ‘id’.
** (Mariaex.Error) (1054): Unknown column 'p0.id' in 'field list'
Solution
You can define the primary key using the @primary_key as in:
@primary_key {:id_other_name, :integer, []} schema "db_table" do field :description, :string ... end
Taken from here