v2.28.8 升级 v3.10.13 jumpserver-installer 方式报错django.db.utils.OperationalError: (1091, "Can't DROP 'adhoc_id'; check that column/key exists")

  1. Init JumpServer Database
    WARN[0000] Found orphan containers ([jms_celery jms_lion jms_magnus jms_web jms_koko]) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.
    [+] Running 1/0
    ⠿ Container jms_core Running 0.0s
    2024-10-10 16:33:00 Collect static files
    ALLOWED_HOSTS:
  • localhost
  • core:8080
  • 127.0.0.1
  • 127.0.0.1:8080
  • 127.0.0.1:80
  • localhost:8080
  • localhost:80
  • core:8080
  • core:80
    ALLOWED_HOSTS:
  • localhost
  • core:8080
  • 127.0.0.1
  • 127.0.0.1:8080
  • 127.0.0.1:80
  • localhost:8080
  • localhost:80
  • core:8080
  • core:80
    2024-10-10 16:33:01 Collect static files done
    2024-10-10 16:33:01 Check database structure change …
    2024-10-10 16:33:01 Migrate model change to database …
    Operations to perform:
    Apply all migrations: accounts, acls, admin, applications, assets, audits, auth, authentication, captcha, common, contenttypes, django_cas_ng, django_celery_beat, labels, notifications, ops, orgs, perms, rbac, sessions, settings, terminal, tickets, users
    Running migrations:
    Applying ops.0022_auto_20220817_1346…2024-10-10 16:33:01 Perform migrate failed, exit
    Traceback (most recent call last):
    File “/opt/py3/lib/python3.11/site-packages/django/db/backends/utils.py”, line 89, in _execute
    return self.cursor.execute(sql, params)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File “/opt/py3/lib/python3.11/site-packages/django/db/backends/mysql/base.py”, line 75, in execute
    return self.cursor.execute(query, args)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File “/opt/py3/lib/python3.11/site-packages/MySQLdb/cursors.py”, line 179, in execute
    res = self._query(mogrified_query)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File “/opt/py3/lib/python3.11/site-packages/MySQLdb/cursors.py”, line 330, in _query
    db.query(q)
    File “/opt/py3/lib/python3.11/site-packages/MySQLdb/connections.py”, line 255, in query
    _mysql.connection.query(self, query)
    MySQLdb.OperationalError: (1091, “Can’t DROP ‘adhoc_id’; check that column/key exists”)

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

Traceback (most recent call last):
File “/opt/jumpserver/./jms”, line 88, in perform_db_migrate
management.call_command(‘migrate’)
File “/opt/py3/lib/python3.11/site-packages/django/core/management/init.py”, line 198, in call_command
return command.execute(*args, **defaults)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/py3/lib/python3.11/site-packages/django/core/management/base.py”, line 448, in execute
output = self.handle(*args, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/py3/lib/python3.11/site-packages/django/core/management/base.py”, line 96, in wrapped
res = handle_func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/py3/lib/python3.11/site-packages/django/core/management/commands/migrate.py”, line 349, in handle
post_migrate_state = executor.migrate(
^^^^^^^^^^^^^^^^^
File “/opt/py3/lib/python3.11/site-packages/django/db/migrations/executor.py”, line 135, in migrate
state = self._migrate_all_forwards(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/py3/lib/python3.11/site-packages/django/db/migrations/executor.py”, line 167, in _migrate_all_forwards
state = self.apply_migration(
^^^^^^^^^^^^^^^^^^^^^
File “/opt/py3/lib/python3.11/site-packages/django/db/migrations/executor.py”, line 252, in apply_migration
state = migration.apply(state, schema_editor)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/py3/lib/python3.11/site-packages/django/db/migrations/migration.py”, line 130, in apply
operation.database_forwards(
File “/opt/py3/lib/python3.11/site-packages/django/db/migrations/operations/fields.py”, line 170, in database_forwards
schema_editor.remove_field(
File “/opt/py3/lib/python3.11/site-packages/django/db/backends/base/schema.py”, line 724, in remove_field
self.execute(sql)
File “/opt/py3/lib/python3.11/site-packages/django/db/backends/base/schema.py”, line 199, in execute
cursor.execute(sql, params)
File “/opt/py3/lib/python3.11/site-packages/django/db/backends/utils.py”, line 67, in execute
return self._execute_with_wrappers(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/py3/lib/python3.11/site-packages/django/db/backends/utils.py”, line 80, in _execute_with_wrappers
return executor(sql, params, many, context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/py3/lib/python3.11/site-packages/django/db/backends/utils.py”, line 84, in _execute
with self.db.wrap_database_errors:
File “/opt/py3/lib/python3.11/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.11/site-packages/django/db/backends/utils.py”, line 89, in _execute
return self.cursor.execute(sql, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/py3/lib/python3.11/site-packages/django/db/backends/mysql/base.py”, line 75, in execute
return self.cursor.execute(query, args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/py3/lib/python3.11/site-packages/MySQLdb/cursors.py”, line 179, in execute
res = self._query(mogrified_query)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/py3/lib/python3.11/site-packages/MySQLdb/cursors.py”, line 330, in _query
db.query(q)
File “/opt/py3/lib/python3.11/site-packages/MySQLdb/connections.py”, line 255, in query
_mysql.connection.query(self, query)
django.db.utils.OperationalError: (1091, “Can’t DROP ‘adhoc_id’; check that column/key exists”)
[ERROR] Failed to change the table structure!

(root@jumpserver)>SHOW COLUMNS FROM ops_task;
±--------------------±-------------±-----±----±--------±------+
| Field | Type | Null | Key | Default | Extra |
±--------------------±-------------±-----±----±--------±------+
| id | char(32) | NO | PRI | NULL | |
| name | varchar(128) | NO | MUL | NULL | |
| interval | int(11) | YES | | NULL | |
| crontab | varchar(128) | YES | | NULL | |
| is_periodic | tinyint(1) | NO | | NULL | |
| callback | varchar(128) | YES | | NULL | |
| is_deleted | tinyint(1) | NO | | NULL | |
| comment | longtext | NO | | NULL | |
| org_id | varchar(36) | NO | MUL | NULL | |
| date_created | datetime(6) | NO | MUL | NULL | |
| date_updated | datetime(6) | NO | | NULL | |
| latest_adhoc_id | char(32) | YES | MUL | NULL | |
| latest_execution_id | char(32) | YES | MUL | NULL | |
| success_run_amount | int(11) | NO | | NULL | |
| total_run_amount | int(11) | NO | | NULL | |
±--------------------±-------------±-----±----±--------±------+
15 rows in set (0.00 sec)

跨度小一点的版本看看,先升级到v3.10.10试试

试过了 同一个报错

有查到这个字段吗,试一下手动加上这个字段

分别在 ops_adhoc 和ops_task 加了这个字段 升级报错不变

谢谢 可以了 每个小版本都升级可以了