feat: 添加自动迁移脚本并分离评论的slug和URL字段

- 新增自动数据库迁移脚本,在部署前检查并更新schema
- 将post_slug字段拆分为post_slug(仅路径)和post_url(完整URL)
- 更新前端widget以仅使用路径作为post_slug
- 修改部署脚本以在部署前自动运行迁移
This commit is contained in:
anghunk
2026-02-09 12:22:55 +08:00
parent 5cbc012dd3
commit e37a3e79e4
4 changed files with 99 additions and 5 deletions

View File

@@ -159,13 +159,14 @@ export const postComment = async (c: Context<{ Bindings: Bindings }>) => {
try {
const result = await c.env.CWD_DB.prepare(`
INSERT INTO Comment (
created, post_slug, name, email, url, ip_address,
created, post_slug, post_url, name, email, url, ip_address,
os, browser, device, ua, content_text, content_html,
parent_id, status
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
`).bind(
Date.now(),
post_slug,
post_url || null,
name,
email,
url || null,