humanmade / go-anonymize-mysqldump

Allows you to pipe data from mysqldump or an SQL file and anonymize it.
GNU General Public License v3.0
60 stars 26 forks source link

Ability to skip rows #9

Open Lusitaniae opened 4 years ago

Lusitaniae commented 4 years ago

We're currently using production database in dev.

We plan to improve it by anonymizing the user data.

However we have some test/dev/admin accounts with a variety of roles and associated data which we want to preserve.

Would be nice being able to skip any transformation to a row if a condition matches. Example config we'd use to achieve this

      "tableName": "users",
      "ignore": [
        {
          "field": "mail",
          "position": 6,
          "value": "account1@domain.com"
        },
        {
          "field": "mail",
          "position": 6,
          "value": "account1@domain.com"
        }
      ],
      "fields": [

As a work around:

We take 2 mysqldumps, the first one with all data going through anonymization.

The 2nd dump is appended to the original with "REPLACE INTO" queries with the users we plan to keep as is.

mysqldump --no-create-info --where "email like '%admin.com'" --replace application user_data > own_users.sql