Skip to content

Commit

Permalink
using a filter expression instead
Browse files Browse the repository at this point in the history
  • Loading branch information
codyseibert committed Jun 23, 2023
1 parent 9d1f239 commit b9f2d72
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ jest.mock('./migrationsToRun', () => ({
],
}));

const { migrationsToRun } = require('./migrationsToRun');

const mockValidationMigration = jest.fn();
jest.mock('./migrations/0000-validate-all-items', () => ({
migrateItems: mockValidationMigration,
Expand Down Expand Up @@ -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,
}),
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit b9f2d72

Please sign in to comment.