Skip to content

refactor: DataStore 스키마 버전 관리 및 DataMigration 적용 - #979

Open
Sadturtleman wants to merge 3 commits into
developfrom
refactor/973
Open

Sadturtleman wants to merge 3 commits into
developfrom
refactor/973

Conversation

@Sadturtleman

@Sadturtleman Sadturtleman commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

📌𝘐𝘴𝘴𝘶𝘦𝘴

📎𝘞𝘰𝘳𝘬 𝘋𝘦𝘴𝘤𝘳𝘪𝘱𝘵𝘪𝘰𝘯

DataStore에 스키마 버전을 함께 저장하고, 저장된 버전이 현재 버전보다 낮으면 DataMigration으로 저장값 자체를 현재 명세에 맞게 변환합니다.

v1.9.0 배포 후 구버전 정렬 키("RECENT", "OLD")가 DataStore에 남아 서재 목록이 비는 장애가 있었습니다. 지금까지는 읽을 때마다 매퍼에서 구 키를 변환했는데, 이 방식은 명세가 바뀔 때마다 읽기 코드에 레거시 분기가 쌓이고 저장값은 계속 구버전으로 남습니다. 자세한 배경은 DataStore에 남은 구버전 키 정리에 정리했습니다.

공통 마이그레이션 (VersionedPreferencesMigration)

  • SCHEMA_VERSION 키에 스키마 버전을 저장합니다. 키가 없으면 버전 관리 도입 이전(0)으로 봅니다.
  • 저장된 버전부터 현재 버전까지 등록된 단계(버전 → 버전 + 1)를 순서대로 적용하고 현재 버전을 기록합니다. 이미 현재 버전이면 실행하지 않습니다.
  • 앱 versionCode가 아닌 저장소별 스키마 번호를 사용해, 배포마다 마이그레이션이 다시 돌지 않습니다.
  • 현재 버전 범위를 벗어난 단계는 생성 시점에 막습니다.
  • 저장 명세(키 이름, 값 형식)를 바꿀 때는 스키마 버전을 올리고 이전 버전에서 넘어오는 단계를 추가하면 됩니다.

서재 필터 DataStore

  • 정렬 기준 변환(RECENT → created_desc, OLD → created_asc)과 단일 별점(novelRating) → 별점 범위 변환을 읽기 경로에서 LibraryFilterMigration(0 → 1)으로 옮겼습니다.
  • 마이그레이션은 변환한 값을 다시 저장하고 구 키(novelRating)를 제거합니다. JSON으로 읽을 수 없는 값은 폐기합니다.
  • 읽기 경로에는 서버 명세에 없는 정렬 기준을 기본값으로 바꾸는 방어 로직만 남겼고, 디코딩에 실패하면 필터 없음으로 처리합니다.

그 밖의 DataStore

  • 계정(ACCOUNT_DATASTORE), 유저(USER_DATASTORE), user_preferences(app)에 스키마 버전 1을 도입했습니다. 현재는 변환 단계 없이 버전만 기록합니다.
  • 이슈 작성 이후 develop에 추가된 피드 좋아요 보류 저장소(PENDING_FEED_LIKE_DATASTORE)에도 같은 방식으로 스키마 버전 1을 도입했습니다. 이 저장소에는 모든 키를 순회하거나 clear()하는 코드가 없어 버전 키가 섞여도 영향이 없습니다.
  • user_preferences는 기존 SharedPreferencesMigration 다음에 버전 마이그레이션이 실행됩니다.

📷𝘚𝘤𝘳𝘦𝘦𝘯𝘴𝘩𝘰𝘵

UI 변경 없음

💬𝘛𝘰 𝘙𝘦𝘷𝘪𝘦𝘸𝘦𝘳𝘴

  • 저장 명세를 바꿀 때 스키마 버전을 올리고 단계를 추가하는 규칙을 VersionedPreferencesMigration KDoc에 적었습니다. 앞으로 DataStore 키나 값 형식을 바꿀 때 참고 부탁드립니다.

🤖 Generated with Claude Code

Sadturtleman and others added 3 commits October 14, 2026 13:52
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Sadturtleman Sadturtleman self-assigned this Oct 14, 2026
@github-actions
github-actions Bot requested a review from devfeijoa October 14, 2026 04:53
@coderabbitai

coderabbitai Bot commented Oct 14, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 42 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bef5542f-2c6f-4d41-aceb-744dc635ee76
📥 Commits

Reviewing files that changed from the base of the PR and between 412f7ad and d4fd5f3.

📒 Files selected for processing: 10
  • app/src/main/java/com/into/websoso/core/common/util/ExtentionFuction.kt
  • app/src/main/java/com/into/websoso/data/di/DataStoreModule.kt
  • core/datastore/build.gradle.kts
  • core/datastore/src/main/java/com/into/websoso/core/datastore/datasource/library/DefaultLibraryFilterDataSource.kt
  • core/datastore/src/main/java/com/into/websoso/core/datastore/datasource/library/mapper/LibraryFilterMapper.kt
  • core/datastore/src/main/java/com/into/websoso/core/datastore/datasource/library/migration/LibraryFilterMigration.kt
  • core/datastore/src/main/java/com/into/websoso/core/datastore/di/DataStoreModule.kt
  • core/datastore/src/main/java/com/into/websoso/core/datastore/migration/VersionedPreferencesMigration.kt
  • core/datastore/src/test/java/com/into/websoso/core/datastore/datasource/library/migration/LibraryFilterMigrationTest.kt
  • core/datastore/src/test/java/com/into/websoso/core/datastore/migration/VersionedPreferencesMigrationTest.kt
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

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.

refactor: DataStore 스키마 버전 관리 및 DataMigration 적용

1 participant