Ecto and composite primary keys

Hello guys, I’m trying to write Ecto migrations for composite primary keys but got no luck. This is what I done:

create table(:firmwares, primary_key: false) do
  add :version, :integer, primary_key: true
  add :board_name, references(:boards, column: :name, type: :string), primary_key: true

And this is the error I get when running ecto.migrate

** (Postgrex.Error) ERROR (invalid_table_definition): multiple primary keys for table "firmwares" are not allowed

Anyone got any leads/ideas?

Thanks in advance!


Are you using Ecto 2? Afaik composite primary key support was added to 2.

1 Like

Well I’m not. Can’t wait for Ecto 2 then. :slight_smile:


The Release Candidate was just released a couple of days ago. I think you can give it a try it should be stable enough.

1 Like