Skip to content

Multiple MySQL database support #50

@stefpiatek

Description

@stefpiatek

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions