[GH-ISSUE #1831] Can't create table 'mail.#sql-498_15864' (errno: 150) #1437

Closed
opened 2026-02-27 11:17:06 +03:00 by kerem · 4 comments
Owner

Originally created by @ndoody on GitHub (Jan 30, 2020).
Original GitHub issue: https://github.com/modoboa/modoboa/issues/1831

I have tried to upgrade from older modoboa versions to the latest, going through versions in series and running the upgrade procedure (python manage.py migrate) but it is having a problem creating some new tables for some of the new features / upgraded plugins.

I can run the command above and get the error "errno: 150" trying to create the temporary table, but the correct table is created (dnstools_dnsrecord) it's just empty and running subsequent migrations comes back wit the error that this table is already created.

Can reproduce by dropping the SQL table above and trying to migrate again.

Impacted versions

  • Modoboa: 1.3.1/1.4.0
  • installer used: pip install
  • Webserver: Apache

Steps to reproduce

Run python manage.py migrate after upgrading

Current behavior

Applying dnstools.0001_initial...Traceback (most recent call last):
File "manage.py", line 10, in
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/site-packages/django/core/management/init.py", line 364, in execute_from_command_line
utility.execute()
File "/usr/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 "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 204, in handle
fake_initial=fake_initial,
File "/usr/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 115, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "/usr/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 145, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "/usr/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 244, in apply_migration
state = migration.apply(state, schema_editor)
File "/usr/local/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 109, in exit
self.execute(sql)
File "/usr/local/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 136, in execute
cursor.execute(sql, params)
File "/usr/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/usr/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/site-packages/django/db/utils.py", line 94, in exit
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 101, in execute
return self.cursor.execute(query, args)
File "build/bdist.freebsd-9.2-RELEASE-p7-i386/egg/MySQLdb/cursors.py", line 205, in execute
File "build/bdist.freebsd-9.2-RELEASE-p7-i386/egg/MySQLdb/connections.py", line 36, in defaulterrorhandler
django.db.utils.OperationalError: (1005, "Can't create table 'mail.#sql-498_15864' (errno: 150)")

Expected behavior

The new table is created and the migrate procedure works without error.

Video/Screenshot link (optional)

Originally created by @ndoody on GitHub (Jan 30, 2020). Original GitHub issue: https://github.com/modoboa/modoboa/issues/1831 I have tried to upgrade from older modoboa versions to the latest, going through versions in series and running the upgrade procedure (python manage.py migrate) but it is having a problem creating some new tables for some of the new features / upgraded plugins. I can run the command above and get the error "errno: 150" trying to create the temporary table, but the correct table is created (dnstools_dnsrecord) it's just empty and running subsequent migrations comes back wit the error that this table is already created. Can reproduce by dropping the SQL table above and trying to migrate again. # Impacted versions * Modoboa: 1.3.1/1.4.0 * installer used: pip install * Webserver: Apache # Steps to reproduce Run python manage.py migrate after upgrading # Current behavior Applying dnstools.0001_initial...Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line utility.execute() File "/usr/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 "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv self.execute(*args, **cmd_options) File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 330, in execute output = self.handle(*args, **options) File "/usr/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 204, in handle fake_initial=fake_initial, File "/usr/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 115, in migrate state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial) File "/usr/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 145, in _migrate_all_forwards state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial) File "/usr/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 244, in apply_migration state = migration.apply(state, schema_editor) File "/usr/local/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 109, in __exit__ self.execute(sql) File "/usr/local/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 136, in execute cursor.execute(sql, params) File "/usr/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 79, in execute return super(CursorDebugWrapper, self).execute(sql, params) File "/usr/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) File "/usr/local/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__ six.reraise(dj_exc_type, dj_exc_value, traceback) File "/usr/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) File "/usr/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 101, in execute return self.cursor.execute(query, args) File "build/bdist.freebsd-9.2-RELEASE-p7-i386/egg/MySQLdb/cursors.py", line 205, in execute File "build/bdist.freebsd-9.2-RELEASE-p7-i386/egg/MySQLdb/connections.py", line 36, in defaulterrorhandler django.db.utils.OperationalError: (1005, "Can't create table 'mail.#sql-498_15864' (errno: 150)") # Expected behavior The new table is created and the migrate procedure works without error. # Video/Screenshot link (optional)
kerem closed this issue 2026-02-27 11:17:06 +03:00
Author
Owner

@tonioo commented on GitHub (Feb 4, 2020):

@ndoody Can you check to storage engine used by your database and the encoding please?

<!-- gh-comment-id:581783471 --> @tonioo commented on GitHub (Feb 4, 2020): @ndoody Can you check to storage engine used by your database and the encoding please?
Author
Owner

@ndoody commented on GitHub (Feb 4, 2020):

@tonioo It's innodb and Latin1 for the new tables.

This was changed previously as part of some recommendations of another bug where it Modoboa crashed from trying to render some text in spam mail with funny characters...what should it be set too?

<!-- gh-comment-id:581793087 --> @ndoody commented on GitHub (Feb 4, 2020): @tonioo It's innodb and Latin1 for the new tables. This was changed previously as part of some recommendations of another bug where it Modoboa crashed from trying to render some text in spam mail with funny characters...what should it be set too?
Author
Owner

@tonioo commented on GitHub (Feb 4, 2020):

@ndoody utf8_general_ci for the modoboa database would be better I think.

<!-- gh-comment-id:581938095 --> @tonioo commented on GitHub (Feb 4, 2020): @ndoody utf8_general_ci for the modoboa database would be better I think.
Author
Owner

@tonioo commented on GitHub (Feb 27, 2020):

@ndoody Have you tested the encoding change?

<!-- gh-comment-id:591970986 --> @tonioo commented on GitHub (Feb 27, 2020): @ndoody Have you tested the encoding change?
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#1437
No description provided.