Skip to content

mmarcon/liquibase-mongo-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

liquibase-mongo-docker

Liquibase and its MongoDB extension conveniently packaged in a Docker image that works out of the box.

Links

How to use it

First, build the Docker image

$ docker build . --tag "liquibase-mongo:4.18.0"  

Then use it as follow.

Update

$ docker run --rm -v \
"`pwd`/example/changelog:/liquibase/changelog" liquibase-mongo:4.18.0 \
--url="mongodb://host.docker.internal:27017/liquibase_test" --changeLogFile=changelog/changelog.xml --logLevel=info update

Tag current version

$ docker run --rm -v \
"`pwd`/example/changelog:/liquibase/changelog" liquibase-mongo:4.18.0 \
--url="mongodb://host.docker.internal:27017/liquibase_test" --logLevel=info tag tagName

Rollback

Rollback by count

$ docker run --rm -v \
"`pwd`/example/changelog:/liquibase/changelog" liquibase-mongo:4.18.0 \
--url="mongodb://host.docker.internal:27017/liquibase_test" --changeLogFile=changelog/changelog.xml --logLevel=info rollbackCount 1

Rollback to tag

$ docker run --rm -v \
"`pwd`/example/changelog:/liquibase/changelog" liquibase-mongo:4.5.0 \
--url="mongodb://host.docker.internal:27017/liquibase_test" --changeLogFile=changelog/changelog.xml --logLevel=info rollback tagName

Note: Because Liquibase runs inside the Docker container and I am testing it against a local mongod running outside docker, I am pointing to it by using host.docker.internal:27017 as the host.

Test that it worked

  • After running update You can use Compass to check that the namespace liquibase_test.myCollection exists, has an index on name and some schema validation rules where the name field is required. You can also use MongoDB for VS Code, connect to your local MongoDB Server and run the verify-update.mongodb playground.
  • After running rollbackCount 1 You can use Compass to check that the namespace liquibase_test.myCollection exists, has an index on name and some schema validation rules where the name and address fields are required. You can also use MongoDB for VS Code, connect to your local MongoDB Server and run the verify-rollback.mongodb playground.

You can run the same playground files from the new MongoDB Shell. For example, to verify the update:

$ mongosh ./example/playgrounds/verify-update.mongodb

Known issues

  • The generateChangeLog command is currently not supported for MongoDB.
  • The db-doc command should be supported but in fact it breaks

About

Liquibase and its MongoDB extension inside a Docker image.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published