django.db.migrations.exceptions.InconsistentMigrationHistory

Hari Krishnan :

When I run python manage.py migrate on my Django project, I get the following error:

Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/home/hari/project/env/local/lib/python2.7/site-     packages/django/core/management/__init__.py", line 363, in execute_from_command_line
utility.execute()
File "/home/hari/project/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 355, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/hari/project/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/hari/project/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/home/hari/project/env/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 86, in handle
executor.loader.check_consistent_history(connection)
File "/home/hari/project/env/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 298, in check_consistent_history
connection.alias,
django.db.migrations.exceptions.InconsistentMigrationHistory: Migration admin.0001_initial is applied before its dependency account.0001_initial on database 'default'.

I have a user model like below:

class User(AbstractUser):
    place = models.CharField(max_length=64, null=True, blank=True)
    address = models.CharField(max_length=128, null=True, blank=True)

How can I solve this problem?

Arpit Solanki :

Your django_migrations table in your database is the cause of inconsistency and deleting all the migrations just from local path won't work.

You have to truncate the django_migrations table from your database and then try applying the migrations again. It should work but if it does not then run makemigrations again and then migrate.

Note: don't forget to take a backup of your data.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

django.db.migrations.exceptions.NodeNotFoundError

django.db.migrations.exceptions.CircularDependencyError

Django DB Migration InconsistentMigrationHistory when running migrate

Deleting Migration Files and Getting django.db.migrations.exceptions.NodeNotFoundError:

How do you solve django.db.migrations.exceptions.NodeNotFoundError in Django?

django.db.migrations.exceptions.NodeNotFoundError Migration authentication nonexistent parent node

Automatic db router for migrations in django

Django on Kubernetes Deployment: Best practices for DB Migrations

ValueError while making db migrations in django

"django.core.exceptions.ImproperlyConfigured:" while doing migrations to posgreSQL

Skip exceptions doctrine migrations

How to force migrations to a DB if some tables already exist in Django?

Django make migrations issue changing to new Postgres DB

New Django app initial DB migrations of an existing database

Do django db_index migrations run concurrently?

django.db.migrations.RenameModel and AutoField sequence name

from django.db import models, migrations ImportError: cannot import name migrations

Django migrations

Running django migrations on windows for remote mssql db with native windows db drivers

Apostrophe CMS db migrations

CodeFirst DB Migrations with Azure

Getting error while syncdb django.db.utils.ProgrammingError: permission denied for relation django_migrations

django.db.utils.IntegrityError: duplicate key value violates unique constraint "django_migrations_pkey"

Steps to Troubleshoot "django.db.utils.ProgrammingError: permission denied for relation django_migrations"

Django Migrations ValueError: Could not find manager in django.db.models.manager

How to set default column value in the db using django 1.7.3/postgres migrations?

How to read data from an External Server and apply migrations on a local Db file in Django?

Django-DB-Migrations: cannot ALTER TABLE because it has pending trigger events

Django-DB-Migrations: cannot ALTER TABLE because it has pending trigger events

TOP Ranking

  1. 1

    How can I create a column whose entries depend on the contents of a column in another table?

  2. 2

    pump.io port in URL

  3. 3

    How to display items using sessions

  4. 4

    BigQuery - concatenate ignoring NULL

  5. 5

    no applicable method for 'mutate_' applied to an object of class "c('integer', 'numeric')"

  6. 6

    How i extract text from a model dialog in selenium?

  7. 7

    x no applicable method for 'tbl_vars' applied to an object of class "c('double', 'numeric')"

  8. 8

    AirflowException: Celery command failed - The recorded hostname does not match this instance's hostname

  9. 9

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  10. 10

    Most efficient regex for checking if a string contains at least 3 alphanumeric characters

  11. 11

    using excel range find return Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))

  12. 12

    redirect your computer port to url

  13. 13

    Can't create database with Symfony 4.1 : could not find driver

  14. 14

    How to fix "Exception evaluating SpringEL expression" error after submitting a variable Spring/Thymeleaf

  15. 15

    A python function to get the maximum value of a specific column, given a string that represents a table in CSV format

  16. 16

    Double spacing in rmarkdown pdf

  17. 17

    Uploading Files on production server returns either CORS error or POST 400 Bad Request using Apollo-Graphql

  18. 18

    Android Kotlin Unit test failing with io.mockk.MockKException: no answer found for

  19. 19

    Change Model input_shape but got an : ValueError: Input 0 of layer dense_44 is incompatible with the layer

  20. 20

    Formik, Yup - How to check is Decimal number

  21. 21

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

HotTag

Archive