From: Peter Thomassen Date: Mon, 20 Feb 2017 10:26:05 +0000 (+0100) Subject: docs: improve documentation of MySQL foreign keys X-Git-Tag: rec-4.1.0-alpha1~270^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F5006%2Fhead;p=thirdparty%2Fpdns.git docs: improve documentation of MySQL foreign keys So far, the docs mentioned the foreign key for the records table only. However, if foreign keys are used, they also make sense for the domainmetadata, cryptokeys, and comments tables. Corresponding SQL is already in an .sql file in the repository. This commit replaces the incomplete information with these statements. --- diff --git a/docs/markdown/authoritative/backend-generic-mysql.md b/docs/markdown/authoritative/backend-generic-mysql.md index 40ef860baf..6cb122194e 100644 --- a/docs/markdown/authoritative/backend-generic-mysql.md +++ b/docs/markdown/authoritative/backend-generic-mysql.md @@ -24,23 +24,14 @@ with the `--gmysql` flag also assumes this layout is in place. For full migratio notes, please see [Migration](migration.md). This schema contains all elements needed for master, slave and superslave operation. -When using the InnoDB storage engine, we suggest adding the following lines to -the 'create table records' command above: - -``` -CONSTRAINT `records_ibfk_1` FOREIGN KEY (`domain_id`) REFERENCES `domains` -(`id`) ON DELETE CASCADE -``` - -Or, if you have already created the tables, execute: - +When using the InnoDB storage engine, we suggest adding foreign key contraints +to the tables in order to automate deletion of records, key material, and other +information upon deletion of a domain from the domains table. The following SQL +does the job: ``` -ALTER TABLE `records` ADD CONSTRAINT `records_ibfk_1` FOREIGN KEY (`domain_id`) -REFERENCES `domains` (`id`) ON DELETE CASCADE; +!!include=../modules/gmysqlbackend/enable-foreign-keys.mysql.sql ``` -This automates deletion of records on deletion of a domain from the domains table. - # Using MySQL replication To support `NATIVE` domains, the `binlog_format` for the MySQL replication **must** be set to `MIXED` or `ROW` to prevent differences in data between replicated