east-elasticsearch

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

Usage no npm install needed!

<script type="module">
  import eastElasticsearch from 'https://cdn.skypack.dev/east-elasticsearch';
</script>

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 -g

alternatively you could install it locally

Usage

go to project dir and run

east init

create .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 apples

created 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 migrate

output

target migrations:
    1_apples
migrate `1_apples`
migration done

and roll them back

east rollback

output

target migrations:
    1_apples
rollback `1_apples`
migration successfully rolled back

you can specify one or several particular migrations for migrate/rollback e.g.

east migrate 1_apples

or

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