Schema PKey is not ID but still getting ERROR 42703 (undefined_column) column does not exist

I’m sure I’m doing something lame again about config. I have a liveview application that I’m pulling back all data from a Schema that uses a primary key that does not use id as the default primary key. When I run Repo.all(<schema_name>) from context module, I get the error ERROR 42703 (undefined_column) column does not exist. Here’s my schema definition:

defmodule Crm.Cards.Card do
use Ecto.Schema
import Ecto.Changeset

schema “cards” do
field :addr, :string
field :biz_type, :string
… additional field definitions
field :trello_id, :string, primary_key: true
field :web_url, :string
field :zip_code, :string



Appreciate any help on this.

Hey @wdtnh checkout Ecto.Schema — Ecto v3.10.3 basically you need to

@primary_key {:trello_id, :string, autogenerate: false}

thanks. I wasn’t aware of that particular formatting change to schema defs.

afraid that didn’t work either.

Can you show the schema module as it stands now?

fixed it. Found the reference where @primary_key outside of the schema field defs. For those are curious…

  use Ecto.Schema
  import Ecto.Changeset

  @primary_key {:trello_id, :string, autogenerate: false}

  schema "cards" do
    field :addr, :string

Found it… thanks very much for the assist.

Glad it worked! Tiny forum note: I edited your post so that the code formatting worked properly, you want to use ``` not ‘’'.