Bug #18202

Candlepin tables are missing primary key

Added by Karlis Melderis over 5 years ago. Updated almost 4 years ago.

Target version:
Bugzilla link:
Pull request:
Fixed in Releases:
Found in Releases:
Red Hat JIRA:


I found that set of candlepin tables don't have primary key thus I cannot move DB to Postgress BDR (updates and deletes are denied)

Here are keys I added

\d+ cp_consumer_content_tags
ALTER TABLE cp_consumer_content_tags ADD PRIMARY KEY (consumer_id, content_tag);
\d+ cp_content_modified_products;
ALTER TABLE cp_content_modified_products ADD PRIMARY KEY (cp_content_id, element);
\d+ cp_pool_branding
ALTER TABLE cp_pool_branding ADD PRIMARY KEY (pool_id, branding_id);
\d+ cp_product_dependent_products
ALTER TABLE cp_product_dependent_products ADD PRIMARY KEY (cp_product_id, element);
\d+ cp_sub_branding
ALTER TABLE cp_sub_branding ADD PRIMARY KEY (subscription_id, branding_id);
\d+ cp_sub_derivedprods
ALTER TABLE cp_sub_derivedprods ADD PRIMARY KEY (subscription_id, product_id);
\d+ databasechangelog
ALTER TABLE databasechangelog ADD PRIMARY KEY (id);


#1 Updated by Dominic Cleal over 5 years ago

  • Legacy Backlogs Release (now unused) deleted (213)

#2 Updated by Justin Sherrill over 5 years ago

  • Status changed from New to Rejected
  • Legacy Backlogs Release (now unused) set to 166

I chatted with the candlepin team and this is what they said:

First and foremost, while adding a primary key is preferred on paper, I seem to recall Hibernate doing silly
things like adding a duplicate row and then deleting the old one when doing some updates or some such.

Having a primary key or unique constraint may cause some headaches.
The databasechangelog table is something managed by liquibase, so I'd be reluctant to mess with that at all,
but it's likely more safe/sane than the ones Hibernate fiddles with.

And, finally, cp_product_dependent_products, cp_sub_branding and cp_sub_derivedprods no longer exist in cp2.
cp_product_dependent_products is cp2_product_dependent_products and has the same missing-primary-key issue.

I would suggest filing this issue over at candlepin's bugzilla:

I'm gonna go ahead and close this as there isn't anything katello can do sadly :(

Also available in: Atom PDF