dynamodb-migrator-cli
Install
npm i @eolas-medical/dynamodb-migrator-cli --save-dev
Usage
1. Configuration file
Set the config options in .dynamodb-migratorrc.<json|yaml|yml|js|cjs>
or dynamodb-migrator.config.<js|cjs>
:
Config Options
module.exports = {
migrationsPath: "./migrations",
region: "eu-west-1",
endpoint: "http://localhost:8000",
tableName: "migrations",
keyName: "migrationName",
};
2. Generate a migration file
dynamodb-migrator generate <name-of-migration>
3. Update the generated migration file
import { UpdateCommand } from "@aws-sdk/lib-dynamodb";
module.exports = {
up: async (db) => {
return db.send(
new UpdateCommand({
TableName: "TableName",
Key: {
id: "abc-123",
},
UpdateExpression: "SET #newAttr = :newAttr",
ExpressionAttributeNames: {
"#newAttr": "newAttr",
},
ExpressionAttributeValues: {
":newAttr": "new attribute",
},
})
);
},
down: () => {},
};