# migrashun

> An abstract migration library that gives you control

Latest version **0.2.0** (published 2016-05-26) · ISC license · 0 weekly downloads

## Install

```sh
npm install migrashun
pnpm add migrashun
yarn add migrashun
bun add migrashun
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2016-05-26 |
| First published | 2015-02-05 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Known vulnerabilities | 0 (+6 in 1 direct dependencies) |
| Install scripts | no |
| Author | Ramnique Singh |
| Maintainers | ramniquesingh |
| Keywords | db, migration, database, mongodb |

## Links

- npm: https://www.npmjs.com/package/migrashun
- Repository: https://github.com/ramniquesingh/migrashun
- Issues: https://github.com/ramniquesingh/migrashun/issues
- npm.io page: https://npm.io/package/migrashun

## Dependencies (6)

- [glob](https://npm.io/package/glob.md) ^4.3.5
- [async](https://npm.io/package/async.md) ^0.9.0
- [lodash](https://npm.io/package/lodash.md) ^3.0.1
- [fs-extra](https://npm.io/package/fs-extra.md) ^0.16.3
- [glob-stream](https://npm.io/package/glob-stream.md) ^4.0.1
- [sanitize-filename](https://npm.io/package/sanitize-filename.md) ^1.1.3

## 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

- 0.2.0 (latest) — 2016-05-26
- 0.1.0 — 2015-02-05

## README

# migrashun
Another abstract migration framework, that lets YOU do all the work!

## Installation

    $ npm install migrashun

## How does it work?
The constructor takes 4 arguments:

    var Migrashun = require('migrashun');

    var m = new Migrasun(
        filesDir,
        getLastMigration,
        setLastMigration,
        iter
    );

- **filesDir**: (String) Path to directory where migrations will be stored. This should exist on the filesystem already.
- **getLastMigration**: (Function) A function that will fetch the filename of the latest executed migration. This is given a callback that must be called with the filename. Example:
      function getLastMigration(cb) {
          db.fetchLast(function (err, doc) {
              if (err)
                  return cb(err);
              cb(null, doc.filename);
          }
      }
- **setLastMigration**: (Function) A function that will save the latest executed migration filename. Again, this is given a callback that must be called after processing. Example:
      function getLastMigration(filename, cb) {
          db.saveLast(filename, function (err) {
              if (err)
                  return cb(err);
              cb();
          }
      }
- **iter**: (Function) **OPTIONAL** - A function that will receive the filename of the current migration being processed, and the direction (up/down). You can use this to log or do custom printing. Example:
      function iter(fname, direction) {
          console.log('Running ', direction, ':', fname);
      }

## API
### up(count, cb)
Migrate up.

### down(count, cb)
Migrate down

### create(title, cb)
Create new migration

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