Qfix: final account migration adjustments (#6801)

Signed-off-by: Alexey Zinoviev <alexey.zinoviev@xored.com>
This commit is contained in:
Alexey Zinoviev 2024-10-03 19:29:06 +04:00 committed by GitHub
parent eb66c36892
commit e09a24cbc1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -154,12 +154,20 @@ export async function moveAccountDbFromMongoToPG (
delete (pgAccount as any).workspaces delete (pgAccount as any).workspaces
if (pgAccount.createdOn === undefined) { if (pgAccount.createdOn == null) {
pgAccount.createdOn = Date.now() pgAccount.createdOn = Date.now()
} }
for (const workspace of mongoAccount.workspaces) { if (pgAccount.first == null) {
workspaceAssignments.push([pgAccount._id, workspace.toString()]) pgAccount.first = 'NotSet'
}
if (pgAccount.last == null) {
pgAccount.last = 'NotSet'
}
for (const workspaceString of new Set(mongoAccount.workspaces.map((w) => w.toString()))) {
workspaceAssignments.push([pgAccount._id, workspaceString])
} }
const exists = await getAccount(pgDb, pgAccount.email) const exists = await getAccount(pgDb, pgAccount.email)
@ -175,6 +183,10 @@ export async function moveAccountDbFromMongoToPG (
_id: mongoWorkspace._id.toString() _id: mongoWorkspace._id.toString()
} }
if (pgWorkspace.createdOn == null) {
pgWorkspace.createdOn = Date.now()
}
// delete deprecated fields // delete deprecated fields
delete (pgWorkspace as any).createProgress delete (pgWorkspace as any).createProgress
delete (pgWorkspace as any).creating delete (pgWorkspace as any).creating