title: Should I temporarily disable foreign key constraints? How?
body: <p>I have two tables:</p>
  
  <pre><code>person:
      id serial primary key,
      name varchar(64) not null
  
  task:
      tenant_id   integer not null references person (id) on delete cascade,
      customer_id integer not null references person (id) on delete restrict
  </code></pre>
  
  <p>(They have a lot more columns than that, but the rest aren't relevant to the question.)</p>
  
  <p>The problem is, I want to cascade-delete a <code>task</code> when its tenant <code>person</code> is deleted. But when the tenant and the customer are the same person, the <code>customer_id</code> foreign key constraint will restrict deletion.</p>
  
  <p>My question has two parts:</p>
  
  <ol>
  <li>Is temporarily disabling the second foreign key my only option?</li>
  <li>If so, then how do I do that in PostgreSQL?</li>
  </ol>