Skip to content

Commit

Permalink
tweak script
Browse files Browse the repository at this point in the history
  • Loading branch information
dholms committed Nov 8, 2023
1 parent 1a99165 commit 0bc2542
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions packages/pds/src/migrate-script/migrate-all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ const migrateRepo = async (
adminHeaders,
)
status.importedRev = importedRev
status.phase = TransferPhase.transferredPds
await updateStatus(db, status)
}

if (status.phase < TransferPhase.transferredEntryway) {
await updatePdsOnEntryway(ctx, pds, status.did)
status.phase = TransferPhase.transferredEntryway
await updateStatus(db, status)
}
Expand Down Expand Up @@ -271,30 +277,31 @@ const lockAndTransfer = async (
{ headers: adminHeaders },
)

status.phase = TransferPhase.transferredPds
await updateStatus(db, status)

transferDefer.resolve()

await ctx.db.transaction(async (dbTxn) => {
await dbTxn.db
.updateTable('user_account')
.where('did', '=', status.did)
.set({ pdsId: pds.id })
.execute()
await dbTxn.db
.updateTable('repo_root')
.where('did', '=', status.did)
.set({ did: `migrated-${status.did}` })
.execute()
})

return importedRev
} finally {
transferDefer.resolve()
}
}

const updatePdsOnEntryway = async (
ctx: AppContext,
pds: PdsInfo,
did: string,
) => {
await ctx.db.transaction(async (dbTxn) => {
await dbTxn.db
.updateTable('user_account')
.where('did', '=', did)
.set({ pdsId: pds.id })
.execute()
await dbTxn.db
.updateTable('repo_root')
.where('did', '=', did)
.set({ did: `migrated-${did}` })
.execute()
})
}

const transferPreferences = async (
ctx: AppContext,
pds: PdsInfo,
Expand Down

0 comments on commit 0bc2542

Please sign in to comment.