0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-04-15 03:01:37 -05:00

Added migration to populate missing uuid fields

no-issue

This is to ensure that all members have a uuid
This commit is contained in:
Fabien O'Carroll 2019-11-05 17:58:09 +07:00
parent f2709964ae
commit cd6de74010

View file

@ -0,0 +1,22 @@
const common = require('../../../../lib/common');
const uuid = require('uuid');
module.exports = {
config: {
transaction: true
},
async up(options) {
const conn = options.connection || options.transacting;
const membersWithoutUUID = await conn.select('id').from('members').whereNull('uuid');
common.logging.info(`Adding uuid field value to ${membersWithoutUUID.length} members.`);
for (const member of membersWithoutUUID) {
await conn('members').update('uuid', uuid.v4()).where('id', member.id);
}
},
async down() {
// noop
}
};