Skip to content

a8n: Non-manual Campaigns cannot be deleted due to foreign-key constraint

Created by: mrnugget

When trying to delete a Campaign in the UI that has ChangesetJobs (and Changesets) I get the following message:

pq: update or delete on table "campaigns" violates foreign key constraint "changeset_jobs_campaign_id_fkey" on table "changeset_jobs"

I think we have two options. We either

  1. change the campaign_id column definition on changeset_jobs to have a DELETE CASCADE
  2. we change the deleteCampaign mutation to load the ChangesetJobs from the database and delete them manually (while we're at it, we could also delete the CampaignPlan and its CampaignJobs in the same transaction)