Skip to content

refactor(store): split monolithic sqlite.go into domain-specific files#124

Merged
appleboy merged 1 commit intomainfrom
worktree-plan
Mar 22, 2026
Merged

refactor(store): split monolithic sqlite.go into domain-specific files#124
appleboy merged 1 commit intomainfrom
worktree-plan

Conversation

@appleboy
Copy link
Copy Markdown
Member

Summary

  • Split internal/store/sqlite.go (1,139 lines, 65+ methods) into 10 domain-specific files, each mapping to a core.Store interface group
  • Pure method relocation — no logic changes, no interface or struct changes
  • sqlite.go reduced from 1,139 → 290 lines (Store struct, New(), seedData(), infrastructure methods)

New files

File Interface Methods
user.go UserReader + UserWriter 9
client.go ClientReader + ClientWriter 10
token.go TokenReader + TokenWriter 14
audit_log.go AuditStore 5
user_authorization.go UserAuthorizationStore 7
oauth_connection.go OAuthConnectionStore 6
device_code.go DeviceCodeStore 5
cleanup.go CleanupStore + MetricsStore 5
authorization_code.go AuthorizationCodeStore 3

Test plan

  • make generate — templates compile
  • make build — full build passes
  • make test — all tests pass
  • make lint — 0 issues

🤖 Generated with Claude Code

- 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>
Copilot AI review requested due to automatic review settings March 22, 2026 01:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.go to store construction, seeding, and infrastructure/transaction helpers.
  • Kept method receivers and signatures consistent so *store.Store still satisfies core.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.

@appleboy appleboy merged commit ae44992 into main Mar 22, 2026
21 checks passed
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