Automatically remove PowerDNS records when removing domain

Posted by Frodo Larik Mon, 29 Dec 2008 20:39:00 GMT

When you want to remove a domain from PowerDNS and you’re using postgresql, you can save your self one query:

Normally you’ll do something like:

DELETE FROM rules where domain_id=666
DELETE FROM domains where id=666;

But when you create a rule in postgresql, you’ll only have to do this:

DELETE FROM domains where id=666;

Here’s how to create the rule.

CREATE OR REPLACE RULE remove_records AS 
   ON DELETE TO domains DO      
DELETE FROM records WHERE records.domain_id = old.id; 

For more information, see the PostgreSQL documentation about rules

Trackbacks

Use the following link to trackback from your own site:
http://blog.larik.nl/trackbacks?article_id=10339