From 1f4221bb63549b3f2a038c4146cfbc7383fb1fbe Mon Sep 17 00:00:00 2001 From: mantikoros Date: Mon, 18 Apr 2022 15:53:13 -0500 Subject: [PATCH] migration: error checking --- functions/src/scripts/migrate-to-cfmm.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/functions/src/scripts/migrate-to-cfmm.ts b/functions/src/scripts/migrate-to-cfmm.ts index 479d4ab0..c9ad8bfa 100644 --- a/functions/src/scripts/migrate-to-cfmm.ts +++ b/functions/src/scripts/migrate-to-cfmm.ts @@ -29,6 +29,12 @@ async function recalculateContract(contractRef: DocRef, isCommit = false) { await firestore.runTransaction(async (transaction) => { const contractDoc = await transaction.get(contractRef) const contract = contractDoc.data() as FullContract + + if (!contract?.slug) { + console.log('missing slug; id=', contractRef.id) + return + } + console.log('recalculating', contract.slug) if ( @@ -137,7 +143,9 @@ async function main() { ) for (let contractRef of contractRefs) { - await recalculateContract(contractRef, isCommit) + await recalculateContract(contractRef, isCommit).catch((e) => + console.log('error: ', e, 'id=', contractRef.id) + ) console.log() console.log() }