@onsmart/elasticsearch-migration-cli
TypeScript icon, indicating that this package has built-in type declarations

1.1.3 • Public • Published

Logo

Onsmart Elasticsearch Migration CLI

A CLI to perform elasticsearch migrations.

Installation

Use yarn or npm to install it.

yarn add @onsmart/elasticsearch-migration-cli --dev

npm i @onsmart/elasticsearch-migration-cli -D

Usage

  1. Create a migrations folder

  2. Run setup command

The setup command will create a new index in elasticsearch called onsmart-core-migrations-metadata to store the migrations were performed. You need to run it once.

> elasticsearch-migration-cli setup --elasticsearchCluster <cluster-url> --elasticsearchApiKey <api-key>

You can change the default index name with the flag migrationMetadataAlias, for example:

> elasticsearch-migration-cli setup --elasticsearchCluster <cluster-url> --elasticsearchApiKey <api-key> --migrationMetadataAlias <index-name>
  1. Create a migration file by running this command:
> elasticsearch-migration-cli create-migration
  1. Basically, the elasticsearch migration CLI works with two commands: up and down. Both have the same flags:
  • --elasticsearchCluster <string>: The Elasticsearch Cluster URL
  • --elasticsearchApiKey <string>: The Elasticsearch Api Key with permissions to manage indexes
  • --migration <string>: The migration name
  • --appVersion <string>: The application version to group and persist the migrations
  • --save: This option will persist a document in onsmart-core-migrations-metadata, this prevents the migration from running twice
  1. If you want to test locally, you can run this command below:
> elasticsearch-migration-cli up --elasticsearchCluster http://localhost:9200 --migration <migration-name>

Deployment

To deploy this project, follow these steps:

  • Click on "Actions Tab"
  • Choose the "Onsmart Elasticsearch Migration CLI Deploy" option
  • Click on "Run Workflow"
  • Select "main" branch
  • Run workflow

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @onsmart/elasticsearch-migration-cli

Weekly Downloads

0

Version

1.1.3

License

none

Unpacked Size

206 kB

Total Files

39

Last publish

Collaborators

  • nelsoneldoro
  • falcaoaugustos
  • juanpujol
  • abraaoalves
  • brunolazarus
  • murilopaixao
  • hileomsi