Skip to content

Conversation

@KubrickCode
Copy link
Owner

@KubrickCode KubrickCode commented Sep 22, 2025

  • 기존에 prisma 로 마이그레이션 관리를 하지만, code first 방식의 gorm 을 사용했기 때문에 schema 를 다시 go 쪽에 작성해야하는 문제가 있었음. 데이터베이스에 변경사항이 있을 때 마다 schema.prisma 와 schema.go 를 항상 같이 신경써야했음.
  • 마이그레이션은 prisma 를 통해 중앙 관리할 예정이기 때문에 db first 방식인 SQLBoiler 방식으로 전면 교체함.
  • 이를 통해 go 쪽에서는 간단한 명령어만으로 코어 모델 및 메서드를 db로부터 뽑아와서 생성할 수 있게됨.

@KubrickCode KubrickCode self-assigned this Sep 22, 2025
@KubrickCode KubrickCode marked this pull request as draft September 22, 2025 15:09
@gemini-code-assist
Copy link

Summary of Changes

Hello @KubrickCode, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 Pull Request는 Go 애플리케이션의 데이터베이스 접근 계층을 GORM에서 SQLBoiler로 전환하는 대규모 리팩토링을 수행합니다. 이는 데이터베이스 상호작용의 견고성과 효율성을 높이고, 자동 생성된 코드를 활용하여 개발 프로세스를 간소화하며, 장기적인 유지보수 부담을 줄이는 것을 목표로 합니다. 기존 비즈니스 로직은 새로운 DB 계층에 맞춰 업데이트되었습니다.

Highlights

  • SQLBoiler 도입 및 GORM 제거: 기존 GORM 기반의 데이터베이스 접근 계층을 SQLBoiler로 전면 교체했습니다. 이는 Go 애플리케이션의 ORM(Object-Relational Mapping)을 변경하여 타입 안정성, 성능, 그리고 유지보수성을 향상시키기 위함입니다. GORM 관련 파일들이 제거되고 SQLBoiler로 자동 생성된 모델 및 관련 파일들이 추가되었습니다.
  • 데이터베이스 연결 및 트랜잭션 처리 방식 변경: 데이터베이스 연결 방식이 GORM의 gorm.DB에서 Go 표준 라이브러리의 database/sqllib/pq 드라이버를 사용하는 방식으로 변경되었습니다. 이에 따라 트랜잭션 처리 로직도 업데이트되었으며, 개발 환경의 DATABASE_URL?sslmode=disable 옵션이 추가되었습니다.
  • 데이터베이스 인터페이스 및 구현 재정의: 기존에 수동으로 작성되었던 각 테이블(AuctionItem, MarketItem, Item 등)에 대한 DB 인터페이스와 구현체가 SQLBoiler를 통해 자동 생성된 모델을 기반으로 재정의되었습니다. 이는 데이터베이스 스키마 변경 시 코드 업데이트의 용이성을 높이고 휴먼 에러를 줄이는 데 기여합니다.
  • 기존 비즈니스 로직 업데이트: 경매 아이템 통계 스크래퍼 및 마켓 아이템 통계 스크래퍼 등 기존에 GORM을 사용하던 비즈니스 로직들이 SQLBoiler로 생성된 새로운 DB 접근 계층을 사용하도록 수정되었습니다. 특히 decimal.Decimal 타입 변환 및 통계 계산 로직이 새로운 모델에 맞춰 조정되었습니다.
  • 스키마 동기화 Justfile 명령 추가: 개발 편의성을 위해 justfilesync-go-schema 명령이 추가되었습니다. 이 명령을 통해 sqlboiler psql을 실행하여 데이터베이스 스키마 변경 시 Go 모델 파일을 쉽게 업데이트할 수 있습니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

SQLBoiler 도입을 위한 대규모 리팩토링이 진행되었습니다. GORM에서 SQLBoiler로 ORM을 교체하면서 많은 파일이 변경되었습니다. 전반적으로 SQLBoiler의 기능을 잘 활용하고 있지만, 몇 가지 중요한 개선점이 보입니다. 특히 트랜잭션 처리 로직에 심각한 버그가 있으며, 여러 곳에서 N+1 쿼리 문제와 같은 성능 저하 요인이 발견되었습니다. 또한, nil 컨텍스트를 전달하여 패닉을 유발할 수 있는 코드도 있습니다. 이러한 부분들을 수정하여 안정성과 성능을 높이는 것이 좋겠습니다.

@KubrickCode
Copy link
Owner Author

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

안녕하세요. SQLBoiler 도입을 통해 데이터베이스 스키마를 단일 진실 공급원(SSOT)으로 삼고, 타입-세이프한 코드를 생성하도록 데이터 접근 계층을 리팩터링한 점이 인상 깊습니다. 이는 코드의 유지보수성과 안정성을 크게 향상시킬 것입니다. 몇 가지 성능 및 버그 수정과 관련된 제안 사항을 남겼으니 확인 부탁드립니다.

@KubrickCode KubrickCode marked this pull request as ready for review September 24, 2025 14:04
@KubrickCode KubrickCode linked an issue Sep 25, 2025 that may be closed by this pull request
@KubrickCode
Copy link
Owner Author

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

SQLBoiler를 도입하여 기존 GORM의 스키마 이중 관리 문제를 해결하려는 좋은 시도입니다. 전체적으로 데이터 접근 계층을 리팩토링하고, 레포지토리 패턴과 Decimal 래퍼를 도입한 점이 인상적입니다.

다만, 몇 가지 성능 관련 문제점들이 보입니다. 아이템 통계 업데이트 시 발생하는 N+1 쿼리 문제와, 루프 내에서 개별적으로 DB 작업을 수행하는 비효율적인 CreateMany/UpsertMany 구현이 있습니다.

자세한 내용은 각 파일에 대한 리뷰 코멘트를 참고해주세요.

- 기존에 prisma 로 마이그레이션 관리를 하지만, code first 방식의 gorm 을 사용했기 때문에 schema 를 다시 go 쪽에 작성해야하는 문제가 있었음. 데이터베이스에 변경사항이 있을 때 마다 schema.prisma 와 schema.go 를 항상 같이 신경써야했음.
- 마이그레이션은 prisma 를 통해 중앙 관리할 예정이기 때문에 db first 방식인 SQLBoiler 방식으로 전면 교체함.
- 이를 통해 go 쪽에서는 간단한 명령어만으로 코어 모델 및 메서드를 db로부터 뽑아와서 생성할 수 있게됨.
@KubrickCode KubrickCode merged commit 2e814b5 into main Sep 25, 2025
2 checks passed
@KubrickCode KubrickCode deleted the sql-boiler branch September 28, 2025 07:03
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.

ts, go 양 측에서 스키마를 모두 작성해야하는 문제

2 participants