Skip to content

Commit

Permalink
Add support for update-to-tag and some maintenance commands (#28)
Browse files Browse the repository at this point in the history
* Add support for update-to-tag and some maintenance commands
* feat: added support for update command update-to-tag
* feat: added support for maintenance commands: changelog-sync,
    changelog-sync-to-tag, clear-checksums, release-locks
* docs: documented new commands in README.md

* Fixes to failing unit tests
  • Loading branch information
Erik van der Goetz authored May 25, 2022
1 parent 169c069 commit 8bce3c7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@ if __name__ == '__main__':
liquibase.status()
liquibase.updateSQL()
liquibase.update()
liquibase.update_to_tag("MyTag")
liquibase.rollback("MyTag")
# liquibase maintenance commands
liquibase.changelog_sync()
liquibase.changelog_sync_to_tag("MyTag")
liquibase.clear_checksums()
liquibase.release_locks()
```

## Python Java Integration
Expand Down
34 changes: 34 additions & 0 deletions pyliquibase/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ def update(self):
def updateSQL(self):
self.execute("updateSQL")

def update_to_tag(self, tag: str):
"""Executes the update-to-tag Liquibase command. `Reference Documentation <https://docs.liquibase.com/commands/update/update-to-tag.html>`_.
param: tag: Name of a tag in the changelog.
"""
log.debug("Updating to tag: %s" % tag)
self.execute("update-to-tag", tag)

def validate(self):
self.execute("validate")

Expand All @@ -134,6 +142,32 @@ def rollback_to_datetime(self, datetime):
log.debug("Rolling back to %s" % str(datetime))
self.execute("rollbackToDate", datetime)

def changelog_sync(self):
"""Executes the changelog-sync Liquibase maintenance command. `Reference Documentation <https://docs.liquibase.com/commands/maintenance/changelog-sync.html>`_.
"""
log.debug("Marking all undeployed changes as executed in database.")
self.execute("changelog-sync")

def changelog_sync_to_tag(self, tag: str):
"""Executes the changelog-sync-to-tag Liquibase maintenance command. `Reference Documentation <https://docs.liquibase.com/commands/maintenance/changelog-sync-to-tag.html>`_.
param: tag: Name of a tag in the changelog.
"""
log.debug("Marking all undeployed changes as executed up to tag %s in database." % tag)
self.execute("changelog-sync-to-tag", tag)

def clear_checksums(self):
"""Executes the clear-checksums Liquibase maintenance command. `Reference Documentation <https://docs.liquibase.com/commands/maintenance/clear-checksums.html>`_.
"""
log.debug("Marking all undeployed changes as executed in database.")
self.execute("clear-checksums")

def release_locks(self):
"""Executes the release-locks Liquibase maintenance command. `Reference Documentation <https://docs.liquibase.com/commands/maintenance/release-locks.html>`_.
"""
log.debug("Marking all undeployed changes as executed in database.")
self.execute("release-locks")

def _download_liquibase(self) -> None:
if os.path.exists(self.liquibase_dir):
log.debug("Liquibase version %s found, skipping download..." % str(self.version))
Expand Down

0 comments on commit 8bce3c7

Please sign in to comment.