Skip to content

Conversation

@Gyuhyeok99
Copy link
Contributor

관련 이슈

작업 내용

중복검증이라는 느낌은 들지 않아서 그냥 이메일 유니크키 제거 스크립트만 작성하였습니다.

특이 사항

어떤 pr이 먼저 반영될지 몰라 저도 V33으로 했습니다! 아래 pr이 먼저 반영된다면 34로 업데이트 해놓겠습니다~

리뷰 요구사항 (선택)

혹시 어떤 점에서 중복검증이라고 생각하셨는지 의견 남겨주시면 좋을 거 같습니다!
전 이거만 반영해도 이슈 없을 것이라고 일단 생각했습니다!

@coderabbitai
Copy link

coderabbitai bot commented Oct 4, 2025

Walkthrough

    1. V33 마이그레이션 스크립트에서 site_user 테이블의 site_user_email_unique 유니크 키를 드롭합니다.

Estimated code review effort

  • 변경 범위와 로직이 단일 SQL 구문으로 제한됩니다.
  • 영향 파일 수가 1개이며, 이질적 변경 없이 스키마 제약 해제만 수행합니다.
  • 🎯 1 (Trivial) | ⏱️ ~2 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Linked Issues Check ⚠️ Warning PR은 이메일 단독 유니크키 제거 마이그레이션 스크립트를 포함했으나 링크된 이슈 #520에서 요구하는 중복 검증 로직 제거는 반영되지 않아요. 따라서 이슈의 전체 요구사항을 완전히 충족하지 않습니다. 이메일·인증타입 중복 검증 로직 삭제와 관련 테스트 및 코드 수정이 추가로 필요합니다.
✅ Passed checks (4 passed)
Check name Status Explanation
Title Check ✅ Passed 제목이 변경 사항의 핵심인 이메일 유니크키 삭제를 간결하게 표현하여 동료가 빠르게 이해할 수 있어요. 불필요한 이모지나 과도한 세부 설명 없이 깔끔합니다.
Out of Scope Changes Check ✅ Passed 변경된 파일이 마이그레이션 스크립트 하나뿐으로 링크된 이슈 범위를 벗어난 수정은 없습니다. 불필요한 코드 변경이 포함되지 않아 깔끔합니다.
Description Check ✅ Passed PR 설명은 관련 이슈, 작업 내용, 특이 사항 섹션을 모두 채워 템플릿을 준수하고 있으며 선택적 리뷰 요구사항까지 작성되어 있어요. 섹션 순서도 명확해 가독성이 좋습니다.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 27fd21b and 58efb5f.

