尝试运行创建表查询时出现UndefinedObjectError



我正在尝试使用以下模式创建一个表:

CREATE TABLE IF NOT EXISTS tags (id SERIAL, name TEXT, content TEXT, owner_id BIGINT, uses INTEGER DEFAULT (0), location_id BIGINT, created_at TIMESTAMP DEFAULT (now() at time zone 'utc'), PRIMARY KEY (id));

但我在尝试创建它时遇到了这个错误:

Could not create tags.
Traceback (most recent call last):
File "/root/AzuriteBot/launcher.py", line 119, in init
created = run(table.create(verbose=not quiet, run_migrations=False))
File "uvloop/loop.pyx", line 1494, in uvloop.loop.Loop.run_until_complete
File "/root/AzuriteBot/cogs/utils/db.py", line 662, in create
await con.execute(sql)
File "/usr/local/lib/python3.9/dist-packages/asyncpg/connection.py", line 297, in execute
return await self._protocol.query(query, timeout)
File "asyncpg/protocol/protocol.pyx", line 336, in query
asyncpg.exceptions.UndefinedObjectError: operator class "gin_trgm_ops" does not exist for access method "gin"

这可能是权限问题吗?问题出在哪里?

好吧,我只是通过运行sql本身而不是试图通过python脚本来解决这个问题。在我的例子中,db是数据库池对象:

await db.fetch("CREATE TABLE IF NOT EXISTS tags (id SERIAL, name TEXT, content TEXT, owner_id BIGINT, uses INTEGER DEFAULT (0), location_id BIGINT, created_at TIMESTAMP DEFAULT (now() at time zone 'utc'), PRIMARY KEY (id));")

最新更新