[GH-ISSUE #2947] Error upgrading Modoboa #1719

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

Originally created by @jaysee on GitHub (Apr 10, 2023).
Original GitHub issue: https://github.com/modoboa/modoboa/issues/2947

Impacted versions

  • OS Type: Debian
  • OS Version: 11.6
  • Database Type: MySQL
  • Database version: X.y
  • Modoboa: 2.0.5
  • installer used: No
  • Webserver: Nginx

Steps to reproduce

Current behavior

during modoboa upgrade to 2.0.5, database upgrade fails :

Running migrations:
  Applying admin.0021_auto_20230410_1435...Traceback (most recent call last):
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/backends/mysql/base.py", line 73, in execute
    return self.cursor.execute(query, args)
  File "/srv/modoboa/env/lib/python3.9/site-packages/MySQLdb/cursors.py", line 206, in execute
    res = self._query(query)
  File "/srv/modoboa/env/lib/python3.9/site-packages/MySQLdb/cursors.py", line 319, in _query
    db.query(q)
  File "/srv/modoboa/env/lib/python3.9/site-packages/MySQLdb/connections.py", line 254, in query
    _mysql.connection.query(self, query)
MySQLdb.OperationalError: (1138, 'Invalid use of NULL value')

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

Traceback (most recent call last):
  File "/srv/modoboa/instance/manage.py", line 21, in <module>
    main()
  File "/srv/modoboa/instance/manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/core/management/base.py", line 89, in wrapped
    res = handle_func(*args, **kwargs)
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/core/management/commands/migrate.py", line 244, in handle
    post_migrate_state = executor.migrate(
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/migrations/executor.py", line 117, in migrate
    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/migrations/executor.py", line 227, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/migrations/migration.py", line 126, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/migrations/operations/fields.py", line 244, in database_forwards
    schema_editor.alter_field(from_model, from_field, to_field)
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/backends/base/schema.py", line 608, in alter_field
    self._alter_field(model, old_field, new_field, old_type, new_type,
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/backends/base/schema.py", line 830, in _alter_field
    self.execute(
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/backends/base/schema.py", line 145, in execute
    cursor.execute(sql, params)
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/backends/utils.py", line 66, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/backends/mysql/base.py", line 73, in execute
    return self.cursor.execute(query, args)
  File "/srv/modoboa/env/lib/python3.9/site-packages/MySQLdb/cursors.py", line 206, in execute
    res = self._query(query)
  File "/srv/modoboa/env/lib/python3.9/site-packages/MySQLdb/cursors.py", line 319, in _query
    db.query(q)
  File "/srv/modoboa/env/lib/python3.9/site-packages/MySQLdb/connections.py", line 254, in query
    _mysql.connection.query(self, query)
django.db.utils.OperationalError: (1138, 'Invalid use of NULL value')

Expected behavior

seem 0021_auto_20230410_1435.py is where I got the errors, but can't figure which table or field is causing troubles

Video/Screenshot link (optional)

Originally created by @jaysee on GitHub (Apr 10, 2023). Original GitHub issue: https://github.com/modoboa/modoboa/issues/2947 # Impacted versions * OS Type: Debian * OS Version: 11.6 * Database Type: MySQL * Database version: X.y * Modoboa: 2.0.5 * installer used: No * Webserver: Nginx # Steps to reproduce # Current behavior during modoboa upgrade to 2.0.5, database upgrade fails : ``` Running migrations: Applying admin.0021_auto_20230410_1435...Traceback (most recent call last): File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/backends/mysql/base.py", line 73, in execute return self.cursor.execute(query, args) File "/srv/modoboa/env/lib/python3.9/site-packages/MySQLdb/cursors.py", line 206, in execute res = self._query(query) File "/srv/modoboa/env/lib/python3.9/site-packages/MySQLdb/cursors.py", line 319, in _query db.query(q) File "/srv/modoboa/env/lib/python3.9/site-packages/MySQLdb/connections.py", line 254, in query _mysql.connection.query(self, query) MySQLdb.OperationalError: (1138, 'Invalid use of NULL value') The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/srv/modoboa/instance/manage.py", line 21, in <module> main() File "/srv/modoboa/instance/manage.py", line 17, in main execute_from_command_line(sys.argv) File "/srv/modoboa/env/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line utility.execute() File "/srv/modoboa/env/lib/python3.9/site-packages/django/core/management/__init__.py", line 413, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/srv/modoboa/env/lib/python3.9/site-packages/django/core/management/base.py", line 354, in run_from_argv self.execute(*args, **cmd_options) File "/srv/modoboa/env/lib/python3.9/site-packages/django/core/management/base.py", line 398, in execute output = self.handle(*args, **options) File "/srv/modoboa/env/lib/python3.9/site-packages/django/core/management/base.py", line 89, in wrapped res = handle_func(*args, **kwargs) File "/srv/modoboa/env/lib/python3.9/site-packages/django/core/management/commands/migrate.py", line 244, in handle post_migrate_state = executor.migrate( File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/migrations/executor.py", line 117, in migrate state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial) File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial) File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/migrations/executor.py", line 227, in apply_migration state = migration.apply(state, schema_editor) File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/migrations/migration.py", line 126, in apply operation.database_forwards(self.app_label, schema_editor, old_state, project_state) File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/migrations/operations/fields.py", line 244, in database_forwards schema_editor.alter_field(from_model, from_field, to_field) File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/backends/base/schema.py", line 608, in alter_field self._alter_field(model, old_field, new_field, old_type, new_type, File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/backends/base/schema.py", line 830, in _alter_field self.execute( File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/backends/base/schema.py", line 145, in execute cursor.execute(sql, params) File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/backends/utils.py", line 66, in execute return self._execute_with_wrappers(sql, params, many=False, executor=self._execute) File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers return executor(sql, params, many, context) File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/utils.py", line 90, in __exit__ raise dj_exc_value.with_traceback(traceback) from exc_value File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/backends/mysql/base.py", line 73, in execute return self.cursor.execute(query, args) File "/srv/modoboa/env/lib/python3.9/site-packages/MySQLdb/cursors.py", line 206, in execute res = self._query(query) File "/srv/modoboa/env/lib/python3.9/site-packages/MySQLdb/cursors.py", line 319, in _query db.query(q) File "/srv/modoboa/env/lib/python3.9/site-packages/MySQLdb/connections.py", line 254, in query _mysql.connection.query(self, query) django.db.utils.OperationalError: (1138, 'Invalid use of NULL value') ``` # Expected behavior seem `0021_auto_20230410_1435.py` is where I got the errors, but can't figure which table or field is causing troubles # Video/Screenshot link (optional)
kerem closed this issue 2026-02-27 11:18:45 +03:00
Author
Owner

@tonioo commented on GitHub (Apr 11, 2023):

@jaysee What version are you migrating from?

<!-- gh-comment-id:1502852755 --> @tonioo commented on GitHub (Apr 11, 2023): @jaysee What version are you migrating from?
Author
Owner

@tonioo commented on GitHub (Apr 11, 2023):

This migration is not part of the source code so I guess you created it manually running makemigrations command. Is that right?

<!-- gh-comment-id:1502855836 --> @tonioo commented on GitHub (Apr 11, 2023): This migration is not part of the source code so I guess you created it manually running ``makemigrations`` command. Is that right?
Author
Owner

@jaysee commented on GitHub (Apr 13, 2023):

@tonioo Yes I usually run make migration when doing upgrade (should'nt do I?)

This message pop's 2 versions ago so I think version 2.0.3 (not really sure)

<!-- gh-comment-id:1506437203 --> @jaysee commented on GitHub (Apr 13, 2023): @tonioo Yes I usually run make migration when doing upgrade (should'nt do I?) This message pop's 2 versions ago so I think version 2.0.3 (not really sure)
Author
Owner

@tonioo commented on GitHub (Apr 13, 2023):

@jaysee You should not have to run this command, it's not part of the upgrade process. Only migrate is.
If you see a warning about missing migrations, it means that we forgot to create a migration and that can be considered as a bug.

<!-- gh-comment-id:1506948647 --> @tonioo commented on GitHub (Apr 13, 2023): @jaysee You should not have to run this command, it's not part of the upgrade process. Only ``migrate`` is. If you see a warning about missing migrations, it means that we forgot to create a migration and that can be considered as a bug.
Author
Owner

@jaysee commented on GitHub (Apr 18, 2023):

Thanks @tonioo, I will try to clean that I impove my upgrade scripts to not use makemigrations anymore

<!-- gh-comment-id:1512818316 --> @jaysee commented on GitHub (Apr 18, 2023): Thanks @tonioo, I will try to clean that I impove my upgrade scripts to not use `makemigrations` anymore
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#1719
No description provided.