feat: prepare CMS pages for deployment

This commit is contained in:
Codex
2026-04-29 14:23:00 +08:00
parent 9a55b874a5
commit d4fb7e0973
87 changed files with 5153 additions and 1901 deletions
+5 -5
View File
@@ -8,7 +8,7 @@ For the command-level Chinese handoff guide, see `docs/local-db-to-production-de
- Git commit to deploy.
- PostgreSQL database dump exported from the approved local database.
- `media/` and `files/` directories exported from the same local workspace as the database dump.
- `media/`, `files/`, and `videos/` directories exported from the same local workspace as the database dump.
- Production environment variables from `.env.example`, filled with production values.
## Required Environment
@@ -36,9 +36,9 @@ Optional variables:
3. Export the approved PostgreSQL database:
`pg_dump --format=custom --no-owner --no-acl --file=eversolo.payload.dump "$DATABASE_URI"`.
4. Export matching uploads:
`tar -czf eversolo.uploads.tgz media files`.
`tar -czf eversolo.uploads.tgz media files videos`.
5. Restore the approved PostgreSQL dump into the production database with `pg_restore --no-owner --no-acl`.
6. Copy `media/` and `files/` to the production persistent upload volume.
6. Copy `media/`, `files/`, and `videos/` to the production persistent upload volume.
7. Install dependencies with `npm ci`.
8. Run `npm run generate:types` only during build validation, not as a production data mutation step.
9. Run `npm run typecheck`.
@@ -56,7 +56,7 @@ Optional variables:
- Before exporting a local database for production, confirm `payload_migrations` has no `batch = -1` dev marker. That marker means schema push history is still recorded and production migration commands can prompt interactively.
- Do not edit migrations after they have shipped to production. Add a new forward migration instead.
- Keep schema migrations and data backfills separate. Backfill scripts in `src/scripts/` are manual operational tools, not automatic boot steps.
- The deployed database and upload directories must come from the same local export, otherwise media relationships can point at missing files.
- The deployed database and upload directories must come from the same local export, otherwise media/video/file relationships can point at missing files.
- Admin login captcha is stateless and signed with `PAYLOAD_SECRET`; changing that secret invalidates existing login sessions and outstanding captcha tokens.
## Rollback
@@ -65,7 +65,7 @@ Rollback means switching code and data together:
1. Stop traffic or move traffic back to the previous deployment.
2. Restore the previous database dump.
3. Restore the matching previous `media/` and `files/` directories.
3. Restore the matching previous `media/`, `files/`, and `videos/` directories.
4. Deploy the previous Git commit.
5. Re-run smoke checks before reopening traffic.
+10 -8
View File
@@ -1,13 +1,13 @@
# 本地数据库导线上部署文档
这份文档用于把当前本地 Payload/Next.js 站点完整搬到线上:代码、PostgreSQL 数据库、`media/` 图片库、`files/` 下载文件必须来自同一次导出。
这份文档用于把当前本地 Payload/Next.js 站点完整搬到线上:代码、PostgreSQL 数据库、`media/` 图片库、`files/` 下载文件`videos/` 视频文件必须来自同一次导出。
## 1. 上线前原则
- 线上只使用迁移,不使用 schema push。
- 线上启动不自动跑迁移,迁移必须作为单独发布步骤执行。
- 本地导出的数据库和 `media/``files/` 目录必须成套,不要混用不同时间点的文件。
- 导入线上后不要再跑 seed 脚本,seed/backfill 只应该在本地确认好,再随数据库 dump 一起带上去。
- 本地导出的数据库和 `media/``files/``videos/` 目录必须成套,不要混用不同时间点的文件。
- 导入线上后不要再跑 seed 脚本,seed/backfill 只应该在本地确认好,再随数据库 dump 一起带上去。当前 seed 默认会保护已有全局内容;只有显式加 `--force` 才会覆盖后台已有配置。
- 如果启动或迁移时出现删除旧表、schema push、交互确认提示,先停止,不要继续确认。
## 2. 线上环境变量
@@ -80,7 +80,7 @@ pg_dump \
--file="$EXPORT_DIR/eversolo.payload.dump" \
"$DATABASE_URI"
tar -czf "$EXPORT_DIR/eversolo.uploads.tgz" media files
tar -czf "$EXPORT_DIR/eversolo.uploads.tgz" media files videos
shasum -a 256 "$EXPORT_DIR/eversolo.payload.dump" "$EXPORT_DIR/eversolo.uploads.tgz" \
> "$EXPORT_DIR/SHA256SUMS.txt"
@@ -160,6 +160,7 @@ tar -xzf /srv/eversolo-release/eversolo.uploads.tgz -C /srv/eversolo-app/
```bash
rsync -a --delete /srv/eversolo-app/media/ /srv/eversolo-uploads/media/
rsync -a --delete /srv/eversolo-app/files/ /srv/eversolo-uploads/files/
rsync -a --delete /srv/eversolo-app/videos/ /srv/eversolo-uploads/videos/
```
确认应用运行时能从项目根目录或挂载目录访问:
@@ -167,9 +168,10 @@ rsync -a --delete /srv/eversolo-app/files/ /srv/eversolo-uploads/files/
```text
media/
files/
videos/
```
数据库里 media/files 记录只保存文件名和元数据,文件本体必须在对应目录里。
数据库里 media/files/videos 记录只保存文件名和元数据,文件本体必须在对应目录里。
## 7. 构建和启动
@@ -204,7 +206,7 @@ npm run smoke -- "$NEXT_PUBLIC_SITE_URL"
/en/reviews?tab=reviews
/en/support
/en/support/tutorial
/en/dealers
/en/where-to-buy
/admin
/admin/login
```
@@ -226,6 +228,6 @@ npm run smoke -- "$NEXT_PUBLIC_SITE_URL"
- 不要在线上设置 `PAYLOAD_DB_PUSH=true`
- 不要在线上用 `PAYLOAD_MIGRATING=true` 当常规启动方式。
- 不要把数据库 dump 和不同时间点的 `media/``files/` 混用。
- 不要导入线上后再跑 `npm run seed:import` 覆盖编辑内容
- 不要把数据库 dump 和不同时间点的 `media/``files/``videos/` 混用。
- 不要导入线上后再跑 `npm run seed:import -- --force` 覆盖编辑内容;普通 seed 也只建议在本地验证,不作为线上日常命令
- 不要在生产已经跑过某个迁移后修改同名迁移文件;需要新建 forward migration。
+1 -1
View File
@@ -22,7 +22,7 @@ This project is being tightened toward launch as a CMS-first Eversolo brand site
- Keep Payload globals and collections broad enough for editors, but avoid showing implementation-only legacy fields in admin.
- Prefer compact admin groups, list-style arrays, and explicit per-locale documents for user-facing content.
- Re-run `npm run generate:types`, `npm run build`, and the smoke check after schema or cache changes.
- After restarting a local preview, check both `/en` and `/zh` for homepage, product detail, downloads, news, dealers, support, and admin access.
- After restarting a local preview, check both `/en` and `/zh` for homepage, product detail, downloads, news, where-to-buy, support, and admin access.
## Deployment Discipline
+2 -2
View File
@@ -23,7 +23,7 @@ Use this checklist before every production deployment.
- [ ] `DATABASE_URI` points to the production PostgreSQL database.
- [ ] `PAYLOAD_DB_PUSH=false` is set.
- [ ] `PAYLOAD_RUN_MIGRATIONS_ON_START=false` is set unless a one-off controlled migration boot is intentionally planned.
- [ ] Upload directories `media/` and `files/` are persistent and backed up.
- [ ] Upload directories `media/`, `files/`, and `videos/` are persistent and backed up.
- [ ] Database dump and upload archive are generated from the same local release window.
## CMS Data
@@ -34,7 +34,7 @@ Use this checklist before every production deployment.
- [ ] News list and one news detail page render.
- [ ] Reviews page tabs render, with local media covers where present.
- [ ] Support page and video tutorials render, with local media covers.
- [ ] Dealers page map visibility matches CMS setting.
- [ ] Where to Buy page store links, dealer tabs, and map visibility match CMS settings.
## Smoke Routes