Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

east-mysql

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

east-mysql

MySQL adapter for "east" (node.js database migration tool)

  • 0.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

east mysql

MySQL adapter for east which uses the MySQL driver

All executed migrations names will be stored at _migrations collection in the current database. Object with following properties will be passed to migrate and rollback functions:

  • db - instance of the database driver

Installation

npm install -g east east-mysql

alternatively you could install it locally

Usage

Go to project dir and run

east init

create .eastrc file at current directory

{
    "adapter": "east-mysql",
    "url": "mysql://user:password@host/dbname"
}

where url is url of database which you want to migrate in MySQL URL format

now we can create some migrations

east create users

create files will look like this one

"use strict";

exports.migrate = function (client, done) {
    var db = client.db;
    done();
};

exports.rollback = function (client, done) {
    var db = client.db;
    done();
};

Inside the migrations and rollback functions you can create the scripts to migrate up to that version and to rollback from it, eg

exports.migrate = function(client, done) {
    var db = client.db;

    var sql = "CREATE TABLE users ( id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, firstname VARCHAR(30) NOT NULL, lastname VARCHAR(30) NOT NULL, email VARCHAR(50), reg_date TIMESTAMP)";

    db.query(sql, function (err, rows, fields) {

        done(err);

    });
};

exports.rollback = function(client, done) {
    var db = client.db;

    var sql = "DROP TABLE users";

    db.query(sql, function (err, rows, fields) {

        done(err);

    });
};

to execute the migrations

east migrate

to rollback the migration

east rollback

Creating the database

if the database doesn't exist when first migration is created, add the following to the JSON in your .eastrc file

"createDbOnConnect": true

This will automatically create the database if it doesn't exist

Running tests

Clone this repo and run npm test. You can also check code coverage by running grunt coverage

License

MIT

Keywords

FAQs

Package last updated on 19 Apr 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc