Home brewed wrapper library to make liquibase callable from python in the same vein as python-closure with an extension or two.
git clone python-liquibase
cd python-liquibase
pip install -e .
./get-liquibase.sh
./get-postgresql.sh # or ./get-mysql.sh
python -m liquibase # or `liquibase-run` as created by setup.py
But the extra sauce is in the Extentions.
For some basic reasoning and example of usage see the Google Docs Presentation at the end there is also a Northwind continuous integration example.
liquibase.ext.diff
and liquibase.ext.update
contain helper functions to use diffChangeLog
and updateSQL
more easily.
if you setup your liquibase/config.py
via cp liquibase/config.py.pgsql.example liquibase/config.py
or creating the file as seen below:
LIQUIBASE = {
'url' : 'jdbc:postgresql://localhost:5432/WORKING_DATABASE_WE_WANT_TO_CHANGE',
'driver' : 'org.postgresql.Driver',
'classpath' : 'postgresql.jar',
'username' : 'postgresql',
'password' : '',
# Required Diff Parameters
'referenceUsername' : 'postgresql',
'referencePassword' : '',
'referenceUrl' : 'jdbc:postgresql://localhost:5432/EXAMPLE_DATABASE_WITH_LATEST_DDL',
}
After creation execute python liquibase/test.py
or liquibase-ext-changelog-sql
and if all went well a autogenerated SQL Update Database Script
will be dumped to stdout.
This SQL script will update WORKING_DATABASE_WE_WANT_TO_CHANGE
to match EXAMPLE_DATABASE_WITH_LATEST_DDL
.
WARNING there might be DROP
statements so review the SQL before just running it on your live database.
Note referenceDriver
is commented out. You should be able to compare database across different db technology; your millage my vary.
Finally remember to read THE PROBLEM WITH DATABASE DIFFS.
Will use the liquibase version number currently 3.5.3
and post-fix the date of the python package eg 3.5.3.180312
.
This is a helper library so I just decided on some names and ran with it. If you like the idea but disagree with the layout or structure create an issue.
Personally I would like to merge with one of the py-liquibase modules on pip. But I needed this today.
I'm lucky to only use py3. If this library does not work on py2 please create a pull request.
Thanks to /u/nvoxland and other liquibase contributors without his work and contribution my little toy project will have no existence; and /u/miracle2k who's code I used as a base for this library.
Apache License 2.0