Skip to content

Commit c72f945

Browse files
feat(data-migration): remove destination table from stream migration
1 parent 9264847 commit c72f945

File tree

7 files changed

+79
-176
lines changed

7 files changed

+79
-176
lines changed

package-lock.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,21 @@
1212
"@commitlint/config-conventional": "^17.4.4",
1313
"@commitlint/config-nx-scopes": "^17.6.4",
1414
"@commitlint/cz-commitlint": "^17.5.0",
15+
"@nx/devkit": "16.3.2",
16+
"@nx/eslint-plugin": "16.3.2",
17+
"@nx/jest": "16.3.2",
18+
"@nx/js": "16.3.2",
19+
"@nx/linter": "16.3.2",
20+
"@nx/plugin": "16.3.2",
21+
"@nx/workspace": "16.3.2",
1522
"@semantic-release/changelog": "^6.0.3",
1623
"@semantic-release/exec": "^6.0.3",
1724
"@semantic-release/git": "^10.0.1",
1825
"@semantic-release/github": "^8.0.7",
1926
"@swc-node/register": "^1.6.5",
2027
"@swc/cli": "0.1.62",
2128
"@swc/core": "^1.3.57",
29+
"@types/aws-lambda": "^8.10.125",
2230
"@types/cross-spawn": "^6.0.2",
2331
"@types/fs-extra": "^11.0.1",
2432
"@types/jest": "29.4.0",
@@ -39,21 +47,14 @@
3947
"lint-staged": "^13.1.2",
4048
"mock-fs": "^5.2.0",
4149
"nx": "16.3.2",
50+
"nx-cloud": "16.0.5",
4251
"prettier": "^2.8.4",
4352
"semantic-release-npm": "^0.0.5",
4453
"semantic-release-plus": "^20.0.0",
4554
"string-dedent": "^3.0.1",
4655
"ts-jest": "29.1.0",
4756
"ts-node": "10.9.1",
48-
"typescript": "5.0.4",
49-
"nx-cloud": "16.0.5",
50-
"@nx/devkit": "16.3.2",
51-
"@nx/workspace": "16.3.2",
52-
"@nx/js": "16.3.2",
53-
"@nx/linter": "16.3.2",
54-
"@nx/eslint-plugin": "16.3.2",
55-
"@nx/jest": "16.3.2",
56-
"@nx/plugin": "16.3.2"
57+
"typescript": "5.0.4"
5758
},
5859
"dependencies": {
5960
"@aws-sdk/client-cloudwatch-logs": "^3.348.0",

packages/data-migration-example/src/migrations/users/202305264-migrate-v1-to-v2.stream.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import {
1010
const client = new DynamoDBClient({});
1111
const docClient = DynamoDBDocumentClient.from(client);
1212

13+
const TARGET_TABLE_NAME = 'example-users-v2';
14+
1315
export const handler: DynamoDBStreamHandler = async (event) => {
1416
console.debug('Event', JSON.stringify(event));
1517

@@ -22,7 +24,7 @@ export const handler: DynamoDBStreamHandler = async (event) => {
2224

2325
await docClient.send(
2426
new PutCommand({
25-
TableName: process.env['TARGET_TABLE_NAME'],
27+
TableName: TARGET_TABLE_NAME,
2628
Item: {
2729
userId: item['id'],
2830
name: item['name'],
@@ -37,7 +39,7 @@ export const handler: DynamoDBStreamHandler = async (event) => {
3739

3840
await docClient.send(
3941
new DeleteCommand({
40-
TableName: process.env['TARGET_TABLE_NAME'],
42+
TableName: TARGET_TABLE_NAME,
4143
Key: {
4244
userId: keys['id'],
4345
},

packages/data-migration-example/src/migrations/users/202305264-migrate-v1-to-v2.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default class extends DynamoDBMigrationBase {
2727
}
2828

2929
async up(): Promise<void> {
30-
await this.enableStream('example-users', 'example-users-v2');
30+
await this.enableStream('example-users');
3131

3232
this.logger.info('Migrating users from v1 to v2');
3333
let count = 0;

packages/data-migration/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ import {
413413
})
414414
export default class extends DynamoDBMigrationBase {
415415
async up(): Promise<void> {
416-
await this.enableStream('my-table-v1', 'my-table-v2');
416+
await this.enableStream('my-table-v1');
417417

418418
const items = await MyTableModel.scan().exec();
419419
for (const chunk of chunks(items, 25)) {

0 commit comments

Comments
 (0)