mongodb adapter for east (node.js database migration tool)
All executed migrations names will be stored at
_migrations collection in the
current database. Object with following properties will be passed to
db- instance of mongodb native db
dropIndexIfExistsfunction(collection, index, callback) - helper function which can be used for dropping index in safe way (contrasting to
collection.dropIndexwhich throws an error if index doesn't exist).
npm install east east-mongo -g
alternatively you could install it locally
go to project dir and run
.eastrc file at current directory
"adapter": "east-mongo""url": "mongodb://localhost:27017/test"
url is url of database which you want to migrate (in
mongodb native url connection format)
now we can create some migrations
east create appleseast create bananas
created files will looks like this one
var db = clientdb;done;;var db = clientdb;done;;
edit created files and insert
var db = clientdb;dbcollection'things'insert_id: 1 name: 'apple' color: 'red'if err doneerr;dbcollection'things'insert_id: 2 name: 'apple' color: 'green' done;;;var db = clientdb;dbcollection'things'remove_id: $in: 1 2 done;;
var db = clientdb;dbcollection'things'insert_id: 3 name: 'banana' color: 'yellow' done;;var db = clientdb;dbcollection'things'remove_id: 3 done;;
now we can execute our migrations
target migrations:1_apples2_bananasmigrate `1_apples`migration donemigrate `2_bananas`migration done
and roll them back
target migrations:2_bananas1_applesrollback `2_bananas`migration successfully rolled backrollback `1_apples`migration successfully rolled back
you can specify one or several particular migrations for migrate/rollback e.g.
east migrate 1_apples
east migrate 1_apples 2_bananas
east -h to see all commands,
east <command> -h to see detail command help,
see also east page for command examples.
run east tests with this adapter