Comments (2)
@alexandru-slobodcicov I'm thinking that the Statement implementations could execute the runCommand
operation instead of the higher level driver helper methods.
There are two principal benefits:
1: options can be specified in the migrations themselves and are passed through to the database directly. No need to manually add support for options that change over time.
2: Works with a larger set of underlying mongo-driver versions; increasing adoption of this library.
Example: liquibase.ext.mongodb.statement.InsertOneStatement
Current Code:
@Override
public void execute(final MongoConnection connection) {
final MongoCollection<Document> collection = connection.getDatabase().getCollection(getCollectionName());
collection.insertOne(document);
}
Note that the current code doesn't support any options!
Modified Code:
@Override
public void execute(final MongoConnection connection) {
Bson bson = createCommand();
connection.getDatabase().runCommand(bson);
}
private Bson createCommand() {
Document command = new Document("insert", getCollectionName());
command.put("documents", Collections.singletonList(document));
command.putAll(options);
return command.toBsonDocument(Document.class, getDefaultCodecRegistry());
}
This is the strategy I used in PR #78 to add support for all options in the CreateCollectionStatement
class
Finally there are currently two open issues (#71 and #80) relating to supporting the latest driver version.
The signature of the runCommand
methods in the driver has not changed between version 3.12.x
and 4.x
; but collection.insertOne
is no longer void
and therefore fails at runtime. i.e using runCommand
is a more stable interface to use and would provide greater chances of forward-compatibility.
Keen to hear your thoughts?
Jason
from liquibase-mongodb.
Hi @jsonking. Indeed worth changing where possible the Statemens to db.runCommand as you did for CreateCollectionStatement. Just want to mention that the initial approach was to stick to driver APIs until we identified that approximatively everything can be done from runCommand and adminCommand. The same is mentioned in README: A couple of Changes were implemented until identified that majority of the operations can be achieved using db.runCommand()
and db.adminCommand()
. So there is already the option to define runCommand and adminCommand in changesets with all the flexibility.
This particular issue is about having the Database instead of Connection in statements:
execute(final MongoConnection connection)
-> execute(final MongoLiquibaseDatabase database)
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.