A mysql driver for marv
One of:
marv-mysql-driver will automatically use whichever library you have installed but does not package either of these libraries. Please read the troubleshooting notes if using mysql with MySQL 8.0 (or above).
npm i marv marv-mysql-driver
migrations/
|- 001.create-table.sql
|- 002.create-another-table.sql
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 :)
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 :)
});
});
Client does not support authentication protocol requested by server; consider upgrading MySQL client
MySQL v8 changed the default authentication plugin to caching_sha2_password
, which, at time of writing is not supported by mysql. Therefore MySQL v8 users either need to change the default authentication plugin back to mysql_native_password
or install mysql2.
MySQL v5 users can use either mysql or mysql2.
npm install
npm run mysql5
npm run mysql8
npm run mysql8-native-password
sleep 30
npm test