nixys / nxs-data-anonymizer

A tool for anonymizing PostgreSQL and MySQL databases' dump
Apache License 2.0
233 stars 10 forks source link

Delete rows during anonymization #44

Open borisershov opened 2 months ago

borisershov commented 2 months ago

Add one more additional filter function {{ drop }}. This function (like {{ null }} function that set column value to NULL) will drop whole row. Another words if table has filters for several columns and at least one of them returns drop value - whole row will be skipped during the anonymization process.

For example:

filters:
  orders:
    columns:
      company_id:
        value: "{{ if eq .Values.company_id \"1\" }}{{ .Values.company_id }}{{ else }}{{ drop }}{{ end }}"
      name:
        type: command
        value: /path/to/script.sh
        unique: true

With this config file nxs-data-anonymizer drop all rows in orders table excluding row with company_id == 1 (and name field in this row will be anonymized with /path/to/script.sh script).

P.S. You should be careful when using foreign keys in your database.

Issue source: https://t.me/nxs_data_anonymizer_chat/128