Impossible to delete a user on Open EDX installed with Tutor

Hi all,

I am having trouble deleting users on my edx platform (installed using Tutor, which is an amazing tool :slight_smile: ). I tried different methods:

  1. Logging in as an lms user (student user created for testing purpose) and then ask to delete my account β†’ this redirects to an Error 500 page, when I check the log I see the following error: django.db.utils.ProgrammingError: (1146, "Table 'openedx.proctoring_proctoredexamstudentattempt_history' doesn't exist")

  2. Logging in as a superuser on the admin interface and trying to delete the account β†’ this also redirects to an Error 500 page, same error in the logs: django.db.utils.ProgrammingError: (1146, "Table 'openedx.proctoring_proctoredexamstudentattempt_history' doesn't exist")

  3. From the command line using tutor local run lms ./manage.py lms manage_user --remove <user_name> <user_email> β†’ returns the same error as above: django.db.utils.ProgrammingError: (1146, "Table 'openedx.proctoring_proctoredexamstudentattempt_history' doesn't exist")

  4. From the command line running tutor local run cms ./manage.py cms manage_user --remove <user_name> <user_email> β†’ same error in the logs

Any idea how to resolve this issue ?

Thanks a lot!

Hi! Which tutor version are you running? Did you correctly initialise the database with tutor local init? Can you share the full stracktrace? I believe that the missing table was recently introduced when we upgraded a third-party dependency.

Hi @regis and thanks a lot for your quick reply.
The command pip freeze displays tutor-openedx==12.0.1 and the command tutor --version displays tutor, version 12.1.7.

I am not sure I have ever run the the tutor local init command. I just checked the docs again and I think I skipped this command unintentionally (I probably did not notice it, but I am not 100% sure). Is it Ok to run it now ? Will I loose data ? The platform is already running and I did not notice anything strange so far except account deletion (but I haven’t explored everything).

The command tutor local run lms ./manage.py lms manage_user --remove <user_name> <user_email> returns the following error:

Traceback (most recent call last):
  File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 71, in execute
    return self.cursor.execute(query, args)
  File "/openedx/venv/lib/python3.8/site-packages/MySQLdb/cursors.py", line 206, in execute
    res = self._query(query)
  File "/openedx/venv/lib/python3.8/site-packages/MySQLdb/cursors.py", line 319, in _query
    db.query(q)
  File "/openedx/venv/lib/python3.8/site-packages/MySQLdb/connections.py", line 259, in query
    _mysql.connection.query(self, query)
MySQLdb._exceptions.ProgrammingError: (1146, "Table 'openedx.proctoring_proctoredexamstudentattempt_history' doesn't exist")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "./manage.py", line 123, in <module>
    execute_from_command_line([sys.argv[0]] + django_args)
  File "/openedx/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/openedx/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/openedx/venv/lib/python3.8/site-packages/django/core/management/base.py", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/openedx/venv/lib/python3.8/site-packages/django/core/management/base.py", line 364, in execute
    output = self.handle(*args, **options)
  File "/opt/pyenv/versions/3.8.6/lib/python3.8/contextlib.py", line 75, in inner
    return func(*args, **kwds)
  File "/openedx/edx-platform/common/djangoapps/student/management/commands/manage_user.py", line 92, in handle
    return self._handle_remove(username, email)
  File "/openedx/edx-platform/common/djangoapps/student/management/commands/manage_user.py", line 85, in _handle_remove
    user.delete()
  File "/openedx/venv/lib/python3.8/site-packages/django/db/models/base.py", line 921, in delete
    collector.collect([self], keep_parents=keep_parents)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/models/deletion.py", line 223, in collect
    elif sub_objs:
  File "/openedx/venv/lib/python3.8/site-packages/django/db/models/query.py", line 278, in __bool__
    self._fetch_all()
  File "/openedx/venv/lib/python3.8/site-packages/django/db/models/query.py", line 1242, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "/openedx/venv/lib/python3.8/site-packages/django/db/models/query.py", line 55, in __iter__
    results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1142, in execute_sql
    cursor.execute(sql, params)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 76, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 71, in execute
    return self.cursor.execute(query, args)
  File "/openedx/venv/lib/python3.8/site-packages/MySQLdb/cursors.py", line 206, in execute
    res = self._query(query)
  File "/openedx/venv/lib/python3.8/site-packages/MySQLdb/cursors.py", line 319, in _query
    db.query(q)
  File "/openedx/venv/lib/python3.8/site-packages/MySQLdb/connections.py", line 259, in query
    _mysql.connection.query(self, query)
django.db.utils.ProgrammingError: (1146, "Table 'openedx.proctoring_proctoredexamstudentattempt_history' doesn't exist")
ERROR: 1
Error: Command failed with status 1: docker-compose -f /home/ubuntu/.local/share/tutor/env/local/docker-compose.yml -f /home/ubuntu/.local/share/tutor/env/local/docker-compose.prod.yml --project-name tutor_local run --rm lms ./manage.py lms manage_user --remove ...