1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-10-18 11:14:57 +02:00
unleash.unleash/src/migrations/20241112113555-user-email-hash.js
Jaanus Sellin c8bc40146a
feat: email will be stored hashed now for all users (#8720)
Adding email_hash column to users table.
We will update all existing users to have hashed email. 
All new users will also get the hash.

We are fine to use md5, because we just need uniqueness. We have emails
in events table stored anyways, so it is not sensitive.
2024-11-12 13:28:19 +02:00

19 lines
325 B
JavaScript

exports.up = (db, cb) => {
db.runSql(`
ALTER TABLE users
ADD COLUMN IF NOT EXISTS email_hash VARCHAR(32);
UPDATE users
SET email_hash = md5(email::text);
`, cb);
};
exports.down = (db, cb) => {
db.runSql(`
ALTER TABLE users
DROP COLUMN IF EXISTS email_hash;
`, cb);
};