Эх сурвалжийг харах

fix(db): 迁移227 product_skus.id 升级为 BIGINT

- 修复 Data truncation: Out of range value for column 'id'
- 生产库 id/product_id 为 INT,实体为 Long,插入超出 INT 范围的 id 报错
- 生产 DB 已直连 ALTER(即时生效)
Xiaogang Liao 2 сар өмнө
parent
commit
f7a3020ac5

+ 9 - 0
cfc-backend/src/main/java/com/etotem/cfc/config/DatabaseInitializer.java

@@ -8563,6 +8563,15 @@ private void runMigration100() {
 		// 迁移226: products 添加 growth_category 列(成长分类筛选,Product 实体已含字段,生产库缺列导致 Unknown column 'growth_category')
 		ensureColumn("products", "growth_category", "VARCHAR(50) DEFAULT NULL COMMENT '成长分类'");
 
+		// 迁移227: product_skus.id 升级为 BIGINT(生产库为 INT,插入超出 INT 范围的 id 报 Out of range value for column 'id')
+		try {
+			jdbcTemplate.execute("ALTER TABLE product_skus MODIFY COLUMN id BIGINT AUTO_INCREMENT");
+			jdbcTemplate.execute("ALTER TABLE product_skus MODIFY COLUMN product_id BIGINT NOT NULL COMMENT '所属商品ID'");
+			log.info("product_skus.id/product_id 已升级为 BIGINT");
+		} catch (Exception e) {
+			log.warn("product_skus.id/product_id 升级失败(可能已修改): " + e.getMessage());
+		}
+
 		// 迁移209: 创建 survey_templates 表(定期调研模板)
 		try {
 			jdbcTemplate.execute(