How to run an anonymise.exs file to anonymise user data in database

How to run an anonymise.exs file to anonymise user data in database.

I have a .exs file which anonymise user data in database. But I am not sure how to execute the file.
Can anyone help me on it please.

What have you tried so far, what error did you get?


Hi Ben…I am able to run the .exs file in my local using mix command.

How to run the mix command in a particular environment like QA, PreProduction, Production.

I don’t really recommend running arbitrary elixir scripts in production. If an environment should not have user data, it should be anonymized before it ends up in that environment. To do anonymization for QA and pre-production environments at my company, we have a server where we create an export of production data, load that into a temporary database, and then I run the anonymization routine as a mix task. After that we create a dump of the now anonymous database, and load that into staging / QA.

Thanks Ben…but still my question is now to run a command like below

mix run priv/repo/anonymise.exs

in a QA environment. how to run mix task in case of an environment. In local, I goto my project directory where the mix.exs file is present and I can run successfully.

How do you implement your QA environment? Are you using releases? Do you have distinct mix environments?

Yes Ben you are correct, we have a dev.exs file for local and release.exs file for different environments.
Can we use the release.exs somehow to run mix commands in environments. Thanks.

If you are running a release in QA, mix is no longer available. Instead use:

I would be extremely cautious about baking in code like this into your releases however, because there’s a chance you’ll accidentally run it in production.