From b173a5c509cc9d68afae7a4cdf229ab49c14c106 Mon Sep 17 00:00:00 2001 From: xfy Date: Wed, 3 Jun 2026 15:41:22 +0800 Subject: [PATCH] refactor: merge cover_image migration into 002_posts - Add cover_image column directly in CREATE TABLE posts - Remove standalone 003_post_cover_image.sql migration --- migrations/002_posts.sql | 6 +++++- migrations/003_post_cover_image.sql | 5 ----- 2 files changed, 5 insertions(+), 6 deletions(-) delete mode 100644 migrations/003_post_cover_image.sql diff --git a/migrations/002_posts.sql b/migrations/002_posts.sql index a9c2de7..d395887 100644 --- a/migrations/002_posts.sql +++ b/migrations/002_posts.sql @@ -8,6 +8,7 @@ CREATE TABLE posts ( content_md TEXT NOT NULL, content_html TEXT, + cover_image VARCHAR(500), status TEXT NOT NULL DEFAULT 'draft', published_at TIMESTAMPTZ, @@ -35,4 +36,7 @@ CREATE TABLE post_tags ( ); CREATE INDEX idx_post_tags_post ON post_tags(post_id); -CREATE INDEX idx_post_tags_tag ON post_tags(tag_id); \ No newline at end of file +CREATE INDEX idx_post_tags_tag ON post_tags(tag_id); + +-- 为封面图添加索引 +CREATE INDEX idx_posts_cover ON posts(cover_image) WHERE cover_image IS NOT NULL; \ No newline at end of file diff --git a/migrations/003_post_cover_image.sql b/migrations/003_post_cover_image.sql deleted file mode 100644 index 5d650d2..0000000 --- a/migrations/003_post_cover_image.sql +++ /dev/null @@ -1,5 +0,0 @@ --- 新增封面图字段 -ALTER TABLE posts ADD COLUMN cover_image VARCHAR(500); - --- 为封面图添加索引 -CREATE INDEX idx_posts_cover ON posts(cover_image) WHERE cover_image IS NOT NULL;