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:
parent
f2709964ae
commit
cd6de74010
1 changed files with 22 additions and 0 deletions
|
@ -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
|
||||
}
|
||||
};
|
Loading…
Add table
Reference in a new issue