Giter VIP home page Giter VIP logo

change-table-schemas's Introduction

DynamoDB: Change Table Schemas

A tool to help migrate tables in DynamoDB

Steps to follow

  1. Create a new table (let us call this NewTable), with the desired key structure, LSIs, GSIs.

  2. Enable DynamoDB Streams on the original table

  3. Associate a Lambda to the Stream, which pushes the record into NewTable. (This Lambda should trim off the migration flag in Step 5)

  4. [Optional] Create a GSI on the original table to speed up scanning items. Ensure this GSI only has attributes: Primary Key, and Migrated (See Step 5).

  5. Scan the GSI created in the previous step (or entire table) and use the following Filter:

    FilterExpression = "attribute_not_exists(Migrated)"

    Update each item in the table with a migrate flag (ie: “Migrated”: { “S”: “0” }, which sends it to the DynamoDB Streams (using UpdateItem API, to ensure no data loss occurs).

    NOTE You may want to increase write capacity units on the table during the updates.

  6. The Lambda will pick up all items, trim off the Migrated flag and push it into NewTable.

  7. Once all items have been migrated, repoint the code to the new table

  8. Remove original table, and Lambda function once happy all is good.

More information

https://www.abhayachauhan.com/2017/10/dynamodb-changing-table-schema/

change-table-schemas's People

Contributors

abhayachauhan avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.