How to update nested attribute name for specific DynamoDB items

  Kiến thức lập trình

I use boto3 client for managing DynamoDB items. Let’s assume that the item structure is the following:

{
  "id": "item_id",
  "name": "item_name",
  "age": 23,
  "body": {
    {"nested": "nested_data"}
  }
}

There was a bug at some point, and instead of nested key, nested_error key was inserted for some items:

{
  "id": "item_id",
  "name": "item_name",
  "age": 23,
  "body": {
    {"nested_error": "nested_data"}
  }
}

The bug has been fixed and I would like to implement a “migration” that will rename nested_error key to nested one for all items affected. The action should be skipped if the name of the attribute is already nested.

What is the correct way to do such a migration? Should I implement a script with boto3 or an awscli command would be enough? Or maybe it can be done via the AWS Console? What command should I use?

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT