{"id":15693543,"url":"https://github.com/austinkelleher/dynograte","last_synced_at":"2025-08-04T23:19:00.393Z","repository":{"id":57217918,"uuid":"67606271","full_name":"austinkelleher/dynograte","owner":"austinkelleher","description":"Node.js DynamoDB migration tool","archived":false,"fork":false,"pushed_at":"2018-02-23T13:52:32.000Z","size":42,"stargazers_count":7,"open_issues_count":2,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-14T10:43:00.033Z","etag":null,"topics":["dynamo","dynamodb","migration"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/austinkelleher.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-07T12:54:23.000Z","updated_at":"2020-08-30T14:59:52.000Z","dependencies_parsed_at":"2022-08-28T21:40:34.236Z","dependency_job_id":null,"html_url":"https://github.com/austinkelleher/dynograte","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/austinkelleher%2Fdynograte","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/austinkelleher%2Fdynograte/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/austinkelleher%2Fdynograte/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/austinkelleher%2Fdynograte/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/austinkelleher","download_url":"https://codeload.github.com/austinkelleher/dynograte/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252996965,"owners_count":21837742,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dynamo","dynamodb","migration"],"created_at":"2024-10-03T18:45:17.721Z","updated_at":"2025-05-08T04:19:42.377Z","avatar_url":"https://github.com/austinkelleher.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dynograte\n\nDynograte is a Node.js DynamoDB migration tool\n\n## Installation\n\n```bash\nnpm install dynograte\n```\n\nDynograte also comes packaged with tooling for making your life easier. You\nobviously need it. You can install Dynograte globally with:\n\n```bash\nnpm install dynograte -g\n```\n\n## Features\n\n- Migrating DynamoDB tables from a directory\n- Migrating DynamoDB tables from functions\n- Command line tool for auto-generating migration files\n- Reminds you of a dinosaur\n\n## How it works\n\nDynograte creates a DynamoDB table with a name that you specify. This table is\nused to track migration files that have already been run. Dynograte will only\nrun migration files that do not exist in the migrations table.\n\n## Examples\n\nDynograte can load migrations from a directory\n\n```javascript\nconst path = require('path');\nconst dynamodb = new aws.DynamoDB(config.dynamodb);\n\nlet migrationDir = path.resolve(__dirname, './dynamodb-migrations');\n\nreturn dynograte.migrate({\n  dynamodb: dynamodb,\n  migrationTableName: 'my-awesome-migration-table',\n  migrationDir: migrationDir\n});\n\n```\n\nDynograte can handle migrations as functions\n\n```javascript\n\nreturn dynograte.migrate({\n  dynamodb: dynamodb,\n  migrationTableName: randomTableName\n}, [\n  (dynamodb) =\u003e {\n    return theBestMigration(dynamodb);\n  },\n  (dynamodb) =\u003e {\n    return Promise.resolve();\n  }\n]);\n\n```\n\nOr a single migration function\n\n```javascript\n\nreturn dynograte.migrate({\n  dynamodb: dynamodb,\n  migrationTableName: randomTableName\n}, (dynamodb) =\u003e {\n  return theBestMigration(dynamodb);\n});\n\n```\n\n## Migration Retry\n\nDynograte supports migration retries. Retrying a migration is usefuly for safe\noperations that fail and should be tried multiple times.\n\n\u003e **NOTE**: Retrying a DynamoDB migration can be very dangerous. Use this feature\n\u003e with caution. You should only retry migrations like creating a table.\n\u003e Retrying a migration that alters a table could cause a partial table alter\n\u003e that can be difficult to recover from. We recommend backing up your tables!\n\nDynograte uses the [tri](https://github.com/austinkelleher/tri) module for\nretries. You can either export `true` and use the Dynograte default retry\noptions, or specify your own:\n\n```js\n// My awesome migration that should retry\nexports.retry = true;\n\nexports.up = function(dynograte) {\n  ...\n};\n```\n\n```js\n// My awesome migration that should retry\nexports.retry = {\n  maxAttempts: 3,\n  delay: 100,\n  factor: 2,\n  jitter: true\n};\n\nexports.up = function(dynograte) {\n  ...\n};\n```\n\nOften times, when a database migration is part of the process startup-tasks,\nthe process may be killed if a migration completely fails to run. The process\nmay restart and we may want to retry it again when it comes back online.\nIf your migration fails, Dynograte remembers that the migration has failed\nand stores that information in the migration table in DynamoDB.\n\nDynograte allows you to export `runNextMigrateAfterFail` that will run a failed migration\nagain the next time `dynograte.migrate(...)` is called:\n\n```js\n// My awesome migration that should run the next time the migrations run if it\n// failed to run previously.\nexports.runNextMigrateAfterFail = true;\n\nexports.up = function(dynograte) {\n  ...\n};\n```\n\n## CLI\n\nDynograte comes packaged with a CLI, which will auto-generate migration files.\nMigration files are prefixed with the current `Date` in YY-MM-DD-HH-MM-SS format\nfollowed by a migration name of your choosing.\n\n```bash\ndynograte create --dir ~/Proj/dynomodb-migrations --migration update-users-table\n```\n\nThe `create` command will generate a file in `~/Proj/dynomodb-migrations` that has\na file name similar to `2016-09-07-10-48-28_update-users-table.js.js` and looks like:\n\n```javascript\n'use strict';\n\nexports.up = (dynamodb) =\u003e {\n\n};\n\n```\n\n## Tests\n\nTo run the tests, you can either run docker, or specify your own DynamoDB\nconfiguration in `config.js`.\n\nRun Docker and tests:\n\n```bash\nnpm run docker-test\n```\n\nRun tests without Docker:\n\n```bash\nnpm test\n```\n\n\n`start-docker.sh` generates a `config.js` file that contains the DynamoDB\nconfiguration. You can also manually create it to include your own custom config:\n\n```javascript\n'use strict';\n\nconst aws = require('aws-sdk');\n\nmodule.exports = {\n  dynamodb: {\n    region: 'us-east-1',\n    endpoint: new aws.Endpoint('http://localhost:32795')\n  }\n};\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faustinkelleher%2Fdynograte","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faustinkelleher%2Fdynograte","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faustinkelleher%2Fdynograte/lists"}