Comments (12)
I think you want something like this in AdminCommandStatement.java (I need to figure out how to test this change):
(deleted incorrect code)
from liquibase-mongodb.
Sorry, I was browsing the older code base. I think this might work:
public Document run(final MongoLiquibaseDatabase database) {
MongoDatabase adminDB = ((MongoConnection)database.getConnection()).getMongoClient().getDatabase(database.getSystemSchema());
return adminDB.runCommand(command);
}
from liquibase-mongodb.
To add some detail, here is the command I was attempting:
adminCommand(command: '{shardCollection: "darrin.player_info_static", key: {location: 1, _id: 1}, unique: true} ')
Also, I forked the project and made the patch I suggested above, and it appears to be working!
from liquibase-mongodb.
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:
https://docs.mongodb.com/manual/reference/method/db.adminCommand/
db.adminCommand runs commands against the admin database regardless of the database context in which it runs. The following commands are equivalent:
db.getSiblingDB("admin").runCommand(<command>) db.adminCommand(<command>)
And yes because of that java driver do not contain api for adminCommand we have to run it via runCommand on admin db.
Will add integration tests examples and probably will use properties to provide db name so that liquibase changes are portable and db name not hardcoded
from liquibase-mongodb.
Merged will be available in 4.3.1.1 when released
from liquibase-mongodb.
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?
from liquibase-mongodb.
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.
adminCommand(command: '{enableSharding: "${database.name}" } ')
adminCommand(command: '{shardCollection: "${database.name}.player_info_static", key: {location: 1, _id: 1}, unique: true} ')
from liquibase-mongodb.
Hi @DarrinProtag. I'm trying to add luquibase to my project. We are using Cosmosdb Mongodb API.
I would appreciate it very much if you could share how to add to xml or json script operation like this:
db.runCommand({customAction: "CreateCollection", collection: "name", offerThroughput: 400, shardKey: "partition_key", indexes: [{key: {_id: 1}}, {key: {partition_key: 1, some_key: 1},unique: true}]});
from liquibase-mongodb.
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:
plugins{
id 'org.liquibase.gradle' version '2.0.4'
}
dependencies{
liquibaseRuntime "org.liquibase.ext:liquibase-mongodb:${project.liquibaseMongodbVersion}" //4.3.1
liquibaseRuntime "org.liquibase:liquibase-core:${project.liquibaseCoreVersion}" //4.3.1
liquibaseRuntime "org.liquibase:liquibase-groovy-dsl:${project.liquibaseGroovyVersion}" // 3.0.0
}
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...
// Run liquibase.update to get schema/indexes up to date.
// In the future, to manage multiple clusters in one mongo,
// use -PrunList stuff from the docs: https://github.com/liquibase/liquibase-gradle-plugin
liquibase {
activities {
local {
// parameters in each activity are from -- for liquibase...
// https://docs.liquibase.com/commands/home.html
changeLogFile 'datastore/src/main/resources/liquibase/changelogs.groovy'
dataOutputDirectory 'datastore/src/main/resources/liquibase/changelog_out'
url 'mongodb://localhost:27017/darrin'
// username ''
// password ''
// Needs to run with -Ddatabase.name=darrin to fix up changelog contents (e.g. stuff like "${database.name}.unique_item"}.
changeLogParameters([ "database.name" : "darrin"])
classPath "$rootDir"
}
}
}
Sorry I can't be more help about the json format.
from liquibase-mongodb.
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.
from liquibase-mongodb.
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.
https://github.com/liquibase/liquibase-mongodb/tree/main/src/main/java/liquibase/ext/mongodb
from liquibase-mongodb.
@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 collMod
command not being supported on CosmosDB.
Did you have to use any special configuration for Liquibase to make it work on CosmosDB?
from liquibase-mongodb.
Related Issues (20)
- Support Updates to a collection HOT 7
- MongoDB extension breaks createIndex on MariaDB 10 HOT 5
- Not able to generate the change logs on on mongodb existing database and also index creation not working on json format. HOT 6
- How to execute same change log on different schemas on the same mongo cluster. HOT 1
- liquibase CLI update failing in docker HOT 1
- Not persisting changes to DATABASECHANGELOG HOT 1
- can't set changelog-lock-wait-time-in-minutes parameter to 0 HOT 1
- Version `4.19.1` is not pushed to maven central repo HOT 1
- Unable to create multi key indexing in liquibase HOT 1
- wrong liquibase core dependency in 4.21.0 release
- renameCollection feature HOT 2
- Updating to latest Liquibase causes the checksum to be changed HOT 1
- Bug in commercial version of liquibase related to mongodb HOT 7
- updateMany feature and rename fields in current data HOT 1
- missing liquibase-mongodb jar file for 4.25.0 HOT 2
- Unsupported authMechanism: MONGODB-AWS HOT 1
- Atlas search index HOT 1
- Azure (Cosmos DB API for MongoDB) - index missing
- Is there a way to specify the database name when it's not included in the connection string? HOT 3
- regexReplace/replaceAll is not evaluated in update command
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from liquibase-mongodb.