Opened 2 years ago

Closed 2 years ago

#33576 closed Bug (invalid)

InconsistentMigrationHistory when multiple projects with custom user models share the same database.

Reported by: Artem Owned by: nobody
Component: Core (Other) Version: 4.0
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hello.

I have multiple databases and use it in 2 project.

First project:

DATABASES = {
    'default': {
        'ENGINE': 'django.contrib.gis.db.backends.postgis',
        'NAME': 'main-admin',
    },
    'main': {
        'ENGINE': 'django.contrib.gis.db.backends.postgis',
        'NAME': 'main',
    },
}

Secondary project:

DATABASES = {
    'default': {
        'ENGINE': 'django.contrib.gis.db.backends.postgis',
        'NAME': 'articles-admin',
    },
    'articles': {
        'ENGINE': 'django.contrib.gis.db.backends.postgis',
        'NAME': 'articles',
    },
    'main': {
        'ENGINE': 'django.contrib.gis.db.backends.postgis',
        'NAME': 'main',
    },
}

I am config routers.
For example: https://monosnap.com/file/sblvTdWM9tmSx1DFxPhcI656SyRuHW

In first project I create database "main" and apply all migrations.
In secondary project I create CustomUser and apply migrations.

Then I create new migration in secondary project then look:
InconsistentMigrationHistory: Migration admin.0001_initial is applied before its dependency person.0001_initial on database 'main'

I need create next project with custom user and database "main".
But I will get an error again if now I delete the base and recreate it on the next project that will contain the base "main"

Main database migration sequence is not important, but every time I connect it to the next project and create a custom user, I will get an error

Change History (1)

comment:1 by Mariusz Felisiak, 2 years ago

Component: MigrationsCore (Other)
Resolution: invalid
Status: newclosed
Summary: CustomUser: InconsistentMigrationHistory in multiple databasesInconsistentMigrationHistory when multiple projects with custom user models share the same database.

It's not supported to use the same database for two projects with different user models because they will share the same tables for reusable apps e.g. django.contrib.admin, see docs about Substituting a custom User model. You will encounter many other conflicts with such set. Please see TicketClosingReasons/UseSupportChannels for ways to get help with Django usage.

Note: See TracTickets for help on using tickets.
Back to Top