east-elasticsearch
v1.0.1
Published
Elasticsearch adapter for "east" (node.js database migration tool)
Maintainers
Readme
east elasticsearch
Elasticsearch adapter for east (node.js database migration tool).
All executed migrations names will be stored at .migrations index in elasticsearch.
A elasticsearch Client object will be passed to migrate and rollback functions, see
elasticsearch-js
Installation
npm install east east-elasticsearch -galternatively you could install it locally
Usage
go to project dir and run
east initcreate .eastrc file at current directory
{
"adapter": "east-elasticsearch",
"url": "",
"elasticSearchApiVersion": undefined,
"migrationsIndex": ".migrations"
}url: url for connect to elasticsearch: "localhost:9200"
migrationsIndex: Optional name of the index at which the applied migrations will be tracked.
elasticSearchApiVersion: Optional api version of your elasticsearch. See https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html
now we can create some migrations
east create applescreated file will look like this one
exports.migrate = function(client, done) {
done();
};
exports.rollback = function(client, done) {
done();
};edit created file and insert
exports.migrate = function(client, done) {
client.indices.create({ index: 'apples' }).then(() => {
done();
}).catch(done);
};
exports.rollback = function(client, done) {
client.indices.delete({ index: 'apples' }).then(() => {
done();
}).catch(done);
};now we can execute our migrations
east migrateoutput
target migrations:
1_apples
migrate `1_apples`
migration doneand roll them back
east rollbackoutput
target migrations:
1_apples
rollback `1_apples`
migration successfully rolled backyou can specify one or several particular migrations for migrate/rollback e.g.
east migrate 1_applesor
Run east -h to see all commands, east <command> -h to see detail command help,
see also east page for command examples.
Running tests
run east tests with this adapter
