AI 文章摘要
XinruiGPT
加载中...
此内容根据文章生成,并未经过人工审核,仅用于文章内容的解释与总结

前言

之前就有文章说V3有了,所以升级了V3,而pg数据库版本没有改变还是12,所以导致了一个问题,就是无法在统计页面查看更多数据。如下图

umami无法查看统计数据

所以今天就来解决这个问题。

教程

1.首先找到宝塔面板的docker容器,点击查看日志。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
2025-11-26 16:10:47.212 UTC [1449] ERROR: syntax error at or near "name" at character 340
2025-11-26 16:10:47.212 UTC [1449] STATEMENT:
select
name,
sum(t.c) as "pageviews",
count(distinct t.session_id) as "visitors",
count(distinct t.visit_id) as "visits",
sum(case when t.c = 1 then 1 else 0 end) as "bounces",
sum(floor(extract(epoch from (t.max_time - t.min_time)))) as "totaltime"
from (
select
referrer_domain name,
website_event.session_id,
website_event.visit_id,
count(*) as "c",
min(website_event.created_at) as "min_time",
max(website_event.created_at) as "max_time"
from website_event
where website_event.website_id = $1::uuid
and website_event.created_at between $2 and $3
and website_event.event_type != 2
and website_event.referrer_domain != website_event.hostname
and website_event.referrer_domain != ''
group by name, website_event.session_id, website_event.visit_id
) as t
where name != ''
group by name
order by visitors desc, visits desc
limit 500
offset 0

用AI分析,核心问题是SQL 语句中的name字段在分组 / 排序时引发语法冲突,具体原因是:PostgreSQL 中name是保留关键字(如系统表字段名),而你的 SQL 中用name作为别名(referrer_domain name),且在group by name/order by name中直接使用,导致解析器混淆,报syntax error at or near “name”。

2.基于以上问题,可以得出结论,就是需要升级pg数据库版本。

3.在pg版本为12的情况下,在终端输入如下命令

1
docker compose exec -T db pg_dump -U umami umami > umami-backup.sql

这是将umami的数据库打包成一个sql文件。

4.然后就是停止umami容器以及pg数据库容器,并且删除umami-db-data文件夹,不过在此之前还是备份一下umami-db-data文件夹。

5.新建一个umami-db-data文件夹。

6.修改docker-compose.yml文件,将pg的版本修改为15,然后输入如下命令启动容器。

1
docker compose up -d

7.在终端输入如下命令

1
cat umami-backup.sql | docker compose exec -T db psql -U umami -d umami

8.访问umami页面,如果上图中的数据正常显示了,则说明升级成功。

结语

本教程适合于和我一样之前就使用pg数据库的用户。