A CLI tool to handle migrations and seeders for DynamoDB with ease.
Note: This is an early release — tested manually, but bugs may exist. PRs and issues are welcome!
- Create migration files with partition/sort keys and data types
- Run individual or all pending migrations
- Create and run seeders with type validation
- Undo migrations (latest, specific, or all)
- Force-run seeders (irreversible)
- Track migration/seeder run status via metadata
- Helpful warnings and edge case handling
npm i dynamite-cli
- node.js 14 or higher
- AWS credentials in a
.env
file with:
- AWS_ACCESS_KEY_ID=your_key
- AWS_SECRET_ACCESS_KEY=your_secret
- AWS_REGION=your_region
dynamodb:CreateTable
dynamodb:DeleteTable
dynamodb:DescribeTable
dynamodb:ListTables
dynamodb:PutItem
dynamodb:DeleteItem
dynamodb:Query
dynamodb:Scan
npm i dynamite-cli
Show the CLI help menu with all available commands and options.
npx dynamite-cli --help
Generate a new migration file with a partition key (and optional sort key).
npx dynamite-cli migration:create --name "tableName" --partitionKey id:N
-
--name
Name of the migration file. -
--partitionKey
Partition key definition (name:type
). -
--sortKey
(optional) Sort key definition (name:type
). - Available types:
N
= Number,S
= String,B
= Binary. - If not specified, the default type is
N
(Number).
Example with a sort key:
npx dynamite-cli migration:create --name "tableName" --partitionKey id:N --sortKey tenantId:S
Apply migrations to your DynamoDB tables.
Run a specific migration by name:
npx dynamite-cli migration:run --name "your-migration-name"
Run all pending migrations:
npx dynamite-cli migration:run
Revert previously applied migrations.
Undo a specific migration by name:
npx dynamite-cli migration:undo --name "your-migration-name"
Undo the latest run migration:
npx dynamite-cli migration:undo
Undo all migrations:
npx dynamite-cli migration:undo --all
Generate a new seeder file.
npx dynamite-cli seed:create --name "your-seeder-name"
-
--name
Name of the seeder file.
Populate your tables with seed data.
Run a specific seeder:
npx dynamite-cli seed:run --name "your-seeder-name"
Force rerun a seeder (irreversible):
npx dynamite-cli seed:run --name "your-seeder-name" --force
⚠️ Seeder files cannot be undone. Use the--force
flag to rerun a seeder if needed.
Display the status of all migrations and seeders.
npx dynamite-cli list
This tool performs real AWS operations and may incur costs if you're outside the AWS Free Tier. Use with caution, especially in production environments.
This project is licensed under the MIT License.