44 lines
1.2 KiB
PL/PgSQL
Raw 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.

-- 素材列表可见性权威标记
--
-- 专用 init 会先建一条还没有文件的 Material。以前列表每次用
-- preview/zip/assets.none 现场判断空壳,打开创意资产库就会拖慢。
-- 现在把结论写在素材行上:init=true,complete=false,列表只读本列。
--
-- 可重复执行。默认 false,不影响已有可展示素材。
BEGIN;
ALTER TABLE "materials"
ADD COLUMN IF NOT EXISTS is_incomplete_shell BOOLEAN NOT NULL DEFAULT false;
CREATE INDEX IF NOT EXISTS materials_is_incomplete_shell_idx
ON "materials"(is_incomplete_shell);
UPDATE "materials"
SET is_incomplete_shell = true
WHERE "deletedAt" IS NULL
AND "materialType" IN (
'任务-3D原图',
'任务-AI原图',
'任务-实拍原图',
'任务-视频截图',
'任务-页面',
'证书-检测报告',
'任务-详情'
)
AND "previewUrl" = ''
AND "zipFilePath" = ''
AND "zipFileName" = ''
AND COALESCE(cardinality("displayImages"), 0) = 0
AND (
task_status IN ('uploading', 'processing', 'failed')
OR (
"materialType" = '任务-详情'
AND task_status IS NULL
AND task_detail_source_type IN ('实拍', '渲染', 'AI')
AND task_detail_requester_user_id IS NOT NULL
)
);
COMMIT;