Initial commit
This commit is contained in:
24
schemas/comment.sql
Normal file
24
schemas/comment.sql
Normal file
@@ -0,0 +1,24 @@
|
||||
-- create comment table
|
||||
CREATE TABLE IF NOT EXISTS Comment (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
pub_date DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
post_slug TEXT NOT NULL,
|
||||
author TEXT NOT NULL,
|
||||
email TEXT NOT NULL,
|
||||
url TEXT,
|
||||
ip_address TEXT,
|
||||
device TEXT,
|
||||
os TEXT,
|
||||
browser TEXT,
|
||||
user_agent TEXT,
|
||||
content_text TEXT NOT NULL,
|
||||
content_html TEXT NOT NULL,
|
||||
parent_id INTEGER,
|
||||
status TEXT DEFAULT 'approved',
|
||||
-- 建立自引用外键约束(父子评论关系)
|
||||
FOREIGN KEY (parent_id) REFERENCES Comment (id) ON DELETE SET NULL
|
||||
);
|
||||
|
||||
-- 可选:为常用查询字段创建索引以提高性能
|
||||
CREATE INDEX IF NOT EXISTS idx_post_slug ON Comment(post_slug);
|
||||
CREATE INDEX IF NOT EXISTS idx_status ON Comment(status);
|
||||
Reference in New Issue
Block a user