From fe37e26e5f68857a664f77555f58c96a62c3536f Mon Sep 17 00:00:00 2001 From: seaHi Date: Thu, 6 Aug 2026 12:14:13 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E7=B3=BB=E5=88=97=E6=95=B0=E6=8D=AE=E5=BA=93=E8=A1=A8=E7=BB=93?= =?UTF-8?q?=E6=9E=84=E5=8F=8A=E8=BF=81=E7=A7=BB=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- migrations/0001_add_series.sql | 14 ++++++++++++++ schema.sql | 17 ++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 migrations/0001_add_series.sql diff --git a/migrations/0001_add_series.sql b/migrations/0001_add_series.sql new file mode 100644 index 0000000..4b9c4cf --- /dev/null +++ b/migrations/0001_add_series.sql @@ -0,0 +1,14 @@ +CREATE TABLE series ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + name TEXT NOT NULL UNIQUE COLLATE NOCASE, + slug TEXT NOT NULL UNIQUE, + description TEXT, + created_at DATETIME DEFAULT CURRENT_TIMESTAMP +); + +ALTER TABLE posts ADD COLUMN series_id INTEGER REFERENCES series(id) ON DELETE SET NULL; +ALTER TABLE posts ADD COLUMN series_weight INTEGER; + +CREATE INDEX idx_posts_series_order ON posts(series_id, series_weight, published_at, id); + +INSERT OR IGNORE INTO settings (key, value) VALUES ('alias.series', '系列'); diff --git a/schema.sql b/schema.sql index 0755e31..5b4b114 100644 --- a/schema.sql +++ b/schema.sql @@ -1,5 +1,6 @@ DROP TABLE IF EXISTS post_tags; DROP TABLE IF EXISTS posts; +DROP TABLE IF EXISTS series; DROP TABLE IF EXISTS tags; DROP TABLE IF EXISTS categories; DROP TABLE IF EXISTS pages; @@ -20,6 +21,14 @@ CREATE TABLE categories ( slug TEXT NOT NULL UNIQUE ); +CREATE TABLE series ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + name TEXT NOT NULL UNIQUE COLLATE NOCASE, + slug TEXT NOT NULL UNIQUE, + description TEXT, + created_at DATETIME DEFAULT CURRENT_TIMESTAMP +); + CREATE TABLE posts ( id INTEGER PRIMARY KEY AUTOINCREMENT, slug TEXT NOT NULL UNIQUE, @@ -27,13 +36,18 @@ CREATE TABLE posts ( content TEXT NOT NULL, author_id INTEGER NOT NULL, category_id INTEGER, + series_id INTEGER, + series_weight INTEGER, published_at DATETIME DEFAULT CURRENT_TIMESTAMP, updated_at DATETIME DEFAULT CURRENT_TIMESTAMP, cover TEXT, FOREIGN KEY (author_id) REFERENCES users(id), - FOREIGN KEY (category_id) REFERENCES categories(id) ON DELETE SET NULL + FOREIGN KEY (category_id) REFERENCES categories(id) ON DELETE SET NULL, + FOREIGN KEY (series_id) REFERENCES series(id) ON DELETE SET NULL ); +CREATE INDEX idx_posts_series_order ON posts(series_id, series_weight, published_at, id); + CREATE TABLE pages ( id INTEGER PRIMARY KEY AUTOINCREMENT, slug TEXT NOT NULL UNIQUE, @@ -102,6 +116,7 @@ INSERT INTO settings (key, value) VALUES ('alias.post', '文章'), ('alias.category', '分类'), ('alias.tag', '标签'), +('alias.series', '系列'), ('alias.page', '页面'), ('site.title', 'BlogFlare'), ('site.description', 'A high-performance blog powered by Cloudflare D1, R2, and KV.'),