InconsistentMigrationHistory with devstack make dev.provision command

This is my log

System check identified some issues:

WARNINGS:
?: (2_0.W001) Your URL pattern ‘edx_name_affirmation/v1/verified_name/(?P<verified_name_id>\d+)$’ [name=‘verified_name_by_id’] has a route that contains ‘(?P<’, begins with a ‘^’, or ends with a ‘$’. This was likely an oversight when migrating to django.urls.path().
consent.DataSharingConsent.granted: (fields.W903) NullBooleanField is deprecated. Support for it (except in historical migrations) will be removed in Django 4.0.
HINT: Use BooleanField(null=True) instead.
consent.HistoricalDataSharingConsent.granted: (fields.W903) NullBooleanField is deprecated. Support for it (except in historical migrations) will be removed in Django 4.0.
HINT: Use BooleanField(null=True) instead.
Traceback (most recent call last):
File “manage.py”, line 106, in
execute_from_command_line([sys.argv[0]] + django_args)
File “/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/core/management/init.py”, line 419, in execute_from_command_line
utility.execute()
File “/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/core/management/init.py”, line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File “/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/core/management/base.py”, line 354, in run_from_argv
self.execute(*args, **cmd_options)
File “/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/core/management/base.py”, line 398, in execute
output = self.handle(*args, **options)
File “/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/core/management/base.py”, line 89, in wrapped
res = handle_func(*args, **kwargs)
File “/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/core/management/commands/migrate.py”, line 95, in handle
executor.loader.check_consistent_history(connection)
File “/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/db/migrations/loader.py”, line 306, in check_consistent_history
raise InconsistentMigrationHistory(
django.db.migrations.exceptions.InconsistentMigrationHistory: Migration commerce.0001_data__add_ecommerce_service_user is applied before its dependency user_api.0002_retirementstate_userretirementstatus on database ‘default’.

Captured Task Output:

—> pavelib.servers.update_db
—> pavelib.prereqs.install_prereqs
—> pavelib.prereqs.install_node_prereqs
—> pavelib.prereqs.install_python_prereqs
—> pavelib.prereqs.uninstall_python_packages
pip freeze > /edx/app/edxapp/edx-platform/test_root/log/pip_freeze.log
NO_EDXAPP_SUDO=1 EDX_PLATFORM_SETTINGS_OVERRIDE=devstack_docker /edx/bin/edxapp-migrate-lms --traceback --pythonpath=.

Build failed running pavelib.servers.update_db: Subprocess return code: 1
Makefile:44: recipe for target ‘dev.provision.run’ failed
make: *** [dev.provision.run] Error 1

I cam across simlair error before; but I am not sure if it had cause as you; I was tryting to upgrade the Open edX platform while skipping versions in between e.g. upgrading directly from lilac to nutmeg skipping maple So if you are in a simliar position try to upgrade one version at a time; i.e lilac to maple; then maple to nutmeg.

Again you might see this error for a different reason; this just my personal expirence with this error which might or might not match your current situation

I followed this guide

All of the services can be run by following the steps below. For analyticstack, follow Getting Started on Analytics_.

NOTE: Since a Docker-based devstack runs many containers, you should configure Docker with a sufficient amount of resources. We find that configuring Docker for Mac_ with a minimum of 2 CPUs and 6GB of memory works well.

  1. Install the requirements inside of a Python virtualenv_… code:: sh
make requirements
  1. The Docker Compose file mounts a host volume for each service’s executing code. The host directory defaults to be a sibling of this directory. For example, if this repo is cloned to ~/workspace/devstack, host volumes will be expected in ~/workspace/course-discovery, ~/workspace/ecommerce, etc. These repos can be cloned with the command below… code:: sh
make dev.clone

You may customize where the local repositories are found by setting the DEVSTACK_WORKSPACE environment variable.Be sure to share the cloned directories in the Docker → Preferences… → File Sharing box.
3. Run the provision command, if you haven’t already, to configure the various services with superusers (for development without the auth service) and tenants (for multi-tenancy).NOTE: When running the provision command, databases for ecommerce and edxapp will be dropped and recreated.The username and password for the superusers are both edx. You can access the services directly via Django admin at the /admin/ path, or login via single sign-on at /login/.Default:… code:: sh

make dev.provision

First Devstack is deprecated so its common to face issue, you could look into using tutor GitHub - overhangio/tutor: The docker-based Open edX distribution designed for peace of mind .
Secondly if its your first time running devstack or the platform; try running make dev.destroy followed by make dev.provision The effect of this is all your data be destroyed and the database/data will be created again

Thank you very much