diff --git a/web-api/workflow-terraform/migration/main/lambdas/migration-segments.js b/web-api/workflow-terraform/migration/main/lambdas/migration-segments.js index 33d98fad0cc..5c35d98c6f6 100644 --- a/web-api/workflow-terraform/migration/main/lambdas/migration-segments.js +++ b/web-api/workflow-terraform/migration/main/lambdas/migration-segments.js @@ -43,6 +43,8 @@ const scanTableSegment = async ( await dynamoDbDocumentClient .scan({ ExclusiveStartKey: lastKey, + ExpressionAttributeValues: { ':prefix': 'streams-event-id' }, + FilterExpression: 'NOT begins_with(pk, :prefix)', Segment: segment, TableName: process.env.SOURCE_TABLE, TotalSegments: totalSegments, @@ -100,10 +102,6 @@ exports.processItems = async ( applicationContext, { documentClient, items, ranMigrations, segment }, ) => { - items = items.filter(item => { - return !item.pk.startsWith('streams-event-id'); - }); - try { items = await exports.migrateRecords(applicationContext, { documentClient, diff --git a/web-api/workflow-terraform/migration/main/lambdas/migration-segments.test.js b/web-api/workflow-terraform/migration/main/lambdas/migration-segments.test.js index 953417ec449..e70d29a22d2 100644 --- a/web-api/workflow-terraform/migration/main/lambdas/migration-segments.test.js +++ b/web-api/workflow-terraform/migration/main/lambdas/migration-segments.test.js @@ -44,8 +44,6 @@ jest.mock('./migrationsToRun', () => ({ ], })); -const { migrationsToRun } = require('./migrationsToRun'); - const mockValidationMigration = jest.fn(); jest.mock('./migrations/0000-validate-all-items', () => ({ migrateItems: mockValidationMigration, @@ -97,10 +95,6 @@ describe('migration-segments', () => { pk: 'case|101-20', sk: 'case|101-20', }, - { - pk: 'streams-event-id|abc123', - sk: 'streams-event-id|abc123', - }, ], LastEvaluatedKey: null, }), @@ -153,14 +147,6 @@ describe('migration-segments', () => { ); }); - it('should not try to migrate streams-event-id to the new table', async () => { - await handler(mockLambdaEvent, mockLambdaContext); - - expect(migrationsToRun[0].script.mock.calls[0][0]).toEqual([ - { pk: 'case|101-20', sk: 'case|101-20' }, - ]); - }); - it('should NOT throw an error when an error occurs while attempting to calculate a record`s size', async () => { mockGetRecordSize.mockImplementation(() => { throw new Error();