npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dynamodb-migration-kit

v1.1.1

Published

CLI to manage DynamoDB migrations.

Downloads

8

Readme

DynamoDB Migration Kit

DynamoDB Migration Kit is a tool designed to simplify and manage database migrations for Amazon DynamoDB. It provides a set of commands to create, run, and manage migrations, making it easier to version control your database schema changes.

Bare bone Philosophy

This kit adheres to a bare-bone approach:

  • Minimal dependencies
  • Direct use of AWS SDK v3
  • Simple, straightforward operations

Installation

To install the DynamoDB Migration Kit, run the following command:

npm install dynamodb-migration-kit

Usage

Initializing the Configuration

example-typescript-project

Before you can start using the migration kit, you need to initialize the configuration:

export AWS_PROFILE=your-aws-profile

dynamodb-migration-kit setup

# Assumes that AWS profile is set.
# Assumes that your project uses src folder.
# If the operation fails, please create the migrations dir manually.
  • This command creates a dynamodb-migration-kit.config.js file in your project root. You can customize this file to match your project's needs.
  • Creates migrations dir under /src.
  • Creates a migration-history-table in AWS DynamoDB in AWS environment.

Creating a New Migration

To create a new migration file:

dynamodb-migration-kit create <migration-name>

# e.g. dynamodb-migration-kit create first-migration
# output: src/migrations/20240709101010-first-migration.ts

This generates a new Typescript file in your migrations directory. (as specified by dynamodb-migration-kit.config.js)

Running Migrations

To run a next pending migration:

dynamodb-migration-kit up

Rolling Back Migrations

To roll back the last applied migration:

dynamodb-migration-kit down

Checking Migration Status

To see the status of migrations:

dynamodb-migration-kit status

This command shows which migrations have been applied and which are pending.

Configuration

The dynamodb-migration-kit.config.js file contains important configuration options:

var config = {
  // dir path where raw typescript migration scripts will be created.
  migrationsDir: "src/migrations",

  // dir path where compiled migrations will be stored after code build by your script.
  // usually under dist or build.
  compiledMigrationsDir: "dist/migrations",

  // default table - no support for using custom table name.
  migrationHistoryTableName: "migration-history-table",
};

module.exports = config;

Writing Migrations

Each migration file should export an up and a down function:

import { DynamoDBClient } from "@aws-sdk/client-dynamodb";

const TABLE_NAME = "YOUR_TABLE";
const client = new DynamoDBClient({});

export async function up() {
  // TODO write your migration here.
}

export async function down() {
  // TODO write the statements to rollback your migration
}

Best Practices

  • Always create a down function to allow for rollbacks.
  • Keep migrations small and focused on a single change.
  • Use descriptive names for your migration files.
  • Test your migrations in a non-production environment first.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License.

Additional Resources

Automate migrations with GitHub Actions