Files
FruitServer/sql/migrate-k93-drama-multi-tag.sql
T

17 lines
835 B
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.
-- Author: fruit.com.cn
-- K93 短剧分类与内容类型多选(幂等,仅提交文件,由发布流程执行)
ALTER TABLE drama ADD COLUMN IF NOT EXISTS drama_types VARCHAR(32) NOT NULL DEFAULT '';
COMMENT ON COLUMN drama.drama_types IS '内容类型多选,逗号分隔(ANIME/LIVE),drama_type 保留第一个';
ALTER TABLE drama ADD COLUMN IF NOT EXISTS category_ids VARCHAR(255) NOT NULL DEFAULT '';
COMMENT ON COLUMN drama.category_ids IS
'短剧分类多选,逗号分隔的 category_id,category_id 保留第一个';
UPDATE drama SET drama_types = drama_type
WHERE (drama_types IS NULL OR drama_types = '') AND drama_type IS NOT NULL AND drama_type <> '';
UPDATE drama SET category_ids = category_id::text
WHERE (category_ids IS NULL OR category_ids = '') AND category_id IS NOT NULL AND category_id > 0;