[GH-ISSUE #3757] can't delete identity #1894

Closed
opened 2026-02-27 11:19:45 +03:00 by kerem · 3 comments
Owner

Originally created by @xinomilo on GitHub (Oct 16, 2025).
Original GitHub issue: https://github.com/modoboa/modoboa/issues/3757

Impacted versions

  • OS Type: Debian
  • OS Version: 12
  • Database Type: MySQL
  • Database version: 10.11
  • Modoboa: 2.6.0
  • installer used: No
  • Webserver: Nginx

Steps to reproduce

try to delete any identity.

Current behavior

uwsgi log :
POST /api/v2/accounts/20/delete/ => generated 566 bytes in 478 msecs (HTTP/2.0 500) 5 headers in 181 bytes (1 switches on core 0)

attached file contains debug info send from modoboa with Subject : [Django] ERROR (EXTERNAL IP): Internal Server Error: /api/v2/accounts/20/delete/

already seen issue #3105 but (in anycase) there are no migrations pending.
"$ python manage.py makemigrations
No changes detected
"
" python manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, authtoken, autoreply, contacts, contenttypes, core, django_rq, dmarc, dnstools, lib, limits, maillog, oauth2_provider, otp_static, otp_totp, relaydomains, reversion, sessions, sites, transport
Running migrations:
No migrations to apply.
"

Expected behavior

remove identity and maildir.

info.txt

thanks,

Originally created by @xinomilo on GitHub (Oct 16, 2025). Original GitHub issue: https://github.com/modoboa/modoboa/issues/3757 # Impacted versions * OS Type: Debian * OS Version: 12 * Database Type: MySQL * Database version: 10.11 * Modoboa: 2.6.0 * installer used: No * Webserver: Nginx # Steps to reproduce try to delete any identity. # Current behavior uwsgi log : POST /api/v2/accounts/20/delete/ => generated 566 bytes in 478 msecs (HTTP/2.0 500) 5 headers in 181 bytes (1 switches on core 0) attached file contains debug info send from modoboa with Subject : [Django] ERROR (EXTERNAL IP): Internal Server Error: /api/v2/accounts/20/delete/ already seen issue #3105 but (in anycase) there are no migrations pending. "$ python manage.py makemigrations No changes detected " " python manage.py migrate Operations to perform: Apply all migrations: admin, auth, authtoken, autoreply, contacts, contenttypes, core, django_rq, dmarc, dnstools, lib, limits, maillog, oauth2_provider, otp_static, otp_totp, relaydomains, reversion, sessions, sites, transport Running migrations: No migrations to apply. " # Expected behavior remove identity and maildir. [info.txt](https://github.com/user-attachments/files/22945394/info.txt) thanks,
kerem 2026-02-27 11:19:45 +03:00
Author
Owner

@xinomilo commented on GitHub (Oct 16, 2025):

hmm, something to do with imap_migration.

when tying to login as a user i get this :
Error: Application imap_migration not registered

had disabled imap_migration module a few months ago, but somehow it was still needed(?)

just re-enabled module, run all manage.py migrate | check-deploy | etc, and then deleting identity works.. (?!)

should i open another bug on how to remove imap_migration module, without affecting other modoboa functions?

<!-- gh-comment-id:3410016510 --> @xinomilo commented on GitHub (Oct 16, 2025): hmm, something to do with imap_migration. when tying to login as a user i get this : Error: Application imap_migration not registered had disabled imap_migration module a few months ago, but somehow it was still needed(?) just re-enabled module, run all manage.py migrate | check-deploy | etc, and then deleting identity works.. (?!) should i open another bug on how to remove imap_migration module, without affecting other modoboa functions?
Author
Owner

@Spitfireap commented on GitHub (Oct 31, 2025):

You should be able to deactivate the imap_migration app even-though there is no real benefits doing it and it might break some things in the future.

Try this : removing it from INSTALLED_APPS and restart uwsgi service.
If the issue appears again, then re-add it to INSTALLED_APPS and execute this :
/srv/modoboa/env/bin/python /srv/modoboa/instance/manage.py migrate modoboa.imap_migration zero
Then remove it from INSTALLED_APPS.

<!-- gh-comment-id:3475025014 --> @Spitfireap commented on GitHub (Oct 31, 2025): You should be able to deactivate the imap_migration app even-though there is no real benefits doing it and it might break some things in the future. Try this : removing it from INSTALLED_APPS and restart uwsgi service. If the issue appears again, then re-add it to INSTALLED_APPS and execute this : `/srv/modoboa/env/bin/python /srv/modoboa/instance/manage.py migrate modoboa.imap_migration zero` Then remove it from INSTALLED_APPS.
Author
Owner

@xinomilo commented on GitHub (Nov 6, 2025):

  • removing from MODOBOA_APPS and restarting services, doesn't help. 500 error when trying to delete some identity.
  • readded to MODOBOA_APPS and executing this command results in error (bypassed 1st error as you can see below, but more errors occur..) :
➜  ~ /srv/modoboa/env/bin/python /srv/modoboa/instance/manage.py migrate modoboa.imap_migration zero
CommandError: No installed app with label 'modoboa.imap_migration'. Did you mean 'imap_migration'?

➜  ~ /srv/modoboa/env/bin/python /srv/modoboa/instance/manage.py migrate imap_migration zero 
Operations to perform:
  Unapply all migrations: imap_migration
Running migrations:
  Rendering model states... DONE
  Unapplying imap_migration.0005_auto_20210401_0938... OK
  Unapplying imap_migration.0004_auto_20190207_0939...Traceback (most recent call last):
  File "/srv/modoboa/env/lib/python3.11/site-packages/django/db/backends/utils.py", line 105, in _execute
    return self.cursor.execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/modoboa/env/lib/python3.11/site-packages/django/db/backends/mysql/base.py", line 76, in execute
    return self.cursor.execute(query, args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/modoboa/env/lib/python3.11/site-packages/MySQLdb/cursors.py", line 179, in execute
    res = self._query(mogrified_query)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/modoboa/env/lib/python3.11/site-packages/MySQLdb/cursors.py", line 330, in _query
    db.query(q)
  File "/srv/modoboa/env/lib/python3.11/site-packages/MySQLdb/connections.py", line 265, in query
    _mysql.connection.query(self, query)
MySQLdb.OperationalError: (1822, "Failed to add the foreign key constraint. Missing index for constraint 'imap_migration_migra_provider_id_def9a03d_fk_imap_migr' in the referenced table 'imap_migration_emailprovider'")

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

Traceback (most recent call last):
  File "/srv/modoboa/instance/manage.py", line 22, in <module>
    main()
  File "/srv/modoboa/instance/manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/srv/modoboa/env/lib/python3.11/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/srv/modoboa/env/lib/python3.11/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/srv/modoboa/env/lib/python3.11/site-packages/django/core/management/base.py", line 416, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/srv/modoboa/env/lib/python3.11/site-packages/django/core/management/base.py", line 460, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/modoboa/env/lib/python3.11/site-packages/django/core/management/base.py", line 107, in wrapper
    res = handle_func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/modoboa/env/lib/python3.11/site-packages/django/core/management/commands/migrate.py", line 353, in handle
    post_migrate_state = executor.migrate(
                         ^^^^^^^^^^^^^^^^^
  File "/srv/modoboa/env/lib/python3.11/site-packages/django/db/migrations/executor.py", line 141, in migrate
    state = self._migrate_all_backwards(plan, full_plan, fake=fake)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/modoboa/env/lib/python3.11/site-packages/django/db/migrations/executor.py", line 219, in _migrate_all_backwards
    self.unapply_migration(states[migration], migration, fake=fake)
  File "/srv/modoboa/env/lib/python3.11/site-packages/django/db/migrations/executor.py", line 282, in unapply_migration
    state = migration.unapply(state, schema_editor)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/modoboa/env/lib/python3.11/site-packages/django/db/migrations/migration.py", line 193, in unapply
    operation.database_backwards(
  File "/srv/modoboa/env/lib/python3.11/site-packages/django/db/migrations/operations/fields.py", line 246, in database_backwards
    self.database_forwards(app_label, schema_editor, from_state, to_state)
  File "/srv/modoboa/env/lib/python3.11/site-packages/django/db/migrations/operations/fields.py", line 241, in database_forwards
    schema_editor.alter_field(from_model, from_field, to_field)
  File "/srv/modoboa/env/lib/python3.11/site-packages/django/db/backends/base/schema.py", line 912, in alter_field
    self._alter_field(
  File "/srv/modoboa/env/lib/python3.11/site-packages/django/db/backends/base/schema.py", line 1269, in _alter_field
    self.execute(
  File "/srv/modoboa/env/lib/python3.11/site-packages/django/db/backends/base/schema.py", line 204, in execute
    cursor.execute(sql, params)
  File "/srv/modoboa/env/lib/python3.11/site-packages/django/db/backends/utils.py", line 79, in execute
    return self._execute_with_wrappers(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/modoboa/env/lib/python3.11/site-packages/django/db/backends/utils.py", line 92, in _execute_with_wrappers
    return executor(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/modoboa/env/lib/python3.11/site-packages/django/db/backends/utils.py", line 100, in _execute
    with self.db.wrap_database_errors:
  File "/srv/modoboa/env/lib/python3.11/site-packages/django/db/utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/srv/modoboa/env/lib/python3.11/site-packages/django/db/backends/utils.py", line 105, in _execute
    return self.cursor.execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/modoboa/env/lib/python3.11/site-packages/django/db/backends/mysql/base.py", line 76, in execute
    return self.cursor.execute(query, args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/modoboa/env/lib/python3.11/site-packages/MySQLdb/cursors.py", line 179, in execute
    res = self._query(mogrified_query)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/modoboa/env/lib/python3.11/site-packages/MySQLdb/cursors.py", line 330, in _query
    db.query(q)
  File "/srv/modoboa/env/lib/python3.11/site-packages/MySQLdb/connections.py", line 265, in query
    _mysql.connection.query(self, query)
django.db.utils.OperationalError: (1822, "Failed to add the foreign key constraint. Missing index for constraint 'imap_migration_migra_provider_id_def9a03d_fk_imap_migr' in the referenced table 'imap_migration_emailprovider'")

so, decided to leave it in MODOBOA_APPS, rerun migrate/collectstatic/check-deploy + restart uwsgi , and leave imap_migration as-is.

i think we can close this bug....(?)
since you suggest leaving imap_migration installed to avoid future issues, guess it doesn't hurt to, even though i won't be using it.

thx :)

<!-- gh-comment-id:3495996590 --> @xinomilo commented on GitHub (Nov 6, 2025): - removing from MODOBOA_APPS and restarting services, doesn't help. 500 error when trying to delete some identity. - readded to MODOBOA_APPS and executing this command results in error (bypassed 1st error as you can see below, but more errors occur..) : ``` ➜ ~ /srv/modoboa/env/bin/python /srv/modoboa/instance/manage.py migrate modoboa.imap_migration zero CommandError: No installed app with label 'modoboa.imap_migration'. Did you mean 'imap_migration'? ➜ ~ /srv/modoboa/env/bin/python /srv/modoboa/instance/manage.py migrate imap_migration zero Operations to perform: Unapply all migrations: imap_migration Running migrations: Rendering model states... DONE Unapplying imap_migration.0005_auto_20210401_0938... OK Unapplying imap_migration.0004_auto_20190207_0939...Traceback (most recent call last): File "/srv/modoboa/env/lib/python3.11/site-packages/django/db/backends/utils.py", line 105, in _execute return self.cursor.execute(sql, params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/modoboa/env/lib/python3.11/site-packages/django/db/backends/mysql/base.py", line 76, in execute return self.cursor.execute(query, args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/modoboa/env/lib/python3.11/site-packages/MySQLdb/cursors.py", line 179, in execute res = self._query(mogrified_query) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/modoboa/env/lib/python3.11/site-packages/MySQLdb/cursors.py", line 330, in _query db.query(q) File "/srv/modoboa/env/lib/python3.11/site-packages/MySQLdb/connections.py", line 265, in query _mysql.connection.query(self, query) MySQLdb.OperationalError: (1822, "Failed to add the foreign key constraint. Missing index for constraint 'imap_migration_migra_provider_id_def9a03d_fk_imap_migr' in the referenced table 'imap_migration_emailprovider'") The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/srv/modoboa/instance/manage.py", line 22, in <module> main() File "/srv/modoboa/instance/manage.py", line 18, in main execute_from_command_line(sys.argv) File "/srv/modoboa/env/lib/python3.11/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line utility.execute() File "/srv/modoboa/env/lib/python3.11/site-packages/django/core/management/__init__.py", line 436, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/srv/modoboa/env/lib/python3.11/site-packages/django/core/management/base.py", line 416, in run_from_argv self.execute(*args, **cmd_options) File "/srv/modoboa/env/lib/python3.11/site-packages/django/core/management/base.py", line 460, in execute output = self.handle(*args, **options) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/modoboa/env/lib/python3.11/site-packages/django/core/management/base.py", line 107, in wrapper res = handle_func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/modoboa/env/lib/python3.11/site-packages/django/core/management/commands/migrate.py", line 353, in handle post_migrate_state = executor.migrate( ^^^^^^^^^^^^^^^^^ File "/srv/modoboa/env/lib/python3.11/site-packages/django/db/migrations/executor.py", line 141, in migrate state = self._migrate_all_backwards(plan, full_plan, fake=fake) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/modoboa/env/lib/python3.11/site-packages/django/db/migrations/executor.py", line 219, in _migrate_all_backwards self.unapply_migration(states[migration], migration, fake=fake) File "/srv/modoboa/env/lib/python3.11/site-packages/django/db/migrations/executor.py", line 282, in unapply_migration state = migration.unapply(state, schema_editor) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/modoboa/env/lib/python3.11/site-packages/django/db/migrations/migration.py", line 193, in unapply operation.database_backwards( File "/srv/modoboa/env/lib/python3.11/site-packages/django/db/migrations/operations/fields.py", line 246, in database_backwards self.database_forwards(app_label, schema_editor, from_state, to_state) File "/srv/modoboa/env/lib/python3.11/site-packages/django/db/migrations/operations/fields.py", line 241, in database_forwards schema_editor.alter_field(from_model, from_field, to_field) File "/srv/modoboa/env/lib/python3.11/site-packages/django/db/backends/base/schema.py", line 912, in alter_field self._alter_field( File "/srv/modoboa/env/lib/python3.11/site-packages/django/db/backends/base/schema.py", line 1269, in _alter_field self.execute( File "/srv/modoboa/env/lib/python3.11/site-packages/django/db/backends/base/schema.py", line 204, in execute cursor.execute(sql, params) File "/srv/modoboa/env/lib/python3.11/site-packages/django/db/backends/utils.py", line 79, in execute return self._execute_with_wrappers( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/modoboa/env/lib/python3.11/site-packages/django/db/backends/utils.py", line 92, in _execute_with_wrappers return executor(sql, params, many, context) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/modoboa/env/lib/python3.11/site-packages/django/db/backends/utils.py", line 100, in _execute with self.db.wrap_database_errors: File "/srv/modoboa/env/lib/python3.11/site-packages/django/db/utils.py", line 91, in __exit__ raise dj_exc_value.with_traceback(traceback) from exc_value File "/srv/modoboa/env/lib/python3.11/site-packages/django/db/backends/utils.py", line 105, in _execute return self.cursor.execute(sql, params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/modoboa/env/lib/python3.11/site-packages/django/db/backends/mysql/base.py", line 76, in execute return self.cursor.execute(query, args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/modoboa/env/lib/python3.11/site-packages/MySQLdb/cursors.py", line 179, in execute res = self._query(mogrified_query) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/modoboa/env/lib/python3.11/site-packages/MySQLdb/cursors.py", line 330, in _query db.query(q) File "/srv/modoboa/env/lib/python3.11/site-packages/MySQLdb/connections.py", line 265, in query _mysql.connection.query(self, query) django.db.utils.OperationalError: (1822, "Failed to add the foreign key constraint. Missing index for constraint 'imap_migration_migra_provider_id_def9a03d_fk_imap_migr' in the referenced table 'imap_migration_emailprovider'") ``` so, decided to leave it in MODOBOA_APPS, rerun migrate/collectstatic/check-deploy + restart uwsgi , and leave imap_migration as-is. i think we can close this bug....(?) since you suggest leaving imap_migration installed to avoid future issues, guess it doesn't hurt to, even though i won't be using it. thx :)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/modoboa-modoboa#1894
No description provided.