fix: 给有 FK 依赖的建表脚本加数字前缀以保证字母序就是依赖序

This commit is contained in:
zetaloop
2026-05-03 07:31:12 +08:00
parent 22c7c4e7d9
commit 631469a713
16 changed files with 0 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
CREATE TABLE post_likes
(
id BIGINT PRIMARY KEY,
post_id BIGINT NOT NULL,
user_id BIGINT NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
UNIQUE (post_id, user_id)
);
-- [核心索引] 优化 "feed流中判断我是否已赞" (user_id = ? AND post_id IN (...))
CREATE INDEX idx_post_likes_lookup ON post_likes (user_id, post_id);
-- [核心索引] 优化 "我赞过的帖子" 列表
CREATE INDEX idx_post_likes_user_timeline ON post_likes (user_id, created_at DESC);