📒 Files selected for processing (1)
  • src/main/resources/db/migration/V33__drop_site_user_email_unique.sql (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build

@@ -0,0 +1 @@
ALTER TABLE site_user DROP KEY site_user_email_unique;
Copy link

@coderabbitai coderabbitai bot Oct 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

중복 키 제거 후 일반 인덱스를 추가해 주세요. 이메일로 사용자 조회가 빈번한 서비스 특성상, 유니크 키를 삭제하면 해당 컬럼의 인덱스 자체가 사라져 쿼리 성능이 급격히 떨어질 수 있어요. DROP 뒤에 동일 컬럼으로 일반 인덱스를 생성해 주시면 성능 저하를 예방할 수 있겠습니다.

 ALTER TABLE site_user DROP KEY site_user_email_unique;
+CREATE INDEX idx_site_user_email ON site_user (email);
🤖 Prompt for AI Agents
In src/main/resources/db/migration/V33__drop_site_user_email_unique.sql around
lines 1 to 1, after dropping the unique key you must create a non-unique index
on the same email column to avoid query performance degradation; modify the
migration so that immediately after ALTER TABLE site_user DROP KEY
site_user_email_unique; you add a CREATE INDEX (e.g., CREATE INDEX
idx_site_user_email ON site_user(email);) ensuring the index is non-unique and
uses the same column name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

유니크 특정이 email + authType으로 되고 있고 그거에 대한 유니크 키(+ 인덱스)가 있는데 상관 없지 않아?
@coderabbitai

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check for composite unique key on (email, authType) in migration files
echo "=== Searching for composite unique key on email and authType ==="
rg -n -A2 -B2 "UNIQUE.*email.*authType|UNIQUE.*authType.*email|email.*authType.*UNIQUE|authType.*email.*UNIQUE" src/main/resources/db/migration/

echo -e "\n=== Checking for unique constraints in site_user table creation ==="
rg -n -A10 -B5 "CREATE TABLE.*site_user" src/main/resources/db/migration/

echo -e "\n=== Looking for any unique key definitions with email ==="
rg -n "UNIQUE KEY.*email" src/main/resources/db/migration/

Length of output: 1657


🏁 Script executed:

#!/bin/bash
# Get the full site_user table definition
echo "=== Full site_user table definition ==="
sed -n '/CREATE TABLE.*site_user/,/^);/p' src/main/resources/db/migration/V1__init.sql

echo -e "\n=== Searching for ALTER TABLE site_user with UNIQUE ==="
rg -n "ALTER TABLE.*site_user.*UNIQUE|ALTER TABLE.*site_user.*ADD.*KEY" src/main/resources/db/migration/

echo -e "\n=== Looking for authType column ==="
rg -n "authType|auth_type" src/main/resources/db/migration/V1__init.sql

echo -e "\n=== All unique key additions in migration files ==="
rg -n "ADD.*UNIQUE|CREATE.*UNIQUE" src/main/resources/db/migration/

Length of output: 1090


🏁 Script executed:

#!/bin/bash
# Search for authType across all migration files
echo "=== Searching for authType in all migration files ==="
rg -n "authType|auth_type" src/main/resources/db/migration/

echo -e "\n=== List all migration files to see the sequence ==="
ls -1 src/main/resources/db/migration/ | sort -V

echo -e "\n=== Check if there are any recent migrations that add composite unique key ==="
rg -n -C3 "email.*auth|auth.*email" src/main/resources/db/migration/

echo -e "\n=== Look for all CONSTRAINT or KEY definitions in site_user ==="
rg -n "site_user" src/main/resources/db/migration/ | grep -i "constraint\|key\|index"

Length of output: 8701


@Gyuhyeok99, 맞습니다! 제가 잘못 판단했네요. 😅

V3 마이그레이션에서 이미 uk_site_user_email_auth_type UNIQUE (email, auth_type) 복합 유니크 키가 생성되어 있고, MySQL의 최좌측 프리픽스(leftmost prefix) 규칙에 따라 (email, auth_type) 인덱스는 email 단독 조회에도 효율적으로 사용될 수 있습니다.

따라서 email 단독 유니크 키를 제거하더라도 복합 인덱스가 email 필터링 쿼리의 성능을 충분히 보장하므로, 별도의 일반 인덱스를 추가할 필요가 없습니다.

이전 제안을 철회합니다. 현재 마이그레이션 스크립트는 그대로 사용하셔도 문제없습니다! 👍

Copy link
Member

@whqtker whqtker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. /email/sign-up 엔드포인트에 접근하면 EmailSignUpTokenProviderissueEmailSignUpToken 메서드 호출
  2. 해당 메서드에서 existsByEmailAndAuthType 를 통해 (email, authType)으로 중복 여부 검증
  3. 이후 발급받은 signUpToken을 통해 이메일 회원가입 진행, SignUpServicesignUp 메서드 호출
  4. validateUserNotDuplicated 메서드를 통해 (email, authType)으로 중복 여부 검증
  5. 이후 계속 진행 ...

제가 말씀드린 중복 검증은 이런 부분이었습니다 ! 근데 다시 생각해보니 동시성 문제가 발생하면 애플리케이션 레벨에서 문제를 감지하지 못할 거 같아서 있는 게 낫겠다는 생각으로 바뀌었습니다. 혹시 이러한 부분에서 중복 검증이 없다고 생각하신 건가요 ? 제가 봤을 땐 검증 자체는 동일하다고 보여서요 ... 제가 놓친 부분이 있다면 말씀해주세요 !!

@Gyuhyeok99
Copy link
Contributor Author

Gyuhyeok99 commented Oct 7, 2025

네 맞습니다!

  1. POST /email/sign-up (토큰 발급 API)
    └─ issueEmailSignUpToken()
    └─ 1차 검증: existsByEmailAndAuthType
    └─ 토큰 발급

  2. POST /sign-up (실제 회원가입 API)
    └─ signUp()
    └─ 2차 검증: validateUserNotDuplicated
    └─ 회원가입 처리

이렇게 별도 api이다보니 각각 검증하는 게 더 나을 거 같다는 생각도 가지고있었습니다!

@whqtker
Copy link
Member

whqtker commented Oct 7, 2025

제가 로직이 동일하다는 거에 과하게 초점을 맞췄었네요. 어쨌든 현 상태 유지하는 거는 동의합니다 !

@Gyuhyeok99 Gyuhyeok99 merged commit 878c05c into solid-connection:develop Oct 8, 2025
2 checks passed
@Gyuhyeok99 Gyuhyeok99 deleted the refactor/520-remove-site-user-email-unique branch November 9, 2025 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: 회원가입 시 발생하는 중복 및 불필요한 검증 제거

2 participants