/
[console] Anonymizing database command

[console] Anonymizing database command

Usually there are dummy e-mails on staging server and it's ok, but at some point client might enter real e-mails there. This becomes a problem when developer decides to pick up fresh database from staging server and during his tests on local machine will send out e-mail to real person (e.g. client) with some test data. Some clients are particularly unhappy, when this happens.

Currently employed solution is to use DBG_EMAIL setting (only works, when Debug Mode is turned on), that will:

  • either send all e-mails to given e-mail address
  • or replace "@" with "_at_" and append given domain at the end

In either way live people won't be getting these e-mail, but whoever owns that new e-mail account will be able to test what is received. Unfortunately, as mentioned before, it only works in debug mode and if debug mode is turned off real people are getting those e-mails again.

Solution

Add new "db:anonymize" command, that will scan all database for text that looks like e-mail (hopefully database is small enough) and replaces them based on DBG_EMAIL setting value.

Implementation details:

  • create IDatabaseAnonymizer interface with "anonymizeDatabase()" method
  • whoever wants (e.g. each module or unit) create a class (or use existing class), that would implement that interface and in that method anonymize it's own tables (e.g. mangle usernames, e-mail, anything else)
  • or we can create base abstract class with some helper methods and let sub-class it and then discover sub-classes

Related Tasks