From 3fc5b59370cbab1552b9817bacbb1db912cb94aa Mon Sep 17 00:00:00 2001 From: Twan Driessen Date: Thu, 13 Apr 2023 18:09:56 +0200 Subject: [PATCH 1/3] feature: upgrade phpunit version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 687ec46..8f78286 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,7 @@ "minimum-stability": "dev", "prefer-stable": true, "require-dev": { - "phpunit/phpunit": "^7.2" + "phpunit/phpunit": "^8" }, "config": { "allow-plugins": { From 9ff38f96fba79379936ebacbe3b0c5410fcddeae Mon Sep 17 00:00:00 2001 From: Twan Driessen Date: Thu, 13 Apr 2023 18:10:14 +0200 Subject: [PATCH 2/3] feature: expand the README --- README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cfea2ab..7ddcc73 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,8 @@ and can in principle dump any database that PDO supports. ## How to use +*Scroll down a bit for usage with Drush.* + There are presently two ways of manipulating data, the first is by manipulating the actual SQL queries that are run on the server (given by the gdpr-expressions path), and the second is by replacing column output before the dump is generated (given by the gdpr-replacements option). @@ -75,7 +77,7 @@ You can also save replacements mapping to JSON file and use it with `--gdpr-repl ## Use with drush As this mimicks mysqldump, it can be use with drush, backup_migrate and any tool that uses mysqldump. -Drush example: +Example for your local Docker instance: ``` $ export PATH=/var/www/html/vendor/bin:$PATH @@ -84,6 +86,14 @@ $ which mysqldump $ drush sql-dump --tables-list=users_field_data --extra-dump=$'--gdpr-expressions=\'{"users_field_data":{"name":"uid","mail":"uid","init":"uid","pass":"\\"\\""}}\' --debug-sql' ``` +On Staging, Accept or Production environments you probably want to do the following (replace `environment.nl`): +``` +$ export PATH=/data/www/environment.nl/current/vendor/bin/mysqldump:$PATH +$ pwd +/data/www/environment.nl/current +$ drush sql-dump --extra-dump='--gdpr-replacements-file=../gdpr-replacements.json' --result-file=gdpr-dump.sql +``` +If your project does not have a `gdpr-replacements.json` please use the template from this project and add one. ### MySqlOptions file You are able to have your gdpr-expressions/replacement options set in a mysql options file file. From ffdaf3bb91c629c4ca6c01492c2c10ee3d4060ac Mon Sep 17 00:00:00 2001 From: Twan Driessen Date: Thu, 13 Apr 2023 18:10:36 +0200 Subject: [PATCH 3/3] feature: gdpr-replacements template --- gdpr-replacements-template.json | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 gdpr-replacements-template.json diff --git a/gdpr-replacements-template.json b/gdpr-replacements-template.json new file mode 100644 index 0000000..dfcf2bb --- /dev/null +++ b/gdpr-replacements-template.json @@ -0,0 +1,20 @@ +{ + "users_field_data": { + "name": {"formatter": "clear"}, + "mail": {"formatter": "email"}, + "init": {"formatter": "clear"}, + "pass": {"formatter": "clear"}, + "_exclude": {"mail": ["*@uncinc.nl"], "uid": ["0", "1"]} + }, + "profile__field_address": { + "field_address_locality": {"formatter": "city"}, + "field_address_dependent_locality": {"formatter": "clear"}, + "field_address_postal_code": {"formatter": "postcode"}, + "field_address_address_line1": {"formatter": "streetName"}, + "field_address_address_line2": {"formatter": "buildingNumber"} + }, + "profile__field_first_name": { + "field_first_name_value": {"formatter": "firstName"} + } +} +