提交
This commit is contained in:
1 parent
1ca2668112
commit
5b3edb1700
278 files changed
+53761
-36931
No files matched your search
@@ -0,0 +1,72 @@
|
||||
-- =============================================================================
|
||||
-- 历史数据刷新:预计细胞数量 单位「亿」→「千万」(数值 ×10)
|
||||
-- =============================================================================
|
||||
--
|
||||
-- 适用:biz_cell_product.expected_cell_count 历史数据按「亿」录入的环境(仅执行一次)。
|
||||
-- 执行后:库中数值与界面、API 均为「千万」(例:1000万细胞 → 存 1)。
|
||||
--
|
||||
-- 注意:
|
||||
-- 1. 执行前请备份 biz_cell_product 表
|
||||
-- 2. 请勿重复执行(重复 ×10 会导致数据错误)
|
||||
-- 3. 若下方「迁移前检查」显示 column_comment 已含「单位:千万」,说明已迁移,跳过第 2 段
|
||||
--
|
||||
-- =============================================================================
|
||||
-- 1. 迁移前检查(建议先单独执行本段)
|
||||
-- =============================================================================
|
||||
|
||||
SELECT COLUMN_COMMENT AS current_unit_comment
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'biz_cell_product'
|
||||
AND COLUMN_NAME = 'expected_cell_count';
|
||||
|
||||
SELECT COUNT(*) AS pending_rows
|
||||
FROM `biz_cell_product`
|
||||
WHERE `del_flag` = 0
|
||||
AND `expected_cell_count` IS NOT NULL;
|
||||
|
||||
SELECT
|
||||
`product_code`,
|
||||
`expected_cell_count` AS value_before_yi,
|
||||
`expected_cell_count` * 10 AS value_after_qianwan
|
||||
FROM `biz_cell_product`
|
||||
WHERE `del_flag` = 0
|
||||
AND `expected_cell_count` IS NOT NULL
|
||||
ORDER BY `update_time` DESC
|
||||
LIMIT 10;
|
||||
|
||||
-- =============================================================================
|
||||
-- 2. 正式迁移(确认检查无误后执行)
|
||||
-- =============================================================================
|
||||
|
||||
START TRANSACTION;
|
||||
|
||||
UPDATE `biz_cell_product`
|
||||
SET `expected_cell_count` = `expected_cell_count` * 10
|
||||
WHERE `del_flag` = 0
|
||||
AND `expected_cell_count` IS NOT NULL;
|
||||
|
||||
ALTER TABLE `biz_cell_product`
|
||||
MODIFY COLUMN `expected_cell_count` DECIMAL(18,4) DEFAULT NULL
|
||||
COMMENT '预计细胞数量(单位:千万)';
|
||||
|
||||
COMMIT;
|
||||
|
||||
-- =============================================================================
|
||||
-- 3. 迁移后校验
|
||||
-- =============================================================================
|
||||
|
||||
SELECT COLUMN_COMMENT AS unit_comment_after_migrate
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'biz_cell_product'
|
||||
AND COLUMN_NAME = 'expected_cell_count';
|
||||
|
||||
SELECT
|
||||
`product_code`,
|
||||
`expected_cell_count`
|
||||
FROM `biz_cell_product`
|
||||
WHERE `del_flag` = 0
|
||||
AND `expected_cell_count` IS NOT NULL
|
||||
ORDER BY `update_time` DESC
|
||||
LIMIT 10;
|
||||
Reference in new issue
Block a user