https://github.com/py-package/masonite-audit
Keep track of all your model changes with ease.
https://github.com/py-package/masonite-audit
masonite python
Last synced: 2 months ago
JSON representation
Keep track of all your model changes with ease.
- Host: GitHub
- URL: https://github.com/py-package/masonite-audit
- Owner: py-package
- License: mit
- Created: 2022-04-21T07:03:31.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-04-03T11:59:43.000Z (about 2 years ago)
- Last Synced: 2025-04-23T14:14:26.868Z (2 months ago)
- Topics: masonite, python
- Language: Python
- Homepage:
- Size: 107 KB
- Stars: 10
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Masonite Audit
![]()
## Introduction
Keep track of all your model changes with ease.
## Getting Started
Install the package using pip:
```bash
pip install masonite-audit
```Add AuditProvider to your project in `config/providers.py`:
```python
# config/providers.py
# ...
from masonite_audit import AuditProvider# ...
PROVIDERS = [
# ...
# Third Party Providers
AuditProvider,
# ...
]
```Publish the package configuration files.
```bash
python craft package:publish masonite-audit
```This will add migrations and other `masonite-audit` related configuration to your project. Run your migrations to create the related database tables.
```bash
python craft migrate
```Finally, inherit `Audit` mixin into all the models for which you need audit logging.
```python
from masonite_audit.mixins import Audit
class YourModel(Audit):
pass
```If you want to get the audit history for a model, you can use the `history` method:
```python
user = User.find(1)
user.history()
```In order to rollback to previous versions of a model, you can use the `rollback` method:
```python
user = User.find(1)
user.rollback() # to rollback to previous version
# or
user.rollback(step=4) # to rollback to version 4
```## License
Masonite Audit is open-sourced software licensed under the [MIT license](LICENSE).