An Alembic plugin to keep records of upgrades and downgrades.
Project description
An Alembic plugin to keep records of upgrades and downgrades.
Free software: MIT license
Installation
pip install Audit-Alembic
Getting started
Quickstart
Add the following lines to your Alembic env.py:
from audit_alembic import Auditor from myapp import version Auditor.create(version).setup()
Slightly more involved:
# myapp.py alembic_auditor = Auditor.create(version, ...) # env.py from myapp import alembic_auditor def run_migrations_offline(): ... context.configure( ... on_version_apply=alembic_auditor.listen ) ... def run_migrations_offline(): ... context.configure( ... on_version_apply=alembic_auditor.listen ) ...
More involved
These functions create an alembic history table and merely ask you to specify your application version (though they allow much else to be customized as well). If you already have a table you wish to add records to whenever an alembic operation takes place, and you have a callable that creates a row for that table, you can instantiate Auditor directly:
alembic_auditor = Auditor(HistoryTable, HistoryTable.alembic_version_applied)
In this case alembic_version_applied specifies how to build the row based on Alembic’s on_version_apply hook.
Customizing not just what data to populate a row with but whehter the row should appear at all is not currently supported. If you wish to do so, directly using Alembic’s on_version_apply hook may be a better fit for you.
Documentation
https://Audit-Alembic.readthedocs.io/ (not available yet)
Development
Status
The most basic tests, for using Audit-Alembic “correctly”, pass for Postgres, MYSQL, and SQLite as a file. Travis does not appear to support MSSQL or Oracle so test status for those DB backends is not known.
The next tests that need to be written should get us to 100% code coverage as well as covering various error cases.
Please feel free to expand from there. See the issues for a list of known issues to work on.
Testing
To run basic tests:
$ virtualenv venv && source venv/bin/activate (venv) $ python setup.py install (venv) $ pip install pytest psycopg2 (venv) $ pytest
To run all tests (i.e. py2 + py3, across all database drivers), run:
$ tox
Also see our Travis setup.
Note, to combine the coverage data from all the tox environments run:
Windows |
set PYTEST_ADDOPTS=--cov-append tox |
---|---|
Other |
PYTEST_ADDOPTS=--cov-append tox |
Changelog
0.1.0 (2017-06-21)
First release on PyPI. (powered by cookiecutter-pylibrary)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.