Django-tenant-schema migration issue: IntegrityError: insert or update on table "auth_permission" violates foreign key constraint

requirements.txt:

Django==4.2.16
django-tenant-schemas==1.12.0`
django-allauth==65.0.2

Added a new django model, then ran migrations:

./manage.py migrate_schemas --schema=public
./manage.py migrate_schemas --schema=myschema

The first command runs fine. The second command gives this error:


django.db.utils.IntegrityError: insert or update on table "auth_permission" violates foreign key constraint "auth_permission_content_type_id_2f476e4b_fk_django_co"
DETAIL:  Key (content_type_id)=(115) is not present in table "django_content_type".

Indeed, the auth_permission table does not (yet) contain any permissions related to the new model.

But actually, value '115' is present in the public.django_content_type table, with the right app_label and model info.

So unclear why this error is raised. Maybe the migration is not looking in the public schema? But other migrations have been running for ages, only the new table creation seems to cause a problem now.

Вернуться на верх