Files
Jyotisha/docs/testing/production-migration-rehearsal-20261014.md
T
jesse-uxandGrok (agent loop) 09906cdccc fix(release): keep owners and grants in production recovery points
Co-Authored-By: Grok (agent loop)
2026-10-14 21:01:52 +08:00

2.0 KiB
Raw Blame History

生产迁移演练记录(2026-10-14)

本机 Docker,镜像 postgres:17-alpine,和 npm run test:db 用的是同一个 fixture。没有连生产主机,没有点生产按钮。数据是虚构的,每种关键表一行。下面只记计数、退出码和是否一致。

步骤

  1. 建库后套用生产当前版本:frontend/db/migrations 全部,加上 frontend/supabase/migrations 里文件名早于 20260816010000 的文件。Windows 上有 4 个同名文件,内容一致,只留一份。
  2. 用恢复脚本同款方式导出:pg_dump --format=custom。再用 openssl aes-256-cbc -salt -pbkdf2 加密,然后解密。密钥没有写进仓库。
  3. 新建空库,pg_restore --exit-on-error。不先删 public。用超级用户比较源库和还原库的表权限、列权限、表属主。
  4. 再还原一份,跑 deploy/rehearse-production-migrations.sh 的本地模式。
  5. 再按手册还原一份。先把登录身份设成库里已有的一条账户,再 set role authenticated,读 public.profiles。

结果

项 值
基线迁移文件 111
基线迁移退出码 0
基线已应用 111
源库计数(身份账户 / 账户资料 / 点数流水 / 人物表 / public 表) 1 / 1 / 1 / 1 / 76
加密退出码 0
解密退出码 0
表权限一致 true(871 行)
列权限一致 true(6760 行)
表属主一致 true(75 行)
演练第一批文件 160
演练全部文件 175
演练退出码 0
archived_sessions_before absent
archived_sessions_after 0
self_chart_rows_before 0
self_chart_rows_after 0
other_person_accepted_rows 0
notice_lines 161
revoked_grants 0
chart_profiles_service_role_select_missing 0
rehearsal_ok 1
结束后名字以 rehearse_ 开头的库 0
authenticated 读到的行 1

notice_lines=161 是这次空库演练里迁移提示的行数,不是生产上的标题修补人数。生产上仍按手册:标题修补不是 0 就停。