mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-30 20:25:38 +00:00
Qfix doc updates migration (#7984)
Signed-off-by: Alexey Zinoviev <alexey.zinoviev@xored.com>
This commit is contained in:
parent
2a772d3837
commit
f7792fb9ae
@ -249,9 +249,9 @@ async function migrateAccountsInDocUpdates (client: MigrationClient): Promise<vo
|
||||
au: DocAttributeUpdates,
|
||||
update: MigrateUpdate<DocUpdateMessage>['attributeUpdates'],
|
||||
field: P
|
||||
): boolean {
|
||||
): void {
|
||||
const oldValue = au?.[field]
|
||||
if (oldValue == null) return false
|
||||
if (oldValue == null) return
|
||||
|
||||
let changed = false
|
||||
let newValue: any
|
||||
@ -275,8 +275,6 @@ async function migrateAccountsInDocUpdates (client: MigrationClient): Promise<vo
|
||||
|
||||
update[field] = newValue
|
||||
}
|
||||
|
||||
return changed
|
||||
}
|
||||
|
||||
const iterator = await client.traverse(DOMAIN_ACTIVITY, {
|
||||
@ -301,15 +299,14 @@ async function migrateAccountsInDocUpdates (client: MigrationClient): Promise<vo
|
||||
for (const doc of docs) {
|
||||
const dum = doc as DocUpdateMessage
|
||||
if (dum.attributeUpdates == null) continue
|
||||
let changed = false
|
||||
const update: any = { attributeUpdates: { ...dum.attributeUpdates } }
|
||||
|
||||
changed = migrateField(dum.attributeUpdates, update.attributeUpdates, 'added') || changed
|
||||
changed = migrateField(dum.attributeUpdates, update.attributeUpdates, 'prevValue') || changed
|
||||
changed = migrateField(dum.attributeUpdates, update.attributeUpdates, 'removed') || changed
|
||||
changed = migrateField(dum.attributeUpdates, update.attributeUpdates, 'set') || changed
|
||||
migrateField(dum.attributeUpdates, update.attributeUpdates, 'added')
|
||||
migrateField(dum.attributeUpdates, update.attributeUpdates, 'prevValue')
|
||||
migrateField(dum.attributeUpdates, update.attributeUpdates, 'removed')
|
||||
migrateField(dum.attributeUpdates, update.attributeUpdates, 'set')
|
||||
|
||||
if (!changed) continue
|
||||
update.attributeUpdates.attrClass = core.class.TypePersonId
|
||||
|
||||
operations.push({
|
||||
filter: { _id: dum._id },
|
||||
@ -379,7 +376,7 @@ export const activityOperation: MigrateOperation = {
|
||||
func: migrateAccountsToSocialIds
|
||||
},
|
||||
{
|
||||
state: 'accounts-in-doc-updates',
|
||||
state: 'accounts-in-doc-updates-v2',
|
||||
func: migrateAccountsInDocUpdates
|
||||
}
|
||||
])
|
||||
|
Loading…
Reference in New Issue
Block a user