Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
dynamodb-migrations
Advanced tools
This library allows you to manager DynamoDB Migration Files (Which includes your Tables Schema and Seed data) with an simplified template for use in devops.
npm install --save dynamodb-migrations
Usage example
var AWS = require('aws-sdk'),
dm = require("dynamodb-migrations");
/* Note: To configure AWS Credentials refer https://aws.amazon.com/sdk-for-node-js/ */
var dynamodb = {raw: new AWS.DynamoDB() , doc: new AWS.DynamoDB.DocumentClient() };
dm.init(dynamodb, '<myprojectroot>/<migrations>'); /* This method requires multiple dynamodb instances with default Dynamodb client and Dynamodb Document Client. All the other methods depends on this. */
dm.create('sampleTable'); /* Use gulp, grunt or serverless to integrate this with the commandline, modify the created template file with your custom table schema and seed data */
dm.execute('sampleTable', { prefix: 'dev-', suffix: '-sample'}); /* This executes the 'sampleTable' migration. Note: second parameter is optional. With prefix and suffix actual table name e.g dev-<tablename>-sample
Note: For dynamodb local you can initialize the dynamodb variable as follows
var options = { region: 'localhost', endpoint: "http://localhost:8000" },
dynamodb = {raw: new AWS.DynamoDB(options) , doc: new AWS.DynamoDB.DocumentClient(options) };
Note: for the 'init' method, the migration directory path should be an absolute path. Following example shows how to refer the adbolute path
var path = require('path');
var relPath = 'migrations';
var absolutePath = path.dirname(__filename) + '/' + relPath;
Supported methods
init(dynamodb, migrationsDir) To initialize DynamoDB Client Instances to execute queries and to initialize the directory where migration files exists
create(migrationName) To create a new template with migrationName included, which you can modify to include other attributes and seed data. More information on migration template is shown in the following section.
execute(migrationName, tableOptions) To execute a single migration file. This create the tables if they don't exists and runs the seeds defined in the migration file. tableOptions provides, tablePrefix and tableSuffix attributes to be set, if the actual table is different from migration name
executeAll(tableOptions) To execute all the migration files to create tables and run all the seeds
{
"Table": {
"TableName": "TableName",
"KeySchema": [{
"AttributeName": "attr_1",
"KeyType": "HASH"
}, {
"AttributeName": "attr_2",
"KeyType": "RANGE"
}],
"AttributeDefinitions": [{
"AttributeName": "attr_1",
"AttributeType": "S"
}, {
"AttributeName": "attr_2",
"AttributeType": "S"
}],
"LocalSecondaryIndexes": [{
"IndexName": "local_index_1",
"KeySchema": [{
"AttributeName": "attr_1",
"KeyType": "HASH"
}, {
"AttributeName": "attr_2",
"KeyType": "RANGE"
}],
"Projection": {
"NonKeyAttributes": ["attr_1", "attr_2"],
"ProjectionType": "INCLUDE"
}
}],
"GlobalSecondaryIndexes": [{
"IndexName": "global_index_1",
"KeySchema": [{
"AttributeName": "attr_1",
"KeyType": "HASH"
}, {
"AttributeName": "attr_2",
"KeyType": "RANGE"
}],
"Projection": {
"NonKeyAttributes": ["attr_1", "attr_2"],
"ProjectionType": "INCLUDE"
},
"ProvisionedThroughput": {
"ReadCapacityUnits": 1,
"WriteCapacityUnits": 1
}
}],
"ProvisionedThroughput": {
"ReadCapacityUnits": 1,
"WriteCapacityUnits": 1
}
},
"Seeds": [{
"attr_1": "attr_1_value",
"attr_2": "attr_2_value"
}]
}
Before modifying the migration template, refer the Dynamodb Client SDK and Dynamodb Document Client SDK links.
We love our contributors! If you'd like to contribute to the project, feel free to submit a PR. But please keep in mind the following guidelines:
FAQs
Dynamodb migrations for devops
We found that dynamodb-migrations demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.