# megrim

> Migration Tool for Postgres databases in node.js

Latest version **2.1.0** (published 2016-10-01) · MIT license · 0 weekly downloads

## Install

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

Provides the commands `migrate`, `add-migration`.

## 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 | 2.1.0 |
| Published | 2016-10-01 |
| First published | 2012-08-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 4.0.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | mren |
| Maintainers | mren |

## Links

- npm: https://www.npmjs.com/package/megrim
- Repository: https://github.com/mren/megrim
- Homepage: https://github.com/mren/megrim#readme
- Issues: https://github.com/mren/megrim/issues
- npm.io page: https://npm.io/package/megrim

## Dependencies (1)

- [mesa](https://npm.io/package/mesa.md) 1.0.0-alpha.13

## Recent versions

- 2.1.0 (latest) — 2016-10-01
- 2.0.0 — 2016-10-01
- 1.4.7 — 2016-04-12
- 1.4.6 — 2016-04-12
- 1.4.5 — 2016-04-12
- 1.4.4 — 2015-11-27
- 1.4.3 — 2015-11-26
- 1.4.2 — 2015-03-09
- 1.4.1 — 2015-03-09
- 1.4.0 — 2015-01-28
- 1.3.0 — 2015-01-27
- 1.2.0 — 2015-01-26
- 1.1.5 — 2014-02-27
- 1.1.4 — 2014-02-10
- 1.1.3 — 2014-02-10
- … 5 more at https://npm.io/package/megrim/versions

## README

# megrim

Migration Tool for Postgres databases in node.js

# usage

`node_modules/.bin` contains `add-migration` and `migrate`.

## add-migration

`add-migration <name>` will add a migration file to `schema/$timestamp-$name.sql`.
Custom SQl can be written into this file.

## migrate

`migrate` will execute all migrations which are not yet in the database.
Therefore `migrate` will look at the environment variable `DATABASE_URL`.


## Technical Implementaiton

```coffeescript
megrim = require 'megrim'
megrim path_to_migrations, psql_connection, (err, result) ->
    console.err err if err?
    console.log result
```

All sql files in `path_to_migrations` which are not yet in the database are executed.
After successful execution the timestamp of the migration file is added to the `schema_info` table.

The format of the migrations files should be

```
YYYYMMDDHHMMSS-description.sql
```


License MIT

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