Anonymise customer first and last names

These were added a couple of years ago in https://github.com/openfoodfoundation/openfoodnetwork/pull/8763
But I guess we never noticed the names weren't getting anonymised.

The old 'name' field is still in the DB. It was kept for compatibility during migraiton but never cleaned up. I've added the tech debt task to the welcome new devs board now: https://github.com/openfoodfoundation/openfoodnetwork/issues/8835
This commit is contained in:
David Cook
2024-09-16 11:42:58 +10:00
parent 68491559f3
commit 9c51615b03

View File

@@ -46,10 +46,14 @@ namespace :ofn do
unconfirmed_email = concat(id, '_ofn_user@example.com')")
Customer.where(user_id: nil)
.update_all("email = concat(id, '_ofn_customer@example.com'),
name = concat('Customer Number ', id, ' (without connected User)')")
name = concat('Customer Number ', id, ' (without connected User)'),
first_name = concat('Customer Number ', id),
last_name = '(without connected User)'")
Customer.where.not(user_id: nil)
.update_all("email = concat(user_id, '_ofn_user@example.com'),
name = concat('Customer Number ', id, ' - User ', user_id)")
name = concat('Customer Number ', id, ' - User ', user_id),
first_name = concat('Customer Number ', id),
last_name = concat('User ', user_id)")
Spree::Order.update_all("email = concat(id, '_ofn_order@example.com')")
end