Conversation
database.yml 에 schema_search_path: "ra_news,public" 이 지정돼 있으나 리포지토리 어디에도 ra_news 스키마를 만드는 코드가 없었다. PostgreSQL 은 search_path 에 없는 스키마를 건너뛰고 다음 항목(public)에 객체를 만들기 때문에, 신규 클론에서 db:migrate 로 셋업하면 모든 테이블이 public 에 생성되어 프로덕션(ra_news)과 다른 레이아웃이 됐다. ra_news 를 만드는 유일한 코드는 gitignore 대상인 db/schema.rb 의 create_schema 였다. 최초 스키마(20260330052834_init_schema)보다 앞선 타임스탬프를 부여해 신규 환경에서 가장 먼저 실행되게 하고, 이미 적용된 환경에서는 CREATE SCHEMA IF NOT EXISTS 로 무해하게 통과시킨다. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012km6QF6Pd6N1dfoDifok1q
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
Warning Review limit reached
Next review available in: 91 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
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. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bf3dc13c21
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| def up | ||
| return unless search_path_includes_schema? | ||
|
|
||
| execute("CREATE SCHEMA IF NOT EXISTS #{quote_schema}") |
There was a problem hiding this comment.
기존 public 전용 DB를 빈 ra_news 상태로 두지 마세요
이 수정 전 db:migrate로 초기화되어 애플리케이션 테이블이 모두 public에 있는 환경에서는 이 문장이 빈 ra_news 스키마만 만들고 기존 테이블은 이동하지 않습니다. 이후 schema_search_path가 ra_news,public이므로 기존 테이블은 계속 public에서 조회되지만 향후 create_table 마이그레이션은 ra_news에 생성되어 한 데이터베이스의 앱 객체가 두 스키마로 갈라집니다. 이 경우를 감지해 기존 객체를 옮기거나 안전하게 중단해야, 바로 이 결함으로 이미 만들어진 클론도 운영 레이아웃으로 수렴할 수 있습니다.
AGENTS.md reference: AGENTS.md:L171-L171
Useful? React with 👍 / 👎.
Closes #933
문제
config/database.yml:23에schema_search_path: "ra_news,public"이 지정돼 있지만, 리포지토리 어디에도ra_news스키마를 만드는 코드가 없었다.PostgreSQL 은 search_path 첫 항목이 존재하지 않으면 조용히 건너뛰고 다음 항목(
public)에 객체를 만든다.ra_news를 생성하는 유일한 코드는 gitignore 대상인db/schema.rb의create_schema였으므로, 신규 클론에서db:migrate로 셋업하면 모든 테이블이public에 생성되어 프로덕션과 다른 레이아웃이 됐다.변경
ra_news스키마를 만드는 마이그레이션을 추가했다. 최초 스키마(20260330052834_init_schema)보다 앞선 타임스탬프(20260330052833)를 부여해 신규 환경에서 가장 먼저 실행되게 한다.CREATE SCHEMA IF NOT EXISTS— 이미 스키마가 있는 환경(프로덕션 포함)에서는 무해하게 통과down은 의도적으로 no-op — 스키마를 지우면 내부 테이블이 전부 함께 사라져init_schema롤백보다 파괴적이다ra_news가 없으면 아무것도 하지 않는다검증
① 신규 환경 (스키마 없음 + schema.rb 없음) — 실제로 마이그레이션 46개가 실행되고 테이블이
ra_news에 생성됨:변경 전 동일 절차에서는 29개 테이블이 전부
public에 생성됐다.② 기존 환경 (스키마·테이블 이미 존재) —
schema_migrations에서 해당 버전만 지우고 재실행:③
bundle exec rspec→ 64 examples, 0 failures /rubocop→ no offenses남는 부분
public에 남는 2개는schema_migrations와ar_internal_metadata다. Rails 가 첫 마이그레이션 이전에 만들기 때문에 마이그레이션으로는 위치를 옮길 수 없다. 앱 동작에는 영향이 없어(search_path 로 해석됨) 이번 PR 범위에서는 두었다.db:create시점에 스키마를 만드는 rake 후크로 이것까지 맞출 수 있지만, 같은 일을 하는 두 번째 메커니즘이 생기고 rake 로드 순서 의존이 붙어서 뺐다. 필요하면 별도로 논의.관련
db/schema.rb가 gitignore 대상이라 스키마 손상·드리프트가 diff 로 잡히지 않는 문제. 이 PR 의db:schema:load라운드트립 이슈도 거기서 함께 다룬다.🤖 Generated with Claude Code
https://claude.ai/code/session_012km6QF6Pd6N1dfoDifok1q