open-index/open-npm huggingface dataset:
npm package: @outfront/opensearch-migration-cli
Description: ![Logo](https://beakyn-ui.s3.amazonaws.com/OUT_PRIMARY_LOGO_POS_RGB_BLACK_PILL.svg?2)
Latest version: 1.2.0

![Logo](https://beakyn-ui.s3.amazonaws.com/OUT_PRIMARY_LOGO_POS_RGB_BLACK_PILL.svg?2)

# Onsmart Elasticsearch Migration CLI

A CLI to perform elasticsearch migrations.

## Installation

Use [yarn](https://classic.yarnpkg.com/lang/en/docs/install/) or [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) to install it.

```bash
yarn add @outfront/elasticsearch-migration-cli --dev

npm i @outfront/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.

```bash
> elasticsearch-migration-cli setup --elasticsearchCluster <cluster-url> --elasticsearchApiKey <api-key>
```
You can change the default index name with the flag `migrationMetadataAlias`, for example:

```bash
> elasticsearch-migration-cli setup --elasticsearchCluster <cluster-url> --elasticsearchApiKey <api-key> --migrationMetadataAlias <index-name>
```
3. Create a migration file by running this command:

```bash
> elasticsearch-migration-cli create-migration
```

4. 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

5. If you want to test locally, you can run this command below:

```bash
> 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](https://choosealicense.com/licenses/mit/)