Files
class-history-template/schema.sql
T
hanyixuanten ca422df0c3 feat(api): record submitter IP/UA for messages and submissions
- messages: store ua/country alongside ip (audit only, not returned by GET);
  full schema now documented in schema.sql
- submit: append IP/UA/country/time to PR body in a collapsed section;
  never written into committed files
2026-10-25 12:13:11 +00:00

20 lines
923 B
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- D1 数据库结构(留言墙 /api/messages 使用,绑定名 DB)
--
-- 全新部署:直接执行下面的 CREATE TABLE。
-- 已有部署:老表缺少 ua / country 列时,执行文件末尾注释里的 ALTER TABLE。
CREATE TABLE IF NOT EXISTS messages (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL, -- 留言人昵称
text TEXT NOT NULL, -- 留言内容
time TEXT NOT NULL, -- 展示用日期 YYYY.MM.DD
ip TEXT, -- 访客 IP(限流 + 审计)
ua TEXT, -- User-Agent(审计)
country TEXT, -- 国家/地区代码,来自 CF-IPCountry(审计)
created_at INTEGER NOT NULL -- Unix 秒,排序与限流用
);
-- 已有部署的增量迁移:
-- ALTER TABLE messages ADD COLUMN ua TEXT;
-- ALTER TABLE messages ADD COLUMN country TEXT;