社区版 4.10.16 → 4.10.17
在应用数据库更新阶段提示语法错误(该样本数据库使用docker版本mysql 5.7)
另一个样本数据库使用docker版本maridb 10.6,能够正常通过更新
补充报错信息
/opt/py3/lib/python3.14/site-packages/django/db/backends/utils.py:98: RuntimeWarning: Accessing the database during app initialization is discouraged. To fix this warning, avoid executing queries in AppConfig.ready() or when your app modules are imported.
warnings.warn(self.APPS_NOT_READY_WARNING_MSG, category=RuntimeWarning)
2026-07-17 16:43:22 Collect static files
2026-07-17 16:43:23 Collect static files done
2026-07-17 16:43:23 Check database structure change …
2026-07-17 16:43:23 Migrate model change to database …
Operations to perform:
Apply all migrations: accounts, acls, admin, assets, audits, auth, authentication, captcha, contenttypes, django_cas_ng, django_celery_beat, labels, notifications, oauth2_provider, ops, orgs, perms, rbac, reports, sessions, settings, terminal, tickets, users
Running migrations:
Applying assets.0020_favoritefolder… OK
Applying audits.0008_userloginlog_reason_code_userloginlog_reason_params… OK
Applying audits.0009_alter_passwordchangelog_datetime… OK
Applying authentication.0009_connectiontoken_input_secret_type… OK
Applying django_celery_beat.0019_alter_periodictasks_options… OK
Applying notifications.0003_messagecontent_display_mode… OK
Applying rbac.0005_report_create_delete_permissions… OK
Applying reports.0001_initial… OK
Applying reports.0002_alter_reportexecution_status… OK
Applying reports.0003_rename_report_range_days_to_days…2026-07-17 16:43:26 Perform migrate failed
Traceback (most recent call last):
File “/opt/py3/lib/python3.14/site-packages/django/db/backends/utils.py”, line 105, in _execute
return self.cursor.execute(sql, params)
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
File “/opt/py3/lib/python3.14/site-packages/django/db/backends/mysql/base.py”, line 76, in execute
return self.cursor.execute(query, args)
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
File “/opt/py3/lib/python3.14/site-packages/MySQLdb/cursors.py”, line 179, in execute
res = self._query(mogrified_query)
File “/opt/py3/lib/python3.14/site-packages/MySQLdb/cursors.py”, line 330, in _query
db.query(q)
~~~~~~~~^^^
File “/opt/py3/lib/python3.14/site-packages/MySQLdb/connections.py”, line 261, in query
_mysql.connection.query(self, query)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
MySQLdb.ProgrammingError: (1064, “You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘COLUMN range_days TO days’ at line 1”)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File “/opt/jumpserver/./jms”, line 213, in
upgrade_db()
~~~~~~~~~~^^
File “/opt/jumpserver/./jms”, line 146, in upgrade_db
perform_db_migrate()
~~~~~~~~~~~~~~~~~~^^
File “/opt/jumpserver/./jms”, line 94, in perform_db_migrate
raise e
File “/opt/jumpserver/./jms”, line 91, in perform_db_migrate
management.call_command(‘migrate’)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
File “/opt/py3/lib/python3.14/site-packages/django/core/management/init.py”, line 194, in call_command
return command.execute(*args, **defaults)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
File “/opt/py3/lib/python3.14/site-packages/django/core/management/base.py”, line 464, in execute
output = self.handle(*args, **options)
File “/opt/py3/lib/python3.14/site-packages/django/core/management/base.py”, line 111, in wrapper
res = handle_func(*args, **kwargs)
File “/opt/py3/lib/python3.14/site-packages/django/core/management/commands/migrate.py”, line 353, in handle
post_migrate_state = executor.migrate(
targets,
…<3 lines>…
fake_initial=fake_initial,
)
File “/opt/py3/lib/python3.14/site-packages/django/db/migrations/executor.py”, line 135, in migrate
state = self._migrate_all_forwards(
state, plan, full_plan, fake=fake, fake_initial=fake_initial
)
File “/opt/py3/lib/python3.14/site-packages/django/db/migrations/executor.py”, line 167, in _migrate_all_forwards
state = self.apply_migration(
state, migration, fake=fake, fake_initial=fake_initial
)
File “/opt/py3/lib/python3.14/site-packages/django/db/migrations/executor.py”, line 255, in apply_migration
state = migration.apply(state, schema_editor)
File “/opt/py3/lib/python3.14/site-packages/django/db/migrations/migration.py”, line 132, in apply
operation.database_forwards(
~~~~~~~~~~~~~~~~~~~~~~~~~~~^
self.app_label, schema_editor, old_state, project_state
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File “/opt/py3/lib/python3.14/site-packages/django/db/migrations/operations/fields.py”, line 311, in database_forwards
schema_editor.alter_field(
~~~~~~~~~~~~~~~~~~~~~~~~~^
from_model,
^^^^^^^^^^^
from_model._meta.get_field(self.old_name),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
to_model._meta.get_field(self.new_name),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File “/opt/py3/lib/python3.14/site-packages/django/db/backends/base/schema.py”, line 912, in alter_field
self._alter_field(
~~~~~~~~~~~~~~~~~^
model,
^^^^^^
…<6 lines>…
strict,
^^^^^^^
)
^
File “/opt/py3/lib/python3.14/site-packages/django/db/backends/base/schema.py”, line 1077, in _alter_field
self.execute(
~~~~~~~~~~~~^
self._rename_field_sql(
^^^^^^^^^^^^^^^^^^^^^^^
model._meta.db_table, old_field, new_field, new_type
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
)
^
File “/opt/py3/lib/python3.14/site-packages/django/db/backends/base/schema.py”, line 204, in execute
cursor.execute(sql, params)
~~~~~~~~~~~~~~^^^^^^^^^^^^^
File “/opt/py3/lib/python3.14/site-packages/django/db/backends/utils.py”, line 79, in execute
return self._execute_with_wrappers(
~~~~~~~~~~~~~~~~~~~~~~~~~~~^
sql, params, many=False, executor=self._execute
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File “/opt/py3/lib/python3.14/site-packages/django/db/backends/utils.py”, line 92, in _execute_with_wrappers
return executor(sql, params, many, context)
File “/opt/py3/lib/python3.14/site-packages/django/db/backends/utils.py”, line 100, in _execute
with self.db.wrap_database_errors:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/py3/lib/python3.14/site-packages/django/db/utils.py”, line 91, in exit
raise dj_exc_value.with_traceback(traceback) from exc_value
File “/opt/py3/lib/python3.14/site-packages/django/db/backends/utils.py”, line 105, in _execute
return self.cursor.execute(sql, params)
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
File “/opt/py3/lib/python3.14/site-packages/django/db/backends/mysql/base.py”, line 76, in execute
return self.cursor.execute(query, args)
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
File “/opt/py3/lib/python3.14/site-packages/MySQLdb/cursors.py”, line 179, in execute
res = self._query(mogrified_query)
File “/opt/py3/lib/python3.14/site-packages/MySQLdb/cursors.py”, line 330, in _query
db.query(q)
~~~~~~~~^^^
File “/opt/py3/lib/python3.14/site-packages/MySQLdb/connections.py”, line 261, in query
_mysql.connection.query(self, query)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
django.db.utils.ProgrammingError: (1064, “You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘COLUMN range_days TO days’ at line 1”)
[ERROR] Failed to change the table structure!
v4版本如果对接的数据库为mysql,建议版本在8.0+
mysql 版本太低啦,不再受支持了,迁移到mysql8版本吧
感谢回复,问题已解决