@@ -378,7 +378,11 @@ export function makeMigration<
378378 try {
379379 const next = await migrateOne ( ctx , doc ) ;
380380 if ( next && Object . keys ( next ) . length > 0 ) {
381- await ctx . db . patch ( doc . _id as GenericId < TableName > , next ) ;
381+ await ctx . db . patch (
382+ table ,
383+ doc . _id as GenericId < TableName > ,
384+ next ,
385+ ) ;
382386 }
383387 } catch ( error ) {
384388 console . error ( `Document failed: ${ doc . _id } ` ) ;
@@ -395,7 +399,7 @@ export function makeMigration<
395399 if ( args . dryRun ) {
396400 // Throwing an error rolls back the transaction
397401 for ( const before of page ) {
398- const after = await ctx . db . get ( page [ 0 ] ! . _id as any ) ;
402+ const after = await ctx . db . get ( table , page [ 0 ] ! . _id as any ) ;
399403 if ( JSON . stringify ( before ) === JSON . stringify ( after ) ) {
400404 continue ;
401405 }
@@ -414,7 +418,8 @@ export function makeMigration<
414418 // 2. The migration is being resumed at a different cursor.
415419 // 3. There are two instances of the same migration racing.
416420 const worker =
417- state . workerId && ( await ctx . db . system . get ( "_scheduled_functions" , state . workerId ) ) ;
421+ state . workerId &&
422+ ( await ctx . db . system . get ( "_scheduled_functions" , state . workerId ) ) ;
418423 if (
419424 worker &&
420425 ( worker . state . kind === "pending" ||
@@ -631,7 +636,8 @@ export async function getStatus<
631636 docs . reverse ( ) . map ( async ( migration ) => {
632637 const { workerId, isDone } = migration ;
633638 if ( isDone ) return migration ;
634- const worker = workerId && ( await ctx . db . system . get ( "_scheduled_functions" , workerId ) ) ;
639+ const worker =
640+ workerId && ( await ctx . db . system . get ( "_scheduled_functions" , workerId ) ) ;
635641 return {
636642 ...migration ,
637643 workerStatus : worker ?. state . kind ,
@@ -669,7 +675,9 @@ export async function cancelMigration<DataModel extends GenericDataModel>(
669675 if ( state . isDone ) {
670676 return state ;
671677 }
672- const worker = state . workerId && ( await ctx . db . system . get ( "_scheduled_functions" , state . workerId ) ) ;
678+ const worker =
679+ state . workerId &&
680+ ( await ctx . db . system . get ( "_scheduled_functions" , state . workerId ) ) ;
673681 if (
674682 worker &&
675683 ( worker . state . kind === "pending" || worker . state . kind === "inProgress" )
0 commit comments