feat: payment 서버 데이터를 backend로 마이그레이션하는 스크립트 추가#45
Conversation
ffa69bc to
660af08
Compare
| - auto_username: 위 미매칭 + username 동일 (같은 사람이 다른 email 로 양쪽 가입한 케이스) | ||
| - manual: hardcoded — darjeeling@gmail.com (legacy id 5, 1135) → backend darjeeling@python.or.kr (id 5) | ||
| - shifted: 모두 미매칭 → legacy.id + USER_ID_OFFSET (backend max id 와 충돌 없는 여유 공간) | ||
| """ |
There was a problem hiding this comment.
자세하게 주석 남겨주셔서 감사합니다!
혹시 shifted case는 어떤 경우일까요?
There was a problem hiding this comment.
아 운영진이 아닌 일반 티켓 구매 참가자분들입니다ㅎㅎ
| class Migration(migrations.Migration): | ||
| dependencies = [ | ||
| ("user", "0009_alter_historicaluserext_options_and_more"), | ||
| ("order", "0001_initial"), | ||
| ("product", "0001_initial"), | ||
| ("payment_history", "0001_initial"), | ||
| # allauth — socialaccount/account 테이블 선행 생성 | ||
| ("socialaccount", "0006_alter_socialaccount_extra_data"), | ||
| ("account", "0009_emailaddress_unique_primary_email"), | ||
| ] | ||
| operations = [migrations.RunPython(migrate_data, reverse_code=migrations.RunPython.noop)] |
There was a problem hiding this comment.
중간에 실패하는 경우를 대비해서 롤백이나 transaction 관련 설정이 추가되면 좋을 것 같습니다!
| # 사전 계산값. 새 URL 이 발견되면 여기에 추가하거나 RunPython 결과를 확인할 것. | ||
| LEGACY_IMAGE_META: dict[str, dict] = { | ||
| "https://s3.ap-northeast-2.amazonaws.com/pyconkr-backend-prod-public/public/t-shirt-compressed.png": { | ||
| "file_path": "public/t-shirt-compressed.png", | ||
| "hash": "d131452cf6cd2287e4c302f4f7c17bb5", | ||
| "size": 2069683, | ||
| "mimetype": "image/png", | ||
| }, | ||
| "https://s3.ap-northeast-2.amazonaws.com/pyconkr-backend-prod-public/public/t-shirt-comporessed-2.png": { | ||
| "file_path": "public/t-shirt-comporessed-2.png", | ||
| "hash": "30acab0125661cac1ce75c4a4633042a", | ||
| "size": 2278886, | ||
| "mimetype": "image/png", | ||
| }, | ||
| } |
There was a problem hiding this comment.
혹시 가능하다면, 이런 URL을 .env의 환경변수로 빼도 좋을 것 같습니다!
- 형식이 정해져야 한다면 type을 사용해도 좋을 것 같아요!
There was a problem hiding this comment.
요게 이번 딱 1번만 사용될 마이그레이션이고, 마이그레이션이 끝나면 noop으로 본 마이그레이션 파일들의 내용물을 비워버릴 예정이에요! 그렇다보니 .env로 분리하기에 좀 애매합니다ㅎㅎ;;
그리고 https://s3.ap-northeast-2.amazonaws.com/pyconkr-backend-prod-public/를 미래에 사용하게 되지 않을까...라고 해도, 아시다시피 저희가 파일 저장소를 S3 대신 인스턴스에서 직접 응답하는 구조로 변경 예정이다보니... 이번만 하드코딩으로 이렇게 진행하려 합니다 🙏
| class Migration(migrations.Migration): | ||
| dependencies = [("file", "0001_initial"), ("product", "0001_initial")] | ||
| operations = [ |
There was a problem hiding this comment.
operation이 여러 개라서 transaction 처리가 추가되면 좋을 것 같습니다!
주요 변경 사항