Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@clarityhub/serverless-dynamodb-migrations

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@clarityhub/serverless-dynamodb-migrations

Trigger DynamoDB migrations from AWS Lambda with Serverless ⚡️

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

Serverless DynamoDB Migrations

Build Status NPM version

Database migrations for AWS Lambda and DynamoDB using DynamoDB Migrations.

About

This Serverless plugin can execute and rollback database migrations after deploys. See Usage. Forked from serverless-pg-migrations.

Heavily inspired by transmogrify. I tried to use it but encountered a lot of showstopping bugs for me, so I wrote my own, smaller and simpler version.

Notable differences from transmogrify:

  • This plugin does not attempt to add handlers automatically (see Adding handlers)
  • This plugin does not create or drop databases
  • This plugin does not have a handler for checking database connection

Migrations

The plugin assumes that migration files live in a migrations directory inside your project.

Installation

yarn add @clarityhub/serverless-dynamodb-migrations OR npm i --save @clarityhub/serverless-dynamodb-migrations

Usage

Define a migration handler somewhere in your project. Example:

// /migrations.js

const { up, down } = require("@clarityhub/serverless-dynamodb-migrations/handlers");

module.exports.up = up;

module.exports.down = down;

Add the plugin and handlers to your serverless.yml:

provider:
  name: aws

plugins:
  - "@clarityhub/serverless-dynamodb-migrations"

functions:
  up:
    handler: migrations.up
    timeout: 30
    environment:
      MIGRATION_TABLE: migrations
  down:
    handler: migrations.down
    timeout: 30
    environment:
      MIGRATION_TABLE: migrations

Pass the function to the serverless deploy command to have it execute after the deploy is finished:

sls deploy --function up

You can also manually invoke the functions locally:

sls invoke local --function up

Or use the plugin directly without going through your function:

sls migrate up
sls migrate down

Configuration

The provided migration handlers can be imported with const { up, down} = require("@clarityhub/serverless-dynamodb-migrations/handlers").

The functions need to have the environment variable MIGRATION_TABLE set to the DynamoDB table name you want to use. If the table doesn't exist, the migrations will create the table for you. You can use resources to create one if you want though.

FAQs

Package last updated on 30 Nov 2019

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc