Skip to content

Instantly share code, notes, and snippets.

@johnpmitsch
Last active February 6, 2017 18:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnpmitsch/af158851ddf1403a42343472a5b1d273 to your computer and use it in GitHub Desktop.
Save johnpmitsch/af158851ddf1403a42343472a5b1d273 to your computer and use it in GitHub Desktop.
candlepin ueber cert - clear associated content when deleting ueber cert
To delete ueber cert: https://access.redhat.com/solutions/1609643
related to:
https://bugzilla.redhat.com/show_bug.cgi?id=1418376
Clearing associated content:
SELECT (SELECT Count(*)
FROM cp_subscription s
INNER JOIN cp_product p
ON s.product_id = p.id
WHERE p.NAME LIKE '%_ueber_product') AS UEBER_SUBS,
(SELECT Count(*)
FROM cp_ent_certificate ec
INNER JOIN cp_entitlement e
ON e.id = ec.entitlement_id
INNER JOIN cp_pool p
ON e.pool_id = p.id
WHERE p.productname LIKE '%_ueber_product') AS UEBER_ENT_CERTS,
(SELECT Count(*)
FROM cp_entitlement e
INNER JOIN cp_pool p
ON e.pool_id = p.id
WHERE p.productname LIKE '%_ueber_product') AS UEBER_ENTS,
(SELECT Count(*)
FROM cp_pool p WHERE p.productname LIKE '%_ueber_product') AS UEBER_POOLS,
(SELECT Count(*)
FROM cp_content c
INNER JOIN cp_product_content pc
ON pc.content_id = c.id
INNER JOIN cp_product p
ON p.id = pc.product_id
WHERE p.NAME LIKE '%_ueber_product') AS UEBER_CONTENT,
(SELECT Count(*)
FROM cp_product
WHERE NAME LIKE '%_ueber_product') AS UEBER_PRODUCTS,
(SELECT Count(*)
FROM cp_consumer
WHERE NAME = 'ueber_cert_consumer') AS UEBER_CONSUMER;
then if more than 0 counts in each, run:
delete from cp_subscription where id in (select s.id from cp_subscription s inner join cp_product p on s.product_id = p.id where p.name LIKE '%_ueber_product');
delete from cp_ent_certificate where entitlement_id in (select e.id from cp_entitlement e inner join cp_pool p on e.pool_id = p.id where p.productname LIKE '%_ueber_product');
delete from cp_entitlement where pool_id in (select id from cp_pool p where p.productname LIKE '%_ueber_product');
delete from cp_pool where productname like '%_ueber_product%';
delete from cp_content where id in (select id from cp_content where name = 'ueber_content');
delete from cp_product where name like '%_ueber_product';
delete from cp_consumer where name = 'ueber_cert_consumer';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment