title: What is this Ecto Constraint Error trying to tell me?
body: <pre><code>** (Ecto.ConstraintError) constraint error when attempting to insert model:
  
      * foreign_key: matches_person_id_fkey
  </code></pre>
  
  <p>Here is my schema and migration:</p>
  
  <pre><code>def change do
    create table(:matches) do
      add :percentage, :float
      add :person_id, references(:persons)
      add :star_id, references(:stars)
  
      timestamps
    end
    create index(:matches, [:person_id])
  end
  
  schema "matches" do
    field :percentage, :float
    belongs_to :person, Person
    belongs_to :star, Star
  
    timestamps
  end
  </code></pre>
  
  <p>The changeset I am using when calling Repo.insert(changeset) is:</p>
  
  <pre><code>%Ecto.Changeset{action: nil,
   changes: %{percentage: 0.513657, person_id: 55, star_id: 1}, constraints: [],
   errors: [], filters: %{},
   model: %App.Match{__meta__: #ecto.Schema.Metadata&lt;:built&gt;, id: nil,
    inserted_at: nil, percentage: nil,
    person: #ecto.Association.NotLoaded&lt;association :person is not loaded&gt;,
    person_id: nil,
    star: #ecto.Association.NotLoaded&lt;association :star is not loaded&gt;,
    star_id: nil, updated_at: nil}, optional: [], opts: [],
   params: %{"percentage" =&gt; 0.513657, "person_id" =&gt; 55, "star_id" =&gt; 1},
   prepare: [], repo: nil, required: [:percentage, :person_id, :star_id],
   types: %{id: :id, inserted_at: Ecto.DateTime, percentage: :float,
     person_id: :id, star_id: :id, updated_at: Ecto.DateTime}, valid?: true,
   validations: []}
  </code></pre>
  
  <p>I'm not sure what happened or if I made a change along the way because this was working previously. The error seems to suggest I need a person_id, which I do.</p>
  
  <p>Edit: As requested the function call I'm making for the match insert</p>
  
  <pre><code>...
  Repo.transaction(fn -&gt;
    case Repo.insert(person_changeset) do
    {:ok, person} -&gt;
       Match.create(person.id)
    {:error, _}
       Repo.rollback(:no_bueno)
    end
  end)
  
  def create(person_id) do
    ...
    params = %{"person_id" =&gt; person.id, "percentage" =&gt; percentage, "star_id" =&gt; star.id}
    changeset = __MODULE__.changeset(%__MODULE__{}, params)
    case Repo.insert(changeset) do
    {:ok, _person} -&gt;
       IO.puts "success"
    {:error, _changeset} -&gt;
       Repo.rollback(:no_bueno)
    end
  end
  </code></pre>