How to solve 'django.db.migrations.exceptions.InconsistentMigrationHistory' error?? (using powershell/VSCode)

I am making a web app (I am a student and this is my first attempt of building a project) using stack: Django, Vue and MySQL. Attaching link to git repo here: https://github.com/yeshapan/LearningDashboard (please refer ReadME for details)

I completed initial setup and then created an app called dashboard where I defined models for the features.

Edit: Here's the error message as text:

Traceback (most recent call last):
  File "C:\Users\DELL\Desktop\LearningDashboard\manage.py", line 22, in <module>
    main()
  File "C:\Users\DELL\Desktop\LearningDashboard\manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "C:\Users\DELL\Desktop\LearningDashboard\venv\Lib\site-packages\django\core\management\__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "C:\Users\DELL\Desktop\LearningDashboard\venv\Lib\site-packages\django\core\management\__init__.py", line 436, in execute   
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\DELL\Desktop\LearningDashboard\venv\Lib\site-packages\django\core\management\base.py", line 413, in run_from_argv 
    self.execute(*args, **cmd_options)
  File "C:\Users\DELL\Desktop\LearningDashboard\venv\Lib\site-packages\django\core\management\base.py", line 459, in execute       
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\DELL\Desktop\LearningDashboard\venv\Lib\site-packages\django\core\management\base.py", line 107, in wrapper       
    res = handle_func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\DELL\Desktop\LearningDashboard\venv\Lib\site-packages\django\core\management\commands\migrate.py", line 121, in handle
    executor.loader.check_consistent_history(connection)
  File "C:\Users\DELL\Desktop\LearningDashboard\venv\Lib\site-packages\django\db\migrations\loader.py", line 327, in check_consistent_history
    raise InconsistentMigrationHistory(
django.db.migrations.exceptions.InconsistentMigrationHistory: Migration admin.0001_initial is applied before its dependency dashboard.0001_initial on database 'default'.

However, it is raising error: Error message I tried asking ChatGPT for help.

It said to delete everything in dashboard/migrations and delete db.sqlite3 file in root folder (Edit: I also deleted the table from MySQL and applied migrations again but it is still giving error) and apply migrations again. I did so but it keeps showing the same error. Please guide me how am I supposed to solve this error??

NOTE: (Also, since this is my first project ever and I only know the basics of python and MySQL) and I'm learning everything else as I go, so any advice in general would be really helpful and much appreciated

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