# milkshake

> Extendable database agnostic migration command line tool and mini-framework for node.js. Inspired by the Rails migrate tool and node-migrate.

Latest version **0.2.1** (published 2013-12-06) · MIT license · 0 weekly downloads

## Install

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

Provides the command `milkshake`.

## 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.1 |
| Published | 2013-12-06 |
| First published | 2013-12-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 17 |
| Author | Arnor Heidar Sigurdsson |
| Maintainers | arnorhs |
| Keywords | migrate, database, db, migration |

## Links

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

## Dependencies (3)

- [spurt](https://npm.io/package/spurt.md) 0.0.1
- [xtend](https://npm.io/package/xtend.md) ~2.1.1
- [optimist](https://npm.io/package/optimist.md) ~0.6.0

## 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.1 (latest) — 2013-12-06
- 0.2.0 — 2013-12-06
- 0.1.5 — 2013-12-06
- 0.1.4 — 2013-12-02
- 0.1.3 — 2013-12-02
- 0.1.2 — 2013-12-02
- 0.1.1 — 2013-12-02
- 0.1.0 — 2013-12-02
- 0.0.7 — 2013-12-02
- 0.0.6 — 2013-12-01
- 0.0.5 — 2013-12-01
- 0.0.4 — 2013-12-01
- 0.0.3 — 2013-12-01
- 0.0.2 — 2013-12-01
- 0.0.1 — 2013-12-01

## README

# Milkshake

Simple database migration tool inspired by [migrate](https://npmjs.org/package/migrate) and
the rails migration tool.

- Migration scripts are stored in a folder, with a timestamp + ID + name identifier
  and are written in pure JS
- By default it stores which migrations have been run on the filesystem, but you can easily
  extend and change that behavior.
- You can have setup and teardown scripts run before and after migrations
- It will attempt to fail gracefully by saving which migrations have been run each time
  one has been run, and not all-or-nothing.

### Usage

Install using:
```sh
$ npm install milkshake
```
(To install globally use `npm install -g milkshake`)

To initialize a new migration folder:
```sh
$ milkshake init
```
This will create an empty folder in your current working directory named `migrations`
and include a setup.js file by default. (Hint: Look in lib/default-setup.js to see
the methods you can override in your own setup file, eg. for inserting active
migrations or removing from your own database).

Create a new migration file:
```sh
$ milkshake new "Create table users"
```
This will generate a new empty migration file named `<timestamp>-Create_table_users.js`
in the `migrations` folder.

You can list the migrations that will be run (changes not yet reflected in your database) by using
the command:
```sh
$ milkshake list
```

To run the migration:
```sh
$ milkshake migrate
```

To run a downwards migration (downgrades, undos, whatever you'd call them):
```sh
$ milkshake migrate:down
```

And then you can run a single upwards migration (also applies to downwards migrations) by appending
a number after the command:
```sh
$ milkshake migrate:up 2
```

To see the full command line options:
```sh
$ milkshake --help
```

### Full list of commands and options
```sh
  Usage: milkshake [options] command

  Options:
     -c, --chdir <path>     Change the working directory to a given migration
                            directory. eg. /home/billybob/myapp/migrations
                            If no path is given, it defaults to ./migrations
     -h, --help             Show this help screen
     -v, --version          Displays the current version
     -d, --dry, --dry-run   Dry run of migrations (shows you which migrations would
                            by run with a migration command)

  Commands:
     init               Initialize an initial migration directory and helper file(s)

     migrate            Migrate up to the latest migration
     migrate:up [n]     Migrate up by n migrations (default 1)
     migrate:down [n]   Migrate down by n migrations (default 1)

     list               List the migrations to be run (same as running
                        the command 'milkshake migrate --dry-run'

     wrong              List migrations that show up as active even though there is
                        no matching migration file (indicating that you did something
                        wrong in version control (not implemented yet)

     new [title]        Create a new migration file with optional title
     generate [title]   Alias for 'new'
     create [title]     Alias for 'new'
```

### TODO
- Maybe the MigrationDir thing should be a more traditional class-like thing
- Write more tests
- There might be some error cases we could handle better.
- Implement the command to list applied migrations that don't exist (helpful for
  debugging)

*Pull requests welcome*

### License

MIT license

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