Files
platforms/backend/api/cmd/cli/device_mapping_migration.go
czl231 3ef33b531d 已完成用户APP首期功能开发
交付用户端首期页面、配套接口、后台资源及测试文档。用户APP构建、静态分析和三个管理后台构建通过;完整测试仍有2项失败,后端模型注释检查未通过,详见交付记录。
2026-09-13 00:57:32 +08:00

13 lines
985 B
Go
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.
// 功能只扩展产品分类和厂商映射字段不猜测或改写既有归属版本1.0.0。
package main
// migrateDeviceMapping 保留历史档案为unknown非空厂商编号全局唯一。
func migrateDeviceMapping() error {
return migrateClientColumns([]string{
`ALTER TABLE product_info ADD COLUMN IF NOT EXISTS device_kind varchar(16) NOT NULL DEFAULT 'unknown', ADD COLUMN IF NOT EXISTS vendor_device_id varchar(16) NOT NULL DEFAULT ''`,
`COMMENT ON COLUMN product_info.device_kind IS '设备分类unknown=未分类valve=智能阀alarm=报警器cylinder=钢瓶;后台明确设置,不按产品名称推断'`,
`COMMENT ON COLUMN product_info.vendor_device_id IS '厂商16位十进制设备编号空表示未建立映射同一编号仅能关联一份平台档案不代表在线或可控制'`,
`CREATE UNIQUE INDEX IF NOT EXISTS idx_product_vendor_device_id ON product_info(vendor_device_id) WHERE vendor_device_id <> ''`,
})
}