diff --git a/prisma/migrations/20260727120000_normalize_user_social_type_uppercase/migration.sql b/prisma/migrations/20260727120000_normalize_user_social_type_uppercase/migration.sql new file mode 100644 index 0000000..d2adae0 --- /dev/null +++ b/prisma/migrations/20260727120000_normalize_user_social_type_uppercase/migration.sql @@ -0,0 +1,6 @@ +-- Backfill: legacy rows had lowercase social_type ('google', 'naver', 'kakao'). +-- Current write paths (config/social/*.ts, auth.service.ts) always store uppercase, +-- so this one-shot normalization aligns historical data with the code contract. +UPDATE `User` +SET `social_type` = UPPER(`social_type`) +WHERE `social_type` IN ('google', 'naver', 'kakao'); diff --git a/src/stats/services/admin-stats.service.ts b/src/stats/services/admin-stats.service.ts index a7cff50..a480b3b 100644 --- a/src/stats/services/admin-stats.service.ts +++ b/src/stats/services/admin-stats.service.ts @@ -29,7 +29,7 @@ export const getMemberStats = async (): Promise => { let total = 0; for (const row of grouped) { - const channel = SOCIAL_TYPE_TO_CHANNEL[row.social_type]; + const channel = SOCIAL_TYPE_TO_CHANNEL[row.social_type?.toUpperCase()]; if (!channel) continue; byChannel[channel].count = row._count._all; total += row._count._all;