I would like to drop all foreign keys associated to a table.
I first identify the foreign keys associated to it using the below
SELECT DISTINCT constraint_name
FROM information_schema.key_column_usage
WHERE table_name = 'crm_campaign_offer_customer_groups'
AND table_schema = 'schema001'
AND constraint_name LIKE '%fkey%'
Then loop through each of these deleting the foreign keys using a statement like
ALTER TABLE crm_campaign_offer_customer_groups DROP CONSTRAINT crm_campaign_offer_customer_groups_variable_1_fkey1;
The issue that is occurring is that it first truncates the foreign key expression then tries to drop the truncated expression
NOTICE: identifier "..." will be truncated to "..."
ERROR: constraint "..." of relation "..." does not exist
It seems that it is truncating identifiers > 63 characters, but I'm hoping there is an alternative as the table and variable naming conventions are already set
crm_campaign_offer_customer_groups_variable_1_fkey1is only 51... you seem to have built postgres withNAMEDATALENmore the default and then upgraded it?.. Otherwise I dont see how you created long names in first place. it should have truncated the name onADD CONSTRAINT, so you would not have long name ininformation_schema.key_column_usageRETURNS SETOF "TABLE(seq integer, path_id integer, path_seq integer, node bigint, edge bigint, cost double precision, agg_cost double precision)": ` identifier "TABLE(seq..." will be truncated to... ` and thenERROR: type "TABLE(seq integer, path_id integer, path_seq integer, node bigi" does not exist