feat(publish): 街拍实体键细化为 city+year+title,支持同城同年多专题

This commit is contained in:
toom1996
2026-09-23 13:04:37 +08:00
parent d8b3424663
commit ce4f8b786d
4 changed files with 57 additions and 13 deletions

View File

@ -0,0 +1,12 @@
-- 街拍实体键细化:由 (city, year) 改为 (city, year, title)。
--
-- 背景:同城同年可能有多个专题(如 London 2027 Day 2 / Day 3),原键把它们判为同一实体,
-- 导致唯一索引不允许共存、且入库查重把第二个专题当成重复直接放弃。
--
-- COALESCE(title, '') 是刻意的:唯一索引中 NULL 互不冲突,若直接用 title,
-- 两条 title 为 NULL 的行会被判为不同实体而共存。入库始终会写 title,
-- 这里只是把「NULL 也要参与唯一性」这件事钉死。
DROP INDEX IF EXISTS uq_ss_entity;
CREATE UNIQUE INDEX IF NOT EXISTS uq_ss_entity
ON street_snaps (city, year, COALESCE(title, '')) WHERE is_deleted = 0;