Skip to content
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

Does it support preconditions #69

Closed
vshalgarg opened this issue Dec 10, 2020 · 9 comments · Fixed by #75
Closed

Does it support preconditions #69

vshalgarg opened this issue Dec 10, 2020 · 9 comments · Fixed by #75

Comments

@vshalgarg
Copy link

vshalgarg commented Dec 10, 2020

Does this extension supports preconditions. If yes, please provide some examples. I believe it will be good and easy if there is a page describing all the tags available.

┆Issue is synchronized with this Jira Bug by Unito

@alexandru-slobodcicov
Copy link

@vshalgarg, thanks for raising this. haven't tried if works out of the box. Will give it a try and fix if not working.

@vshalgarg
Copy link
Author

Hi @alexandru-slobodcicov , I don't know if this is working and even couldn't try it as I am unable to find the syntax.. can you provide me some syntax so that I can try it on my own. I tried following from https://docs.liquibase.com/concepts/advanced/preconditions.html

"preConditions": [
{
"sqlCheck": {
"expectedResult": 0,
"sql": "db.getCollection('collection1').find({})"
}
}
]

But it gives me IllegalArgumentException. Will appreciate if you could help asap as I am blocked on it

@vshalgarg
Copy link
Author

Hi @alexandru-slobodcicov ,
any update or can you provide some TAT for this

@alexandru-slobodcicov
Copy link

Hi @vshalgarg, will be required to extend AbstractPrecondition in order to be possible to use.
Please let me know which precondition you need? A collection exists, index etc. or you need a generic one to pass some query command? Will try to pick this up next days

@vshalgarg
Copy link
Author

Hi @alexandru-slobodcicov ,
The preconditions I need mostly are checking if a document already exist in collection or not. But other conditions might also be useful.

@vshalgarg
Copy link
Author

Hi @alexandru-slobodcicov ,
any update on this. Requesting you to please pick on priority, as I am blocked on this and Mongo db also doesn't throw an exception on duplicate documents.

@alexandru-slobodcicov
Copy link

Hi @vshalgarg please see the associated PR.
Added the precondition DocumentExistsPrecondition
added examples for XML and JSON: changelog.insert-precondition.test.xml, changelog.insert-precondition.test.json
In the examples tested the new introduced documentExists with filter and without as well as the out of the box one like changeSetExecuted.

Please let me know if this fits your needs. You can build it locally from main branch or wait for the next release most probably 4.2.2.1

Additionally if you are a Java developer you can write a custom Java precondition as well as custom change and do your precondition checks.

Related to duplicate documents exceptions in Mongo, you can add unique indexes on some fields (id) and you will get exceptions during inserts.

@vshalgarg
Copy link
Author

Hi @alexandru-slobodcicov ,
Could we please get this PR merged
#76

@nayakam
Copy link

nayakam commented Nov 3, 2021

Hi @vshalgarg, will be required to extend AbstractPrecondition in order to be possible to use. Please let me know which precondition you need? A collection exists, index etc. or you need a generic one to pass some query command? Will try to pick this up next days

@alexandru-slobodcicov
Is there a way to add precodition check for an index in the collection? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants