Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: 기존에 등록된 프로젝트에 이미지 추가 시 예외처리 발생하지 않던 에러 해결 #157

Merged
merged 5 commits into from
Sep 19, 2024

Conversation

yunhacandy
Copy link
Member

@yunhacandy yunhacandy commented Sep 19, 2024

연관된 이슈

이슈링크(url): #156 (comment)

✅ 작업 내용

  • 프로젝트 추가 간에 검증 로직 및 예외 사항 핸들링 할 것
  • extends로 BaseTimeEntity를 프로젝트, 프로젝트 이미지, 프로젝트 멤버에 달기
  • order 0부터 시작하게 바꾸기

SQL문

기존에 있는 프로젝트 이미지 순서를 바꾸기 위한 쿼리 (주석 반드시 확인 바랍니다!!)

UPDATE project_image pi
    JOIN (
        SELECT project_image_id,
               ROW_NUMBER() OVER (PARTITION BY project_id ORDER BY project_image_id) - 1 AS new_order
        FROM project_image
        WHERE project_image_type = 'DETAIL' -- project_image_type를 지정
    ) AS ordered_images
    ON pi.project_image_id = ordered_images.project_image_id
SET pi.project_image_order = ordered_images.new_order
WHERE pi.project_id = 1;  -- project_id를 지정

Project, ProjectImage, ProjectMember 테이블에 컬럼 추가:

ALTER TABLE Project
ADD COLUMN created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
ADD COLUMN modified_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;

ALTER TABLE ProjectImage
ADD COLUMN created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
ADD COLUMN modified_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;

ALTER TABLE ProjectMember
ADD COLUMN created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
ADD COLUMN modified_at  TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;

@yunhacandy yunhacandy self-assigned this Sep 19, 2024
Copy link
Member

@Youthhing Youthhing left a comment

Choose a reason for hiding this comment

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

리뷰 확인했습니다. optional 활용과 jpa 메서드 관련해서 공부해보시면 좋을 것 같아요!

추가로 작성하신 sql 쿼리문은 project_id가 1인 대상에 order를 입력하는 쿼리일까요?

@yunhacandy
Copy link
Member Author

yunhacandy commented Sep 19, 2024

리뷰 확인했습니다. optional 활용과 jpa 메서드 관련해서 공부해보시면 좋을 것 같아요!

추가로 작성하신 sql 쿼리문은 project_id가 1인 대상에 order를 입력하는 쿼리일까요?

'입력'보다는 '변경'이 맞을거 같습니다.
어제 테스트를 해보니 qa 서버의 project1 같은 경우는 사진들의 order가 다 0으로 지정되어있었습니다.
그래서 테스트 서버랑 cotato.kr에 이미 프로젝트가 있기에 그 프로젝트들에 대해 order의 값을 바꾸기 위해 만들어놓은 쿼리문입니다.
project_id가 뭔지 확인하고 주석을 넣어놓은 곳에 맞춰서 type이랑 id 바꾸면서 쿼리문 돌리면 좋을거 같다고 생각해서 만들어놨습니다.

추가로 type을 DETAIL로 국한하지 않은 이유는 이전 코드는 order가 1부터 시작이라 LOGO랑 THUMBNAIL의 order도 바꿔야 해서 입니다.

@Youthhing Youthhing merged commit 5795753 into develop Sep 19, 2024
1 check passed
@Youthhing Youthhing deleted the fix/#MF-53-project-image branch September 19, 2024 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants