# anydb-sql-migrations

> Database migrations for anydb-sql

Latest version **2.4.1** (published 2019-01-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install anydb-sql-migrations
pnpm add anydb-sql-migrations
yarn add anydb-sql-migrations
bun add anydb-sql-migrations
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.4.1 |
| Published | 2019-01-10 |
| First published | 2014-12-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 54.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | spion |
| Maintainers | goldsmith, spion |
| Keywords | anydb, sql, migrations |

## Links

- npm: https://www.npmjs.com/package/anydb-sql-migrations
- Repository: https://github.com/spion/anydb-sql-migrations
- Issues: https://github.com/spion/anydb-sql-migrations/issues
- npm.io page: https://npm.io/package/anydb-sql-migrations

## Dependencies (4)

- [yargs](https://npm.io/package/yargs.md) ^1.3.3
- [lodash](https://npm.io/package/lodash.md) ^4.17.11
- [bluebird](https://npm.io/package/bluebird.md) ^2.3.11
- [anydb-sql](https://npm.io/package/anydb-sql.md) ^0.7.1

## Recent versions

- 2.4.1 (latest) — 2019-01-10
- 2.4.0 — 2019-01-09
- 2.3.1 — 2018-11-29
- 2.3.0 — 2018-11-29
- 2.2.4 — 2018-09-25
- 2.2.3 — 2018-09-19
- 2.2.2 — 2018-09-19
- 2.2.1 — 2018-09-19
- 2.2.0 — 2018-09-19
- 2.1.6 — 2017-11-01
- 2.1.5 — 2017-11-01
- 2.1.4 — 2017-11-01
- 2.1.3 — 2017-11-01
- 2.1.2 — 2017-10-31
- 2.1.1 — 2017-10-31
- … 13 more at https://npm.io/package/anydb-sql-migrations/versions

## README

## anydb-sql-migrations

Database migrations for [anydb-sql](//github.com/doxout/anydb-sql)

## usage

Create a script called `migrate.js` and add the following

```js
#!/usr/bin/env node

var myanydbsql = require('./path/to/my/database/instance');

require('anydb-sql-migrate')
.create(myanydbsql, '/path/to/migrations/dir')
.run();
```

In your migrations dir, create a file named '001-empty-test.js' and add the code

```js
exports.up = function(transaction) {}
exports.down = function(transaction) {}
```

The first method is run when upgrading the db, while the second is run when
downgrading it. Both methods accept a single parameter - the transaction within
which that migration should run.

To check for pending migrations, use
```
./path/to/migrate.js --check
```

It should show `001-empty-test` and return a nonzero exit code

To run pending migrations, use

```
./path/to/migrate.js --execute
```

It should run the exported empty `up` function.

If you want to silently run the migrations, you can pass `{ silent: true }` to `run` and `migrate` functions

```js
require('anydb-sql-migrate')
.create(myanydbsql, '/path/to/migrations/dir')
.migrate({ silent: true }); // it will supress only console.logs, not errors
```

# license

MIT

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