# node-migrate-mongo-orzfly

> Migrations for MongoDB

Latest version **1.6.0** (published 2016-01-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-migrate-mongo-orzfly
pnpm add node-migrate-mongo-orzfly
yarn add node-migrate-mongo-orzfly
bun add node-migrate-mongo-orzfly
```

Provides the command `migrate`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.6.0 |
| Published | 2016-01-17 |
| First published | 2016-01-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 11 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Good Eggs |
| Maintainers | orzfly |
| Keywords | mongo mongoose migrate migrations database |

## Links

- npm: https://www.npmjs.com/package/node-migrate-mongo-orzfly
- Repository: https://github.com/goodeggs/node-migrate-mongo
- Issues: https://github.com/goodeggs/node-migrate-mongo/issues
- npm.io page: https://npm.io/package/node-migrate-mongo-orzfly

## Dependencies (11)

- [async](https://npm.io/package/async.md) ^0.9.2
- [liftoff](https://npm.io/package/liftoff.md) ^2.0.0
- [slugify](https://npm.io/package/slugify.md) ^0.1.0
- [v8flags](https://npm.io/package/v8flags.md) ^1.0.8
- [fs-extra](https://npm.io/package/fs-extra.md) ^0.13.0
- [minimist](https://npm.io/package/minimist.md) ^1.1.0
- [mongoose](https://npm.io/package/mongoose.md) >= 3.8.21
- [interpret](https://npm.io/package/interpret.md) ^0.3.10
- [lodash.assign](https://npm.io/package/lodash.assign.md) ^3.2.0
- [path-is-absolute](https://npm.io/package/path-is-absolute.md) ^1.0.0
- [lodash.isfunction](https://npm.io/package/lodash.isfunction.md) ^3.0.6

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [mongoose-typescript](https://npm.io/package/mongoose-typescript.md) — 85 weekly downloads

## Recent versions

- 1.6.0 (latest) — 2016-01-17

## README

# node-migrate-mongo

Migrations for MongoDB

[![build status][travis-badge]][travis-link]
[![npm version][npm-badge]][npm-link]
[![mit license][license-badge]][license-link]
[![we're hiring][hiring-badge]][hiring-link]

node-migrate-mongo enables data migrations in your existing project.  The state of your migrations is stored in the database specified in the `mongo` property of your `Migratefile.coffee`.  By default, this collection is called `migration_versions`.  See the Usage section (and let's be honest: the code) for more information.

Despite the name, this module does not borrow from TJ's [node-migrate](https://github.com/tj/node-migrate), though it follows very similar conventions.

## Usage

In your existing project where you'd like to have migrations:

```
npm install --save node-migrate-mongo
cat << EOF- > Migratefile.coffee
  module.exports =
    mongo: 'mongodb://localhost/your_db'
EOF
migrate generate --name my_first_migration
# edit it
migrate all
```

## Migratefile Options

* **beforeTest** -- An async function called before running a migration test.  By default sets `NODE_ENV=test`.
* **before** -- An async function called before running a command.  Useful for connecting your app to its database.
* **after** -- An async function called after running a command.
* **afterTest** -- An async function called after running a migration test.
* **mongo** -- A string or function that returns a mongo connection string.
* **model** -- A reference to your custom `MigrationVersion` model.
* **path** -- The place to store your migration files.  Defaults to `migrations`.
* **ext** -- The extension for your migration files.  Defaults to `coffee`.
* **template** -- The template used when generating migrations.
* **context** -- Values provided as part of `this` within all migration functions (`up`, `down`, and `test`)
* **transform** -- A function that allows you to transform migrations before they are run.

before/after callbacks are called in this order: [ beforeTest, before, after, afterTest ]

## Migrations that take promises

One way to accomplish this is with a `Migratefile` that looks like this, which
will allow you to define migrations with `upPromise`, `downPromise`, and
`testPromise` functions:

```javascript
var Promise = require 'bluebird';

module.exports = {
  transform: function(migration) {
    ['up', 'down', 'test'].forEach(function(fn) {
      var promiseVersion = migration[fn + "Promise"];
      if (promiseVersion) {
        migration[fn] = function(done) {
          return Promise.resolve(promiseVersion()).nodeify(done);
        };
      }
    });
    return migration;
  }
}
```

## Contributing

Please follow our [Code of Conduct](https://github.com/goodeggs/mongoose-webdriver/blob/master/CODE_OF_CONDUCT.md)
when contributing to this project.

```
$ git clone https://github.com/goodeggs/node-migrate-mongo && cd node-migrate-mongo
$ npm install
$ npm test
```

_Module scaffold generated by [generator-goodeggs-npm](https://github.com/goodeggs/generator-goodeggs-npm)._

[travis-badge]: http://img.shields.io/travis/goodeggs/node-migrate-mongo/master.svg?style=flat-square
[travis-link]: https://travis-ci.org/goodeggs/node-migrate-mongo
[npm-badge]: http://img.shields.io/npm/v/node-migrate-mongo.svg?style=flat-square
[npm-link]: https://www.npmjs.org/package/node-migrate-mongo
[license-badge]: http://img.shields.io/badge/license-mit-blue.svg?style=flat-square
[license-link]: LICENSE.md
[hiring-badge]: https://img.shields.io/badge/we're_hiring-yes-brightgreen.svg?style=flat-square
[hiring-link]: http://goodeggs.jobscore.com/?detail=Open+Source&sid=161

---
_Source: https://npm.io/package/node-migrate-mongo-orzfly · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
