Storage Layer Refactor (No Globals, Query Isolation) #3

Open
opened 2025-10-23 21:39:51 +00:00 by H3ALY · 0 comments
Owner

Refactor DB init

  • Replace models.SetDB and global DB with storage.Open(cfg).

Context adoption

  • Ensure all storage functions accept context.Context.

Move SQL into local repos

  • Create internal/storage/mysql//repo.go + queries.go.

Embed SQL (optional)

  • Use //go:embed for .sql files per feature.

Acceptance Criteria

  1. No global DB variables.
  2. Storage only exposes constructor + methods.
  3. SQL centralized and reusable.
**Refactor DB init** - Replace models.SetDB and global DB with storage.Open(cfg). **Context adoption** - Ensure all storage functions accept context.Context. **Move SQL into local repos** - Create internal/storage/mysql/<feature>/repo.go + queries.go. **Embed SQL (optional)** - Use //go:embed for .sql files per feature. **Acceptance Criteria** 1. No global DB variables. 2. Storage only exposes constructor + methods. 3. SQL centralized and reusable.
H3ALY added this to the 🛠 In Progress project 2025-10-23 21:39:51 +00:00
Sign in to join this conversation.