fix(auth): 修复 CDC consumer 类型错误

使用 ?? 运算符正确处理可选字段:
- update 使用 undefined 保持字段不变
- create 使用 null 明确设置为空值

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-12 01:45:10 -08:00
parent 40745ca580
commit 4cbdf0b503
1 changed files with 4 additions and 4 deletions

View File

@ -137,8 +137,8 @@ export class LegacyUserCdcConsumer implements OnModuleInit, OnModuleDestroy {
await this.prisma.syncedLegacyUser.upsert({
where: { legacyId: BigInt(user.user_id) },
update: {
phone: user.phone_number || null,
passwordHash: user.password_hash || null,
phone: user.phone_number ?? undefined,
passwordHash: user.password_hash ?? undefined,
accountSequence: user.account_sequence,
status: user.status,
sourceSequenceNum: sequenceNum,
@ -146,8 +146,8 @@ export class LegacyUserCdcConsumer implements OnModuleInit, OnModuleDestroy {
},
create: {
legacyId: BigInt(user.user_id),
phone: user.phone_number || null,
passwordHash: user.password_hash || null,
phone: user.phone_number ?? null,
passwordHash: user.password_hash ?? null,
accountSequence: user.account_sequence,
status: user.status,
legacyCreatedAt: new Date(user.registered_at),