umzug-mysql-storage

1.3.0 • Public • Published

Umzug MySQL Storage

Custom storage engine for Umzug to store migrations history in MySQL.

Build Status

Why?

  • Inception; it allows you to store migration logs within the same MySQL database you are migrating;
  • Umzug's default JSON storage engine produces a local JSON file that does not persist with ephemeral file-systems, such as Heroku;
  • Makes team collaboration easier with devs that use the same db server.

Installation

$ npm install umzug-mysql-storage

Requirements

  • Node.js v.4+
  • MySQL v.5+

Quick start

Install umzug-mysql-storage and umzug v.2+, which is listed as a peer dependency.

$ npm install umzug-mysql-storage --save
$ npm install umzug --save

Setup storage engine with umzug.

const path = require('path');
const Umzug = require('umzug');
const MySQLStorage = require('umzug-mysql-storage');
 
const umzug = new Umzug({
  storage: new MySQLStorage({
    database: 'foo',
    table: 'migration', // will be automatically created
    column: 'name', // optional
    host: 'localhost',
    port: 3306,
    user: 'root',
    password: ''
  }),
  // ... specify additional umzug options - if any
});

Storage properties

  • database (string) the name of the database to store migration logs into (required).
  • table (string) the name of the table to store migration logs into; defaults to "migration" (optional).
  • column (string) the name of the column to store migration logs into; defaults to "name" (optional).
  • host (string) mysql server hostname (optional; defaults to "localhost").
  • port (integer) mysql server port (optional; defaults to 3306).
  • user (string) mysql server username (optional; defaults to "root").
  • password (string) mysql server password (optional; defaults to empty string).

Contribute

Source code contributions are most welcome. The following rules apply:

  1. Follow the Airbnb Style Guide;
  2. Make sure not to break the tests.

License

MIT

Package Sidebar

Install

npm i umzug-mysql-storage

Weekly Downloads

1

Version

1.3.0

License

MIT

Last publish

Collaborators

  • jmike