Skip to content

docs: backend/AGENTS.md — 改 DB schema 前必查全新贡献者能否启动 - #45

Merged
longsizhuo merged 2 commits into
mainfrom
docs/agents-db-guardrail
Jul 19, 2026
Merged

docs: backend/AGENTS.md — 改 DB schema 前必查全新贡献者能否启动#45
longsizhuo merged 2 commits into
mainfrom
docs/agents-db-guardrail

Conversation

@longsizhuo

Copy link
Copy Markdown
Member

把 M0(#43)踩的坑固化成给 AI / contributor 的硬约束,独立于功能栈,可直接合。

起因

M0 的 user_identities 回填读 user_accounts.github_id,但 docker/init-db/init.sql
建的表缺 github_id 等列,schema.sqlCREATE TABLE IF NOT EXISTS 又补不上——
全新贡献者 docker compose up 首启直接 column "github_id" does not exist 崩,
后端起不来。改数据库的人(我)在自己早有那些列的库上完全看不见这个问题。

这个 AGENTS.md 要求什么

  • 三处 schema 同步:schema.sql(真相源)/ init.sql(首次建卷)/ test-schema.sql(H2)
  • schema.sql 的 DML 幂等(每次启动重跑)
  • 不许建议 SPRING_SQL_INIT_MODE=never(新表在本地会缺)
  • 不许直接改生产库,核查只读
  • 验证配方:一次性 throwaway 容器跑 init.sql→schema.sql 两遍,exit 0 才算过——
    只在既有服务器库上测不算数(它藏住了 init.sql 的分裂)

配合根 CLAUDE.md 与 SECURITY.md 阅读;backend 此前没有自己的 agent 指令文件。

🤖 Generated with Claude Code

https://claude.ai/code/session_01RtSNVtrEkCsFVHrbt4Zjgi

把 M0 踩的坑固化成硬约束:三处 schema(schema.sql / docker/init-db/init.sql /
test-schema.sql)必须同步(CREATE TABLE IF NOT EXISTS 补不上已存在表的缺列)、
schema.sql 的 DML 必须幂等、不许把 SPRING_SQL_INIT_MODE 改成 never、不许直接
敲生产库;附一次性 throwaway 容器跑 init→schema 两遍的验证配方,杜绝"我这能跑"
式自证。
CopilotAI review requested due to automatic review settings July 19, 2026 10:18

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@longsizhuo
longsizhuo merged commit b474ce8 into mainJul 19, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@longsizhuo