refactor(store): split monolithic sqlite.go into domain-specific files#124
Merged
refactor(store): split monolithic sqlite.go into domain-specific files#124
Conversation
- Extract user operations into user.go (UserReader + UserWriter) - Extract client operations into client.go (ClientReader + ClientWriter) - Extract token operations into token.go (TokenReader + TokenWriter) - Extract device code operations into device_code.go (DeviceCodeStore) - Extract authorization code operations into authorization_code.go - Extract user authorization operations into user_authorization.go - Extract OAuth connection operations into oauth_connection.go - Extract audit log operations into audit_log.go (AuditStore) - Extract cleanup and metrics operations into cleanup.go - Keep Store struct, New(), seedData(), and infrastructure methods in sqlite.go Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors the internal/store package by splitting the previously monolithic sqlite.go into smaller, domain-focused files aligned with core.Store interface groupings, while keeping behavior and public APIs unchanged.
Changes:
- Moved user, client, token, device code, OAuth connection, audit log, authorization code, and consent (user authorization) methods into dedicated files.
- Reduced
internal/store/sqlite.goto store construction, seeding, and infrastructure/transaction helpers. - Kept method receivers and signatures consistent so
*store.Storestill satisfiescore.Store.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| internal/store/sqlite.go | Removed relocated domain methods; retains Store struct, New/seed, health/close, and transaction helpers. |
| internal/store/user.go | User read/write and external-user upsert operations moved here. |
| internal/store/client.go | OAuth client read/write and listing/counting operations moved here. |
| internal/store/token.go | Access token read/write, status updates, and revocation operations moved here. |
| internal/store/device_code.go | Device code CRUD operations moved here. |
| internal/store/oauth_connection.go | OAuth connection CRUD operations moved here. |
| internal/store/audit_log.go | Audit log create/query/stats operations moved here. |
| internal/store/cleanup.go | Expired-data cleanup and metrics counting operations moved here. |
| internal/store/authorization_code.go | Authorization code create/get/mark-used operations moved here. |
| internal/store/user_authorization.go | Consent (user authorization) read/write/revoke/list operations moved here. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
internal/store/sqlite.go(1,139 lines, 65+ methods) into 10 domain-specific files, each mapping to acore.Storeinterface groupsqlite.goreduced from 1,139 → 290 lines (Store struct, New(), seedData(), infrastructure methods)New files
user.goclient.gotoken.goaudit_log.gouser_authorization.gooauth_connection.godevice_code.gocleanup.goauthorization_code.goTest plan
make generate— templates compilemake build— full build passesmake test— all tests passmake lint— 0 issues🤖 Generated with Claude Code