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

better-migration

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

better-migration

This is a simple tool to migrate data.

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Better Migration - Make migrations easy!

npm package Build status Dependency Status Known Vulnerabilities Gitter

This is a simple tool to migrate data. It features some key features:

  • Easy to write migrations: just implement the function
  • Out of the box auto-save current version (into a simple text file)
  • Out of the box locking mechanism to ensure only one migration is running
  • Customizable version saving and locking mechanism
npm install --save better-migration

Usage

var migration = require('better-migration');

The idea behind this tool is simple:

1. Write a migration script
migration.version('1.0.0', function (cb) {
	// Your migration script, call cb() when done.
	// cb(err) will abort the migration.
	cb();
})
2. Start the migration

This will run your migration scripts one at a time until it reaches the latest version.

migration.start(function (err) {
	// If the error is set, the script failed, and you should probably not continue.
	// Your data is updated to the latest semver version (in this case is 1.0.0)
})

When you need to migrate again, just call migration.set with the new version number, and restart.

Advanced usage

By default, we save the current version into a file, ./version. You may change this:

var migration = require('better-migration');

Optionally, you may set your own functions for setting the version/lock:

// Set the function to get the version
migration.get = function (cb) {
	cb(null, '1.0.0');
};

// Set the function to set the version
migration.set = function (v, cb) {
	cb(); // Call when saved
}

// Set the function to obtain a lock for migration.
migration.lock = function (cb) {
	// After you acquire the lock, you must return a release function
	// so that we can release the lock after the migration is complete.
	cb(err, release)
}

Contributions welcome!

Credits

This library was initially made by the awesome team of engineers at Diamond.

If you haven't already, make sure you install Diamond!

Keywords

FAQs

Package last updated on 12 Dec 2016

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