# marv-mysql-driver

> A mysql marv driver implementation

Latest version **5.0.0** (published 2022-11-06) · ISC license · 0 weekly downloads

## Install

```sh
npm install marv-mysql-driver
pnpm add marv-mysql-driver
yarn add marv-mysql-driver
bun add marv-mysql-driver
```

## 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 | 5.0.0 |
| Published | 2022-11-06 |
| First published | 2016-09-08 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=14.0.0 |
| Dependencies | 3 |
| Unpacked size | 22.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | GuideSmiths Ltd |
| Maintainers | cressie176, ulisesgascon, feliun, guidesmiths_bot |
| Keywords | marv, database, db, migration, migrate, mysql |

## Links

- npm: https://www.npmjs.com/package/marv-mysql-driver
- Repository: https://github.com/guidesmiths/marv-mysql-driver
- Homepage: https://github.com/guidesmiths/marv-mysql-driver#readme
- Issues: https://github.com/guidesmiths/marv-mysql-driver/issues
- npm.io page: https://npm.io/package/marv-mysql-driver

## Dependencies (3)

- [async](https://npm.io/package/async.md) ^3.2.4
- [debug](https://npm.io/package/debug.md) ^4.3.4
- [lodash](https://npm.io/package/lodash.md) ^4.17.21

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

- 5.0.0 (latest) — 2022-11-06
- 4.0.1 — 2020-04-05
- 4.0.0 — 2020-04-04
- 3.0.0 — 2019-10-21
- 2.0.2 — 2019-08-17
- 2.0.1 — 2019-08-17
- 2.0.0 — 2017-10-31
- 1.4.1 — 2017-07-12
- 1.4.0 — 2017-07-10
- 1.3.0 — 2017-05-03
- 1.2.1 — 2017-05-01
- 1.2.0 — 2017-03-07
- 1.1.0 — 2017-01-21
- 1.0.0 — 2017-01-11
- 0.2.0 — 2016-09-28
- … 1 more at https://npm.io/package/marv-mysql-driver/versions

## README

[![NPM version](https://img.shields.io/npm/v/marv-mysql-driver.svg?style=flat-square)](https://www.npmjs.com/package/marv-mysql-driver)
[![NPM downloads](https://img.shields.io/npm/dm/marv-mysql-driver.svg?style=flat-square)](https://www.npmjs.com/package/marv-mysql-driver)
[![Node.js CI](https://github.com/acuminous/tripitaka/workflows/Node.js%20CI/badge.svg)](https://github.com/guidesmiths/marv-mysql-driver/actions?query=workflow%3A%22Node.js+CI%22)
[![Maintainability](https://api.codeclimate.com/v1/badges/621e711c2cd6077f5ad3/maintainability)](https://codeclimate.com/github/guidesmiths/marv-mysql-driver/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/621e711c2cd6077f5ad3/test_coverage)](https://codeclimate.com/github/guidesmiths/marv-mysql-driver/test_coverage)

# marv-mysql-driver

A mysql driver for [marv](https://www.npmjs.com/package/marv)

## Prerequisites

One of:

- [mysql](https://www.npmjs.com/package/mysql)
- [mysql2](https://www.npmjs.com/package/mysql2)

marv-mysql-driver will automatically use whichever library you have installed **but does not package either of these libraries**. Please read the [troubleshooting](#troubleshooting) notes if using [mysql](https://www.npmjs.com/package/mysql) with MySQL 8.0 (or above).

## Installation

```
npm i marv marv-mysql-driver
```

## Usage

```
migrations/
  |- 001.create-table.sql
  |- 002.create-another-table.sql
```

### Promises

```js
const marv = require('marv/api/promise'); // <-- Promise API
const driver = require('marv-mysql-driver');
const directory = path.resolve('migrations');
const connection = {
  // Properties are passed straight mysql.createConnection
  host: 'mysql.example.com',
  multipleStatements: true    // See https://www.npmjs.com/package/mysql#multiple-statement-queries
};

const migrations = await marv.scan(directory);
await marv.migrate(migrations, driver({ connection });
// Profit :)
```

### Callbacks

```js
const marv = require("marv/api/callback"); // <-- Callback API
const driver = require("marv-mysql-driver");
const directory = path.resolve("migrations");
const connection = {
  // Properties are passed straight [mysql|mysql2].createConnection
  host: "mysql.example.com",
  multipleStatements: true, // See https://www.npmjs.com/package/mysql#multiple-statement-queries
};

marv.scan(directory, (err, migrations) => {
  if (err) throw err;
  // Connection properties are passed straight [mysql|mysql2].createConnection
  marv.migrate(migrations, driver({ connection }), (err) => {
    if (err) throw err;
    // Profit :)
  });
});
```

## Troubleshooting

```
Client does not support authentication protocol requested by server; consider upgrading MySQL client
```

MySQL v8 changed the [default authentication plugin](https://dev.mysql.com/doc/refman/8.0/en/pluggable-authentication.html) to `caching_sha2_password`, which, at time of writing is not supported by [mysql](https://github.com/mysqljs/mysql/issues/2001). Therefore MySQL v8 users either need to [change](https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin) the default authentication plugin back to `mysql_native_password` or install [mysql2](https://www.npmjs.com/package/mysql2).

MySQL v5 users can use either [mysql](https://www.npmjs.com/package/mysql) or [mysql2](https://www.npmjs.com/package/mysql2).

## Testing

```bash
npm install
npm run mysql5
npm run mysql8
npm run mysql8-native-password
sleep 30
npm test
```

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