Update v13 to V14 missing sequences

Hello I have a stange behavior after an upgrade from v13 to V14

### App Versions

{
	"erpnext": "14.24.1",
	"frappe": "14.36.1"
}

### Route

Workspaces/private/Home

### Traceback

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 66, in application
    response = frappe.api.handle()
  File "apps/frappe/frappe/api.py", line 54, in handle
    return frappe.handler.handle()
  File "apps/frappe/frappe/handler.py", line 45, in handle
    data = execute_cmd(cmd)
  File "apps/frappe/frappe/handler.py", line 83, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "apps/frappe/frappe/__init__.py", line 1607, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/handler.py", line 117, in logout
    frappe.local.login_manager.logout()
  File "apps/frappe/frappe/auth.py", line 332, in logout
    delete_session(frappe.session.sid, user=user, reason="User Manually Logged Out")
  File "apps/frappe/frappe/sessions.py", line 108, in delete_session
    logout_feed(user, reason)
  File "apps/frappe/frappe/core/doctype/activity_log/feed.py", line 61, in logout_feed
    add_authentication_log(subject, user, operation="Logout")
  File "apps/frappe/frappe/core/doctype/activity_log/activity_log.py", line 43, in add_authentication_log
    frappe.get_doc(
  File "apps/frappe/frappe/model/document.py", line 254, in insert
    self.set_new_name(set_name=set_name, set_child_names=set_child_names)
  File "apps/frappe/frappe/model/document.py", line 450, in set_new_name
    set_new_name(self)
  File "apps/frappe/frappe/model/naming.py", line 149, in set_new_name
    doc.name = frappe.db.get_next_sequence_val(doc.doctype)
  File "apps/frappe/frappe/database/database.py", line 1327, in get_next_sequence_val
    return get_next_val(*args, **kwargs)
  File "apps/frappe/frappe/database/sequence.py", line 68, in get_next_val
    return db.sql(f"SELECT nextval({sequence_name})")[0][0]
  File "apps/frappe/frappe/database/database.py", line 219, in sql
    self._cursor.execute(query, values)
  File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 158, in execute
    result = self._query(query)
  File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 325, in _query
    conn.query(q)
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 549, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 779, in _read_query_result
    result.read()
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 1157, in read
    first_packet = self.connection._read_packet()
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 729, in _read_packet
    packet.raise_for_error()
  File "env/lib/python3.10/site-packages/pymysql/protocol.py", line 221, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "env/lib/python3.10/site-packages/pymysql/err.py", line 143, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.OperationalError: (4091, "Unknown SEQUENCE: 'activity_log_id_seq'")


### Request Data

{
	"type": "POST",
	"args": {},
	"headers": {},
	"error_handlers": {},
	"url": "/api/method/logout"
}

### Response Data

{
	"exception": "pymysql.err.OperationalError: (4091, \"Unknown SEQUENCE: 'activity_log_id_seq'\")"
}

There are others missing sequences so I think it’s a specific patch but I cannot say which one

I have run :

  • bench new-site
  • bench restore
  • bench migrate

Should I run another command to restore sequences ?

Thanks

Another example when I try to print a PDF

Traceback (most recent call last):
  File "apps/frappe/frappe/website/serve.py", line 18, in get_response
    response = renderer_instance.render()
  File "apps/frappe/frappe/website/page_renderers/template_page.py", line 84, in render
    html = self.get_html()
  File "apps/frappe/frappe/website/utils.py", line 510, in cache_html_decorator
    html = func(*args, **kwargs)
  File "apps/frappe/frappe/website/page_renderers/template_page.py", line 95, in get_html
    self.update_context()
  File "apps/frappe/frappe/website/page_renderers/template_page.py", line 163, in update_context
    data = self.run_pymodule_method("get_context")
  File "apps/frappe/frappe/website/page_renderers/template_page.py", line 225, in run_pymodule_method
    return method(self.context)
  File "apps/frappe/frappe/www/printview.py", line 47, in get_context
    make_access_log(
  File "apps/frappe/frappe/core/doctype/access_log/access_log.py", line 25, in make_access_log
    _make_access_log(
  File "apps/frappe/frappe/__init__.py", line 815, in wrapper_fn
    retval = fn(*args, **get_newargs(fn, kwargs))
  File "env/lib/python3.10/site-packages/tenacity/__init__.py", line 324, in wrapped_f
    return self(f, *args, **kw)
  File "env/lib/python3.10/site-packages/tenacity/__init__.py", line 404, in __call__
    do = self.iter(retry_state=retry_state)
  File "env/lib/python3.10/site-packages/tenacity/__init__.py", line 349, in iter
    return fut.result()
  File "/usr/local/lib/python3.10/concurrent/futures/_base.py", line 439, in result
    return self.__get_result()
  File "/usr/local/lib/python3.10/concurrent/futures/_base.py", line 391, in __get_result
    raise self._exception
  File "env/lib/python3.10/site-packages/tenacity/__init__.py", line 407, in __call__
    result = fn(*args, **kwargs)
  File "apps/frappe/frappe/core/doctype/access_log/access_log.py", line 65, in _make_access_log
    ).db_insert()
  File "apps/frappe/frappe/model/base_document.py", line 481, in db_insert
    set_new_name(self)
  File "apps/frappe/frappe/model/naming.py", line 149, in set_new_name
    doc.name = frappe.db.get_next_sequence_val(doc.doctype)
  File "apps/frappe/frappe/database/database.py", line 1327, in get_next_sequence_val
    return get_next_val(*args, **kwargs)
  File "apps/frappe/frappe/database/sequence.py", line 68, in get_next_val
    return db.sql(f"SELECT nextval({sequence_name})")[0][0]
  File "apps/frappe/frappe/database/database.py", line 219, in sql
    self._cursor.execute(query, values)
  File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 158, in execute
    result = self._query(query)
  File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 325, in _query
    conn.query(q)
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 549, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 779, in _read_query_result
    result.read()
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 1157, in read
    first_packet = self.connection._read_packet()
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 729, in _read_packet
    packet.raise_for_error()
  File "env/lib/python3.10/site-packages/pymysql/protocol.py", line 221, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "env/lib/python3.10/site-packages/pymysql/err.py", line 143, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.OperationalError: (4091, "Unknown SEQUENCE: 'access_log_id_seq'")