Shinji Kuwayama

02 Dec, 2008

Munging production data

Posted by: Shinji Kuwayama In: Rails

It’s occasionally necessary to load up a production database dump locally, for troubleshooting purposes. Here’s a query I keep handy, for the purpose of munging the user accounts — you wouldn’t want actual customer data sitting around on your local machine.

update users
set email = concat(MD5(RAND()), '@example.com'),
crypted_password = 'c51cb1acc88d17b00950fe1d116980cfabbdf96a',
salt = "44f553a7cc4b41dff01e8ec1d86b1fb9f8ee81be";

This gives every user a random example.com email address, and sets their password to “password”.

This is just an example, of course — you’ll run into reasons to do this slightly differently.

No Responses to "Munging production data"

Comment Form

About

View Shinji Kuwayama's profile on LinkedIn Shinji Kuwayama is a Rails developer in Chicago, Illinois.

Twitter

Posting tweet...