All checks were successful
Build and Deploy / deploy (push) Successful in 1m43s
上传接口接受 query customerId;ConcurrencyStamp 默认改为空串并用主键确定性回填,避免 Galera UUID unsafe。 Co-authored-by: Cursor <cursoragent@cursor.com>
34 lines
1.2 KiB
SQL
34 lines
1.2 KiB
SQL
-- t_9610_order_item 补齐 Fake AggregateRoot 并发戳(幂等)
|
||
-- 现象:详情/申报查明细时报 Unknown column 'ConcurrencyStamp' in 'field list'
|
||
-- 原因:实体继承 OmsAuditedAggregateRoot → AggregateRoot 含 ConcurrencyStamp,头表有、明细表缺
|
||
-- 注意:勿用 DEFAULT (UUID())——Galera/主从会报 Statement is unsafe(副本上 UUID 不一致)
|
||
|
||
SET @db := DATABASE();
|
||
|
||
SET @has := (
|
||
SELECT COUNT(*)
|
||
FROM information_schema.COLUMNS
|
||
WHERE TABLE_SCHEMA = @db
|
||
AND TABLE_NAME = 't_9610_order_item'
|
||
AND COLUMN_NAME = 'ConcurrencyStamp'
|
||
);
|
||
|
||
SET @sql := IF(
|
||
@has = 0,
|
||
'ALTER TABLE `t_9610_order_item` ADD COLUMN `ConcurrencyStamp` CHAR(36) NOT NULL DEFAULT '''' COMMENT ''并发戳'' AFTER `IsDeleted`',
|
||
'SELECT ''skip t_9610_order_item.ConcurrencyStamp'' AS msg'
|
||
);
|
||
|
||
PREPARE stmt FROM @sql;
|
||
EXECUTE stmt;
|
||
DEALLOCATE PREPARE stmt;
|
||
|
||
-- 已有行补确定性戳(基于主键,主从一致);新写入由 ORM 覆盖
|
||
UPDATE `t_9610_order_item`
|
||
SET `ConcurrencyStamp` = LOWER(CONCAT(
|
||
LPAD(HEX(`Id`), 8, '0'),
|
||
'-0000-4000-8000-',
|
||
LPAD(HEX(`Id`), 12, '0')
|
||
))
|
||
WHERE `ConcurrencyStamp` = '' OR `ConcurrencyStamp` IS NULL;
|