Disabling a primary key on Echo inline embeds_many

I recently discovered inline embeds where you can define a module in your schema like:

schema "customers" do 
  field :name, :string
  embeds_many :accepted_payments, Payment, on_replace: :delete do 
   @moduledoc false 
   field :payment_type, :string 
   field :payment_id, UUID
 end 
end 

However this leads to a warning about duplicate primary keys: found duplicate primary keys for association/embed. Is it possible to use @primary_key false on this embeds_many field? I haven’t had any luck with something like:

  @primary_key false
    embeds_many :accepted_payments, ...

Or should I move this into a separate module and add @primary_key false above the schema.

You can set it as an additional option: primary_key: false

3 Likes