Upgrade using tutor local quickstart throws django.db.migrations.exceptions.InconsistentMigrationHistory error

I tried to update my installation with ‘tutor local quickstart’. However I get an error as follows :

How do I run migrations to restore consistency in the database?

Traceback (most recent call last):
  File "./manage.py", line 123, in <module>
    execute_from_command_line([sys.argv[0]] + django_args)
  File "/openedx/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "/openedx/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 356, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/openedx/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/openedx/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "/openedx/venv/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 86, in handle
    executor.loader.check_consistent_history(connection)
  File "/openedx/venv/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 299, in check_consistent_history
    connection.alias,
**django.db.migrations.exceptions.InconsistentMigrationHistory: Migration third_party_auth.0001_initial is applied before its dependency oauth2.0001_initial on database 'default'.**
Error: Command failed with status 1: docker-compose -f /home/USERNAME/.local/share/tutor/env/local/docker-compose.yml --project-name tutor_local -f /home/USERNAME/.local/share/tutor/env/local/docker-compose.jobs.yml run --rm lms-job sh -e -c dockerize -wait tcp://mysql:3306 -timeout 20s

export DJANGO_SETTINGS_MODULE=$SERVICE_VARIANT.envs.$SETTINGS
echo "Loading settings $DJANGO_SETTINGS_MODULE"

./manage.py lms migrate

./manage.py lms create_oauth2_client \
    "http://androidapp.com" "http://androidapp.com/redirect" public \
    --client_id android --client_secret <KEY> \
    --trusted

# Fix incorrect uploaded file path
if [ -d /openedx/data/uploads/ ]; then
  if [ -n "$(ls -A /openedx/data/uploads/)" ]; then
    echo "Migrating LMS uploaded files to shared directory"
    mv /openedx/data/uploads/* /openedx/media/
    rm -rf /openedx/data/uploads/
  fi
fi

Thanks a lot for your help

Which version are you upgrading from, and to?

I have a version : 3.12.6

I did a restart of the server and then did a tutor local quickstart and the error comes after the pullimages part.

I think, might be in the init command part(might be I am wrong)

Thanks @regis

@regis Looks like this happens when I move from Ironwood to Juniper