ankane/pgsync

Conditional Data Rules

onwardmk opened this issue · 2 comments

Is there a way to conditionally anonymize data?

In most cases, I want to do this:

data_rules:
  users.email: unique_email
  users.last_name:
    statement: "random_last_name()"
  users.encrypted_password:
    value: "$2a$10$EknBYSZS0IkaL6ilYmB9S.6lQCYn.KVY1VsDgMes2ghrcY3ZKvETO"
  users.phone: unique_phone
  users.phone_normalized: unique_phone

Except for users where the email ends in "@somedomain.com." Is this possible?

Hi @onwardmk, you can use statement for this:

data_rules:
  email:
    statement: "CASE WHEN email LIKE '%@somedomain.com' THEN email ELSE 'email' || id || '@example.org' END"

Hi @onwardmk, you can use statement for this:

data_rules:

  email:

    statement: "CASE WHEN email LIKE '%@somedomain.com' THEN email ELSE 'email' || id || '@example.org' END"

@ankane Thank you for the response. Is there a way to use unique_email in the statement? I created a SQL function for random_last_name(), but would like to avoid having to do this for multiple fields if possible.