Files
backend_v2/db/migrations/2026-09-21-01-street-main-detail.sql
toom1996 d908036621 update
2026-09-22 11:12:23 +08:00

22 lines
1.3 KiB
SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- 2026-09-21-01 街拍主副图:草稿表 / 正式表的图片表各加两列。
--
-- 对应规格:docs/superpowers/specs/2026-09-21-street-main-detail-design.md §3.1
-- is_detail 0=主图 1=副图
-- parent_image_id 副图指向所属主图的「行 id」;主图为 0
-- (存行 id 而非序号:序号会因重排 / 插入 / 删除而失效)
--
-- 幂等:全部 ADD COLUMN IF NOT EXISTS,可重复执行。
-- 存量行为 0/0,即「全部按主图渲染」,无需数据迁移。
--
-- 应用后请重新导出结构,否则目标库拿不到新列:
-- ./bin/dbtool dump -clean -out db/backups/db_dump.sql
--
-- 说明:规格未给 parent_image_id 建索引。图片表当前规模为千行级(street_snap_draft_images
-- 1052 行),按 (draft_id) 过滤走顺序扫描即可;若日后量级变大需要,再按读侧实际查询补索引。
ALTER TABLE street_snap_draft_images ADD COLUMN IF NOT EXISTS is_detail smallint NOT NULL DEFAULT 0;
ALTER TABLE street_snap_draft_images ADD COLUMN IF NOT EXISTS parent_image_id integer NOT NULL DEFAULT 0;
ALTER TABLE street_snap_images ADD COLUMN IF NOT EXISTS is_detail smallint NOT NULL DEFAULT 0;
ALTER TABLE street_snap_images ADD COLUMN IF NOT EXISTS parent_image_id integer NOT NULL DEFAULT 0;