HibiKier / zhenxun_bot

基于 Nonebot2 开发,非常可爱的绪山真寻bot
GNU Affero General Public License v3.0
3.32k stars 605 forks source link

启动时报错 #1581

Closed SHDocter closed 1 week ago

SHDocter commented 2 weeks ago
08-26 18:57:13 [ERROR] uvicorn | Traceback (most recent call last):
  File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-xRHTbRVY-py3.10/lib/python3.10/site-packages/tortoise/backends/asyncpg/client.py", line 82, in _translate_exceptions
    return await func(self, *args, **kwargs)
  File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-xRHTbRVY-py3.10/lib/python3.10/site-packages/tortoise/backends/asyncpg/client.py", line 136, in execute_query
    res = await connection.execute(*params)
  File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-xRHTbRVY-py3.10/lib/python3.10/site-packages/asyncpg/connection.py", line 350, in execute
    result = await self._protocol.query(query, timeout)
  File "asyncpg/protocol/protocol.pyx", line 374, in query
asyncpg.exceptions.UndefinedFunctionError: operator does not exist: character varying = integer
HINT:  No operator matches the given name and argument types. You might need to add explicit type casts.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-xRHTbRVY-py3.10/lib/python3.10/site-packages/starlette/routing.py", line 732, in lifespan
    async with self.lifespan_context(app) as maybe_state:
  File "/usr/python/lib/python3.10/contextlib.py", line 199, in __aenter__
    return await anext(self.gen)
  File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-xRHTbRVY-py3.10/lib/python3.10/site-packages/nonebot/drivers/fastapi.py", line 153, in _lifespan_manager
    await self._lifespan.startup()
  File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-xRHTbRVY-py3.10/lib/python3.10/site-packages/nonebot/internal/driver/_lifespan.py", line 42, in startup
    await self._run_lifespan_func(self._startup_funcs)
  File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-xRHTbRVY-py3.10/lib/python3.10/site-packages/nonebot/internal/driver/_lifespan.py", line 36, in _run_lifespan_func
    await cast(ASYNC_LIFESPAN_FUNC, func)()
  File "/home/zhenxun_bot-main/zhenxun/builtin_plugins/__init__.py", line 55, in _
    await GoodsInfo.bulk_update(goods_list, ["uuid"], 10)
  File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-xRHTbRVY-py3.10/lib/python3.10/site-packages/tortoise/queryset.py", line 1748, in _execute
    count += (await self._db.execute_query(str(query)))[0]
  File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-xRHTbRVY-py3.10/lib/python3.10/site-packages/tortoise/backends/base_postgres/client.py", line 34, in _translate_exceptions
    return await self._translate_exceptions(func, *args, **kwargs)
  File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-xRHTbRVY-py3.10/lib/python3.10/site-packages/tortoise/backends/asyncpg/client.py", line 84, in _translate_exceptions
    raise OperationalError(exc)
tortoise.exceptions.OperationalError: operator does not exist: character varying = integer
HINT:  No operator matches the given name and argument types. You might need to add explicit type casts.

08-26 18:57:13 [ERROR] uvicorn | Application startup failed. Exiting.

zhenxun/builtin_plugins/__init__.py中的55行

@driver.on_startup
async def _():
    """签到与用户的数据迁移"""
    if goods_list := await GoodsInfo.filter(uuid__isnull=True).all():
        for goods in goods_list:
            goods.uuid = uuid.uuid1()  # type: ignore
        await GoodsInfo.bulk_update(goods_list, ["uuid"], 10)
await GoodsInfo.bulk_update(goods_list, ["uuid"], 10)

我看GoodsInfo是没有bulk_update这个函数的,如果注释掉就能跑了

HibiKier commented 2 weeks ago

是从哪个版本迁移来的?

SHDocter commented 2 weeks ago

上次更新,具体版本号不知道

HibiKier commented 2 weeks ago

现在goodsinfo表里有uuid这个字段吗,有的话看一下这个字段是不是character,没有的话可以加一个uuid字段或删表