liquibase-mongodb icon indicating copy to clipboard operation
liquibase-mongodb copied to clipboard

Not able to generate the change logs on on mongodb existing database and also index creation not working on json format.

Open muralikrishna-kumpatla opened this issue 2 years ago • 6 comments

Hi Team,

Not able to generate the change logs on on MongoDB existing database and also index creation not working on Json format.

I am using liquibase 4.15 and mongodb 4.4 version.

{ "databaseChangeLog": [{ "property": { "name": "collection.name", "value": "person3" } }, { "changeSet": { "id": "12334d", "author": "murali", "changes": [{ "createIndex": { "collectionName": "${collection.name}", "indexQuery": { "clientId": 1,"type": 1 }, "indexOptions": { "$rawJson": { "unique": true, "name": "new_index_key" } } } }] } } ] } `Caused by: com.mongodb.MongoCommandException: Command failed with error 67 (CannotCreateIndex): 'Error in specification { key: {} } :: caused by :: Index keys cannot be empty.' on server localhost:27017. The full response is {"ok": 0.0, "errmsg": "Error in specification { key: {} } :: caused by :: Index keys cannot be empty.", "code": 67, "codeName": "CannotCreateIndex"}

`

muralikrishna-kumpatla avatar Oct 20 '22 12:10 muralikrishna-kumpatla

Mongo extension does not support generateChangeLog

For the index, you need to specify the keys tag

see here for an example

oliallan14 avatar Oct 20 '22 12:10 oliallan14

Thank for the reply. Currently we are using XML format only. I want to know whether json indexing works or not?

On Thu, Oct 20, 2022, 6:19 PM oliallan14 @.***> wrote:

Mongo extension does not support generateChangeLog

For the index, you need to specify ext:keys tag

see here for an example https://github.com/liquibase/liquibase-mongodb/blob/main/src/test/resources/liquibase/ext/changelog.create-index.test.xml

— Reply to this email directly, view it on GitHub https://github.com/liquibase/liquibase-mongodb/issues/299#issuecomment-1285487284, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGMLP2OBQWWLQD7CRB7NZVDWEE5WZANCNFSM6AAAAAARKDKERQ . You are receiving this because you authored the thread.Message ID: @.***>

muralikrishna-kumpatla avatar Oct 20 '22 23:10 muralikrishna-kumpatla

@oliallan14 Thanks for the reply. Currently we are using XML format only. I want to know whether json format supports indexing or not? , I have to generate the Liquibase change for an existing database.

muralikrishna-kumpatla avatar Oct 27 '22 10:10 muralikrishna-kumpatla

sorry I am not sure if json format supports indexing

oliallan14 avatar Nov 02 '22 15:11 oliallan14

We're checking with 4.23.0 to see if we can reproduce this.

tabbyf00 avatar Nov 07 '22 15:11 tabbyf00

It seems like the code generated by the changelog is leaving the "key" value of createIndex(key, options) empty, even when keys are specified in the changeset. This is still an issue in version 4.23.0

tati-qalified avatar Jul 31 '23 17:07 tati-qalified