Skip to content

Commit 1cad13b

Browse files
committed
📝 Update upgrade guide doc 2
1 parent 3bef4a3 commit 1cad13b

File tree

2 files changed

+43
-13
lines changed

2 files changed

+43
-13
lines changed

doc/docs/en/deployment/upgrade-guide.md

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,14 @@ Remove cached resources to avoid conflicts when redeploying:
1919
# Stop and remove existing containers
2020
docker compose down
2121

22-
# Inspect and remove Nexent images
23-
docker images | grep nexent
24-
docker images | grep nexent | awk '{print $3}' | xargs docker rmi -f
22+
# Inspect Nexent images
23+
docker images --filter "reference=nexent/*"
24+
25+
# Remove Nexent images
26+
# Windows PowerShell:
27+
docker images -q --filter "reference=nexent/*" | ForEach-Object { docker rmi -f $_ }
28+
# Linux/WSL:
29+
docker images -q --filter "reference=nexent/*" | xargs -r docker rmi -f
2530

2631
# (Optional) prune unused images and caches
2732
docker system prune -af
@@ -92,23 +97,34 @@ Run the SQL scripts shipped with each release to keep your schema up to date.
9297
3. Execute SQL files sequentially (host machine example):
9398
9499
```bash
95-
docker exec -i nexent-postgresql psql -U $POSTGRES_USER -d $POSTGRES_DB < ./sql/2025-10-30-update.sql
96-
docker exec -i nexent-postgresql psql -U $POSTGRES_USER -d $POSTGRES_DB < ./sql/2025-11-05-update.sql
100+
# Example: If today is November 6th and your last update was on October 20th,
101+
# and there are two new files 1030-update.sql and 1105-update.sql,
102+
# execute the following commands (please replace the placeholders with your actual values)
103+
docker exec -i nexent-postgresql psql -U {YOUR_POSTGRES_USER} -d {YOUR_POSTGRES_DB} < ./sql/1030-update.sql
104+
docker exec -i nexent-postgresql psql -U {YOUR_POSTGRES_USER} -d {YOUR_POSTGRES_DB} < ./sql/1105-update.sql
97105
```
98106
99-
Replace the filenames with the migrations released after your last deployment.
107+
Execute the scripts in chronological order based on your deployment date.
100108
101109
> 💡 Tips
102110
> - Load environment variables first if they are defined in `.env`:
103111
>
112+
> **Windows PowerShell:**
113+
> ```powershell
114+
> Get-Content .env | Where-Object { $_ -notmatch '^#' -and $_ -match '=' } | ForEach-Object { $key, $value = $_ -split '=', 2; [Environment]::SetEnvironmentVariable($key.Trim(), $value.Trim(), 'Process') }
115+
> ```
116+
>
117+
> **Linux/WSL:**
104118
> ```bash
105119
> export $(grep -v '^#' .env | xargs)
120+
> # Or use set -a to automatically export all variables
121+
> set -a; source .env; set +a
106122
> ```
107123
>
108124
> - Create a backup before running migrations:
109125
>
110126
> ```bash
111-
> docker exec -i nexent-postgres pg_dump -U $POSTGRES_USER $POSTGRES_DB > backup_$(date +%F).sql
127+
> docker exec -i nexent-postgres pg_dump -U {YOUR_POSTGRES_USER} {YOUR_POSTGRES_DB} > backup_$(date +%F).sql
112128
> ```
113129
114130
---

doc/docs/zh/deployment/upgrade-guide.md

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,15 @@
1919
# 停止并删除现有容器
2020
docker compose down
2121

22-
# 查看并删除 Nexent 镜像
23-
docker images | grep nexent
24-
docker images | grep nexent | awk '{print $3}' | xargs docker rmi -f
22+
# 查看 Nexent 镜像
23+
docker images --filter "reference=nexent/*"
24+
25+
# 删除 Nexent 镜像
26+
# Windows PowerShell:
27+
docker images -q --filter "reference=nexent/*" | ForEach-Object { docker rmi -f $_ }
28+
29+
# Linux/WSL:
30+
docker images -q --filter "reference=nexent/*" | xargs -r docker rmi -f
2531

2632
# (可选)清理未使用的镜像与缓存
2733
docker system prune -af
@@ -92,23 +98,31 @@ bash deploy.sh
9298
3. 通过容器执行 SQL 脚本(示例):
9399
94100
```bash
95-
docker exec -i nexent-postgresql psql -U $POSTGRES_USER -d $POSTGRES_DB < ./sql/2025-10-30-update.sql
96-
docker exec -i nexent-postgresql psql -U $POSTGRES_USER -d $POSTGRES_DB < ./sql/2025-11-05-update.sql
101+
docker exec -i nexent-postgresql psql -U {POSTGRES_USER} -d {POSTGRES_DB} < ./sql/2025-10-30-update.sql
102+
docker exec -i nexent-postgresql psql -U {POSTGRES_USER} -d {POSTGRES_DB} < ./sql/2025-11-05-update.sql
97103
```
98104
99105
请根据自己的部署时间,按时间顺序执行对应脚本。
100106
101107
> 💡 提示
102108
> - 若 `.env` 中定义了数据库变量,可先导入:
103109
>
110+
> **Windows PowerShell:**
111+
> ```powershell
112+
> Get-Content .env | Where-Object { $_ -notmatch '^#' -and $_ -match '=' } | ForEach-Object { $key, $value = $_ -split '=', 2; [Environment]::SetEnvironmentVariable($key.Trim(), $value.Trim(), 'Process') }
113+
> ```
114+
>
115+
> **Linux/WSL:**
104116
> ```bash
105117
> export $(grep -v '^#' .env | xargs)
118+
> # 或使用 set -a 自动导出所有变量
119+
> set -a; source .env; set +a
106120
> ```
107121
>
108122
> - 执行前建议先备份:
109123
>
110124
> ```bash
111-
> docker exec -i nexent-postgres pg_dump -U $POSTGRES_USER $POSTGRES_DB > backup_$(date +%F).sql
125+
> docker exec -i nexent-postgres pg_dump -U {POSTGRES_USER} {POSTGRES_DB} > backup_$(date +%F).sql
112126
> ```
113127
114128
---

0 commit comments

Comments
 (0)