[Pdns-users] Cascading Deletes (MySQL)

Mark Watts m.watts at eris.qinetiq.com
Fri Apr 21 10:10:29 UTC 2006


Not sure how useful this will be to people, but its a trick I've used on a few 
nameservers we have here and thought it useful to share.

When you create the "records" table in MySQL, add the following line:

CONSTRAINT `records_ibfk_1` FOREIGN KEY (`domain_id`) REFERENCES `domains` 
(`id`) ON DELETE CASCADE

(This implies you're using the InnoDB table type.)

What this does is to automatically delete all records for a domain when the 
domain entry is removed from the "domains" table, thus being a more reliable 
way to clean up when you no-longer host a domain.

Cheers,

Mark.

-- 
Mark Watts BSc RHCE
Senior Systems Engineer
QinetiQ Trusted Information Management
Trusted Solutions and Services Group
GPG Public Key ID: 455420ED



More information about the Pdns-users mailing list