title: postgres key is not present in table constraint
body: <p>When trying to ALTER TABLE in Postgres 9.5 to create foreign key constraint: from <code>product_template.product_brand_id</code> to <code>product_brand.id</code> </p>
  
  <pre><code>ALTER TABLE public.product_template
      ADD CONSTRAINT product_template_product_brand_id_fkey 
      FOREIGN KEY (product_brand_id)
      REFERENCES public.product_brand (id) MATCH SIMPLE
      ON UPDATE NO ACTION
      ON DELETE SET NULL;
  </code></pre>
  
  <p>Returns error</p>
  
  <pre><code>ERROR:  insert or update on table "product_template" violates foreign key         constraint "product_template_product_brand_id_fkey"
  DETAIL:  Key (product_brand_id)=(12) is not present in table "product_brand".
  STATEMENT:  ALTER TABLE "product_template" ADD FOREIGN KEY ("product_brand_id") REFERENCES "product_brand" ON DELETE set null
  </code></pre>
  
  <p>Im confused why postgres is trying to find <code>product_brand.product_brand_id</code>, when the fkey is from <code>product_template.product_brand_id</code> to <code>product_brand.id</code> </p>
  
  <p>Any ideas?</p>