mirror of
https://github.com/Unleash/unleash.git
synced 2025-10-13 11:17:26 +02:00
#10121 points out that we're using md5 functions still. This PR updates our migrations to no longer use md5 at all (so if you haven't run the migrations, you won't get email hashes until you get to the included migration with this PR). If you've already run the migrations, we'll drop the existing `email_hash varchar(32)` column and replace it with a `email_hash TEXT` column. We're also replacing the md5 function with `encode(sha256(email), 'hex')`. encode has been supported since PG10, sha256 came with PG11. Do we want an index on the email_hash? I wasn't sure, but if we want to do lookup we probably should have an index on it (though not a unique one)
16 lines
264 B
JavaScript
16 lines
264 B
JavaScript
exports.up = (db, cb) => {
|
|
db.runSql(`
|
|
ALTER TABLE users
|
|
ADD COLUMN IF NOT EXISTS email_hash VARCHAR(32);
|
|
`, cb);
|
|
|
|
};
|
|
|
|
exports.down = (db, cb) => {
|
|
db.runSql(`
|
|
ALTER TABLE users
|
|
DROP COLUMN IF EXISTS email_hash;
|
|
`, cb);
|
|
};
|
|
|