-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is adminCommand really connected to the admin DB? #111
Comments
I think you want something like this in AdminCommandStatement.java (I need to figure out how to test this change): |
Sorry, I was browsing the older code base. I think this might work:
|
To add some detail, here is the command I was attempting:
Also, I forked the project and made the patch I suggested above, and it appears to be working! |
Thank you @DarrinProtag, will go on with your solution if turns out it is required for adminCommand. mongo documentation says that it basically does the same you described: db.adminCommand runs commands against the admin database regardless of the database context in which it runs. The following commands are equivalent: And yes because of that java driver do not contain api for adminCommand we have to run it via runCommand on admin db. |
Merged will be available in 4.3.1.1 when released |
Hi @DarrinProtag please note https://github.com/liquibase/liquibase-mongodb/releases/tag/liquibase-mongodb-4.3.1.1 is released. Could you please try it out? |
No problem. I switched my build to this released version, and it works fine. Thank you. I am now able to set up sharding, shard my collections, and set the shard keys! For the next person...I'm using groovy formatted changelogs, and doing things like this... And need no manual setup steps, now.
|
Hi @DarrinProtag. I'm trying to add luquibase to my project. We are using Cosmosdb Mongodb API. |
https://docs.liquibase.com/workflows/database-setup-tutorials/mongodb.html - if you twist open the Examples section, there are examples of XML commands to create collections. I haven't found great examples of json (or gradle; which we use) formatted commands. I just tried permutations of syntax until it started making sense to me. These are the libraries we included: I assume there is a json-dsl library you'd need to include if you wanted to parse json command files. I assume cosmo will accept a regular mongo connection string, as opposed to needing a custom cosmo sdk compiled against liquibase. No doubt, Azure (or whoever) wants fancy auth set up locally before it will respond, though. To run stuff from gradle build files...
} Sorry I can't be more help about the json format. |
Darrin thank you for your reply. I red tutorial, but it has no useful examples in my case. I have no issues with connection or running simple commands on CosmosDB MongoDB, but runCommand with customAction won't work. |
Its a bit of a leap into deep water, but the liquibase-mongo source is online. If you spend awhile staring at it, you might figure out whether customAction is supported or if there is a generic command that you could send it through. And if not, maybe you could see how to add a new command that supports it. Alexandru was quite kind about taking suggested changes, so you may not have to use a private fork for very long. |
@Yuriy-Lukashevich I'm trying to run Liquibase-MongoDB on CosmosDB, but I'm running into some errors when Liquibase is starting up, complaining about the Did you have to use any special configuration for Liquibase to make it work on CosmosDB? |
I'm trying to use runCommand or adminCommand to invoke shardCollection. I'm on version 4.3.1.
I get this error from Mongo: 'shardCollection may only be run against the admin database', from this:
adminCommand(command: '{shardCollection: 'darrin.player_info_static', key: '{location: 1, _id: 1}', unique: true} ')
Same as if I'd used runCommand.
Your AdminCommandStatement.run() calls: database.getMongoDatabase().runCommand(command);
I'd expect it to lookup the admin DB.
And I can't figure out how to invoke db.adminCommand() on Mongo using runCommand (as a workaround).
┆Issue is synchronized with this Jira Bug by Unito
The text was updated successfully, but these errors were encountered: