vvangelovski / django-audit-log

Audit log for your Django models
Other
232 stars 93 forks source link

Multiple MySQL database support #50

Open stefpiatek opened 6 years ago

stefpiatek commented 6 years ago

I've got a problem when I try to migrate an auditlogged model that isn't in the same MySQL database as the User table. It creates the table but then can't create the foreign key constraint and raises and IntegrityError

django.db.utils.IntegrityError: (1215, 'Cannot add foreign key constraint')

Tried with with Django 1.8 on Python 2.7 and Django 1.11 on Python 3.6, MySQL databases require the auditlogged model to be in the same database as the User table. SQLite databases don't have a problem here.

I've made a minimal example gist and hopefully I'm not missing something obvious.

After downloading set up virtual env

virtualenv .env
source .env/bin/activate
pip install -r pip_requirements.txt

Migration of default database

python manage.py migrate

Migrate second database with auditlogged model, raises IntegrityError

python manage.py migrate second --database=second