Archive the differentiated YuXinGu product docs, AI engineering system, design contract, and Go/Vue scaffold. Next execution prioritizes Cece-parity over early innovation (see .ai/product/STRATEGY.md). Co-authored-by: Cursor <cursoragent@cursor.com>
1001 B
1001 B
04 数据库规范
引擎
PostgreSQL(主库)。本地可用 Docker Compose。
命名
- 表:
snake_case单数或清晰业务名,如user_profile、payment_order、user_session。 - 禁止
tbl_/t_前缀。 - 字段:
snake_case。
公共字段
每张业务表默认包含:
id BIGSERIAL PRIMARY KEY -- 或 UUID,项目内统一一种
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
deleted_at TIMESTAMPTZ NULL -- 软删除
迁移
- 使用 goose(或 golang-migrate),文件放
apps/api/migrations/。 - 迁移必须可回滚(提供
Down)。 - 禁止手改生产库结构而不留迁移文件。
索引
- 高频查询字段建索引;唯一业务键用 UNIQUE。
- 写迁移时注明索引意图。
敏感数据
- 生日等:最小化存储;访问打审计日志(后置也可先文档约定)。
- 密钥、支付信息不得明文进业务表。