Automatically remove PowerDNS records when removing domain
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