@@ -2,23 +2,28 @@ const { utils } = require('@jitsecurity/dynamodb-data-migrations');
22
33const TABLE_NAME = '{{YOUR_TABLE_NAME}}' ;
44
5- const up = ( item ) => {
6- // Adding a new field to the item example
7- const updatedItem = { ...item , newField : 'value' } ;
8- return updatedItem ;
5+ /**
6+ * @param {DynamoDBDocumentClient } ddb - dynamo db client of @aws-sdk https://github.com/aws/aws-sdk-js-v3/tree/main/clients/client-dynamodb
7+ * @param {boolean } isDryRun
8+ * @returns {{transformed: number} }
9+ *
10+ */
11+ const transformUp = async ( { ddb, isDryRun } ) => {
12+ // Replace this with your own logic
13+ const addNewFieldToItem = ( item ) => {
14+ const updatedItem = { ...item , newField : 'value' } ;
15+ return updatedItem ;
16+ } ;
17+ return utils . transformItems ( ddb , isDryRun , TABLE_NAME , addNewFieldToItem ) ;
918} ;
1019
11- const transformUp = async ( ddb , preparationData , isDryRun ) => {
12- return utils . transformItems ( ddb , isDryRun , TABLE_NAME , up ) ;
13- } ;
14-
15- const down = ( item ) => {
16- const { newField, ...oldItem } = item ;
17- return oldItem ;
18- } ;
19-
20- const transformDown = async ( ddb , isDryRun ) => {
21- return utils . transformItems ( ddb , isDryRun , TABLE_NAME , down ) ;
20+ const transformDown = async ( { ddb, isDryRun } ) => {
21+ // Replace this function with your own logic
22+ const removeFieldFromItem = ( item ) => {
23+ const { newField, ...oldItem } = item ;
24+ return oldItem ;
25+ } ;
26+ return utils . transformItems ( ddb , isDryRun , TABLE_NAME , removeFieldFromItem ) ;
2227} ;
2328
2429module . exports = {
@@ -27,3 +32,9 @@ module.exports = {
2732 // prepare, // pass this function only if you need preparation data for the migration
2833 migrationNumber : 1 ,
2934} ;
35+
36+ /**
37+ * For more data migration scripts examples, see:
38+ * https://github.com/jitsecurity/dynamodb-data-migrations/tree/main/examples
39+ *
40+ */
0 commit comments