Skip to content

Feature/blog cms schema#9

Open
vH192Hv wants to merge 2 commits into
floatboatai:mainfrom
vH192Hv:feature/blog-cms-schema
Open

Feature/blog cms schema#9
vH192Hv wants to merge 2 commits into
floatboatai:mainfrom
vH192Hv:feature/blog-cms-schema

Conversation

@vH192Hv

@vH192Hv vH192Hv commented Jul 11, 2026

Copy link
Copy Markdown

设计方案:Post/Author/Tag 数据模型

新增 Prisma 模型

  • Post: title, slug (@unique), content (Markdown @db.Text), excerpt, coverImage, status (PostStatus), author→User, tags (PostTag[]), publishedAt, timestamps
  • Tag: name (@unique), slug (@unique), posts (PostTag[])
  • PostTag: 显式多对多关联表,双向 Cascade delete
  • PostStatus: DRAFT | PUBLISHED | ARCHIVED 三态枚举
  • User: 新增 posts Post[] 反向关联

设计决策

决策 理由
Author = User 关联(非独立 Author 表) 复用现有认证体系
slug @unique 数据库约束 应用层校验 + 数据库兜底
PostStatus 三态枚举 支持草稿/发布/归档工作流
PostTag 显式关联表 高效双向查询

种子数据

  • seedBlogPosts: 3 个示例标签 + 2 篇示例帖子
  • 自动查找第一个 admin 用户作为作者

文件变更

  • schema.prisma: +39 lines
  • dbSeeds.ts: +72 lines
  • main.wasp.ts: register seedBlogPosts

🔽 无依赖 — 合并顺序第 1 个

vH192Hv and others added 2 commits July 9, 2026 21:30
- Add Post model with title, slug, content, excerpt, coverImage, status, timestamps
- Add Tag model with name and slug
- Add PostTag join table for many-to-many relationship
- Add PostStatus enum (DRAFT, PUBLISHED, ARCHIVED)
- Add posts relation to User model

Co-Authored-By: Claude <noreply@anthropic.com>
- Add seedBlogPosts function with sample posts and tags
- Register seed in main.wasp.ts db.seeds array

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to 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.

1 participant