babenkoivan / elastic-migrations

Elasticsearch migrations for Laravel
MIT License
189 stars 32 forks source link

Elastic Migration is not using Elastic Client Config. #51

Closed nw-mjl closed 1 year ago

nw-mjl commented 1 year ago
Software Version
PHP 8.1
Elasticsearch 8.7.1
Laravel 8.83.27

Describe the bug I set the client config to a different port, but Migrations still run on the default port. I am running two different versions of ES at the same time.

I am not sure if this is a bug, or I have some config that is wrong. But I just can't get migrations to to run on my port 28201 instance.

I am using version 2.0.1.

I would like to upgrade to 3.3 but finding it difficult to have a combination that works with elastic-scout-driver-plus.

        "babenkoivan/elastic-adapter": "^2.4",
        "babenkoivan/elastic-migrations": "^2.0",
        "babenkoivan/elastic-scout-driver-plus": "^3.4",

When I try migrations ^3.3, I end up with dependency conflicts I can't seem to resolve.

Thanks for any assistance you can provide.

To Reproduce Set client config to:

<?php

declare(strict_types=1);

return [
    'default' => env('ELASTICSEARCH_8_CONNECTION', 'elastic8'),
    'connections' => [
        'elastic8' => [
            'hosts' => [
                env('ELASTICSEARCH_8_HOST', 'localhost:28201'),
            ],
            // configure basic authentication
            'basicAuthentication' => [
                env('ELASTICSEARCH_8_USER'),
                env('ELASTICSEARCH_8_PASS'),
            ],
            // configure HTTP client (Guzzle by default)
            'httpClientOptions' => [
                'timeout' => 5,
            ],
        ],
    ],
];

.env:

ELASTIC_MIGRATIONS_CONNECTION='main'

# Configuration for ES version 8
ELASTICSEARCH_8_CONNECTION=default
ELASTICSEARCH_8_CLUSTER_MAP=localhost:28201
ELASTICSEARCH_8_HOST=localhost:28201
ELASTICSEARCH_8_SCHEME=http
ELASTICSEARCH_8_USER=
ELASTICSEARCH_8_PASS=

Current behavior The index is created in the ES on port 9200.

Expected behavior The index is created in the ES on port 28201.

nw-mjl commented 1 year ago

It looks like a lot of changes for multiple connections was made in v3. I am not able to upgrade because of another conflict. For now I will handle migrations differently.

Regards, Mike