Skip to content

Commit dab6f69

Browse files
committed
Fix match in backfill script, remove batching
1 parent d6af842 commit dab6f69

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

src/components/product/migrations/backfill-empty-mediums.migration.ts

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { groupBy } from '@seedcompany/common';
22
import { node } from 'cypher-query-builder';
3-
import { chunk, uniq } from 'lodash';
3+
import { uniq } from 'lodash';
44
import { ID } from '~/common';
55
import { BaseMigration, Migration } from '~/core/database';
66
import { updateProperty, variable } from '~/core/database/query';
77
import { ProductMedium as Medium, Product } from '../dto';
88
import { ProductService } from '../product.service';
99

10-
@Migration('2024-06-24T09:00:02')
10+
@Migration('2024-07-01T09:00:00')
1111
export class BackfillEmptyMediumsMigration extends BaseMigration {
1212
constructor(private readonly productService: ProductService) {
1313
super();
@@ -47,20 +47,18 @@ export class BackfillEmptyMediumsMigration extends BaseMigration {
4747
`Resolves to ${updates.length} products to assign mediums to`,
4848
);
4949

50-
for (const updateChunk of chunk(updates, 50)) {
51-
await this.db
52-
.query()
53-
.unwind(updateChunk, 'update')
54-
.match(node('product', 'Product', { id: variable('update.id') }))
55-
.apply(
56-
updateProperty({
57-
resource: Product,
58-
key: 'mediums',
59-
value: variable('update.mediums'),
60-
}),
61-
)
62-
.return<{ id: ID }>('product.id as id')
63-
.executeAndLogStats();
64-
}
50+
await this.db
51+
.query()
52+
.unwind(updates, 'update')
53+
.match(node('node', 'Product', { id: variable('update.id') }))
54+
.apply(
55+
updateProperty({
56+
resource: Product,
57+
key: 'mediums',
58+
value: variable('update.mediums'),
59+
}),
60+
)
61+
.return<{ id: ID }>('node.id as id')
62+
.executeAndLogStats();
6563
}
6664
}

0 commit comments

Comments
 (0)