Skip to content
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

potif/mygrate

This fork uses the node-postgres JS client for issuing Postgres migration queries instead of spawning a psql process.

mygrate

Database migrations for MySQL and PostgreSQL database.

This utility uses SQL files for migrations that, if need be, can be run by mysql or psql command line utilities. It does not try to be cute.

Installation

npm install -g mygrate

Depending on your database, you will need to install either

npm install mysql

npm install pg

Running

To create migrations directory and config.js sample which must be edited for your database.

mygrate init

To create a migration script.

mygrate new add-tables

That command creates migration/TIMESTAMP-add-tables/{down,up}.sql. Edit these scripts as needed.

To run migrations, do any of the following

mygrate up                           # migrate all scripts
mygrate down                         # down 1 migration
mygrate down 2                       # down 2 migrations
mygrate down all                     # down all migrations
mygrate down TIMESTAMP-some-script   # down to migration before this one

To view migrations applied to the database

mygrate

To target specific environments, development is default

NODE_ENV=test mygrate up

About

SQL file based database migrations for MySQL and PostgreSQL

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages