Files
KCGL/db_migrations/normalize_bom_tri_state.sql
yueli c8cf2bd52b feat(db): BOM 三态互斥存量归一——归档(废弃)自动停用
- 将历史“归档且仍启用(True/True)”的行归一为 归档且停用(True/False)
2026-09-09 13:00:35 +08:00

13 lines
659 B
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.

-- =============================================================================
-- 一次性迁移BOM 三态互斥归一(启用/停用/归档 三者互斥)
-- 规则:归档=彻底废弃 → is_archived=True 且 is_enabled=False
-- 启用=在用;停用=有问题/暂停
-- 把历史上“归档但仍启用(True/True)”的行归一到“归档且停用(True/False)”
-- 执行: docker exec -i inventory_db psql -U test -d inventory_system < 本文件
-- =============================================================================
BEGIN;
UPDATE bom_table
SET is_enabled = FALSE
WHERE is_archived = TRUE AND is_enabled = TRUE;
COMMIT;