|
1 | 1 | import { groupBy } from '@seedcompany/common';
|
2 | 2 | import { node } from 'cypher-query-builder';
|
3 |
| -import { chunk, uniq } from 'lodash'; |
| 3 | +import { uniq } from 'lodash'; |
4 | 4 | import { ID } from '~/common';
|
5 | 5 | import { BaseMigration, Migration } from '~/core/database';
|
6 | 6 | import { updateProperty, variable } from '~/core/database/query';
|
7 | 7 | import { ProductMedium as Medium, Product } from '../dto';
|
8 | 8 | import { ProductService } from '../product.service';
|
9 | 9 |
|
10 |
| -@Migration('2024-06-24T09:00:02') |
| 10 | +@Migration('2024-07-01T09:00:00') |
11 | 11 | export class BackfillEmptyMediumsMigration extends BaseMigration {
|
12 | 12 | constructor(private readonly productService: ProductService) {
|
13 | 13 | super();
|
@@ -47,20 +47,18 @@ export class BackfillEmptyMediumsMigration extends BaseMigration {
|
47 | 47 | `Resolves to ${updates.length} products to assign mediums to`,
|
48 | 48 | );
|
49 | 49 |
|
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(); |
65 | 63 | }
|
66 | 64 | }
|
0 commit comments