diff options
Diffstat (limited to 'lib/tech-vendors')
| -rw-r--r-- | lib/tech-vendors/service.ts | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/tech-vendors/service.ts b/lib/tech-vendors/service.ts index 7513a283..05ec1178 100644 --- a/lib/tech-vendors/service.ts +++ b/lib/tech-vendors/service.ts @@ -1420,7 +1420,7 @@ export async function addTechVendor(input: { // 이미 존재하는 유저인지 확인 const existingUser = await tx.query.users.findFirst({ where: eq(users.email, input.email), - columns: { id: true } + columns: { id: true, techCompanyId: true } }); let userId = null; @@ -1435,7 +1435,15 @@ export async function addTechVendor(input: { userId = newUser.id; console.log("유저 생성 성공:", userId); } else { - console.log("이미 존재하는 유저:", existingUser.id); + // 이미 존재하는 유저의 techCompanyId가 null인 경우 업데이트 + if (!existingUser.techCompanyId) { + await tx.update(users) + .set({ techCompanyId: newVendor.id }) + .where(eq(users.id, existingUser.id)); + console.log("기존 유저의 techCompanyId 업데이트:", existingUser.id); + } + userId = existingUser.id; + console.log("이미 존재하는 유저:", userId); } return { vendor: newVendor, userId }; |
