Skip to content

PF-3943 Add sqlutil package with SQLC integration#267

Merged
svenwltr merged 6 commits intomainfrom
add-sqlutil-package
Sep 9, 2025
Merged

PF-3943 Add sqlutil package with SQLC integration#267
svenwltr merged 6 commits intomainfrom
add-sqlutil-package

Conversation

@svenwltr
Copy link
Copy Markdown
Member

@svenwltr svenwltr commented Sep 8, 2025

Summary

  • Introduces new sqlutil package that consolidates database utilities across rebuy projects
  • Eliminates ~200+ lines of duplicate code per project
  • Updates full example application to demonstrate real PostgreSQL operations via SQLC
  • Provides connection management, migration framework, transaction wrappers, and URI utilities

Key Features

  • Connection Management: Unified connection creation with optional DataDog tracing
  • Migration Framework: Generic migration execution with embedded filesystems
  • Transaction Wrappers: Reusable transaction and connection hijacking utilities
  • SQLC Integration: Complete example showing type-safe database operations
  • Schema Design: Proper PostgreSQL schema with relationships, indexes, and sample data

Code Quality Improvements

  • Standardizes database patterns across all rebuy projects
  • Brings transaction support to projects that previously lacked it
  • Centralizes SQL best practices and bug fixes in single location
  • Maintains flexibility for project-specific database needs

Test Plan

  • Verify sqlutil package compiles and imports correctly
  • Test database connection with and without tracing enabled
  • Run migration framework with embedded filesystem
  • Validate SQLC code generation produces expected Go types
  • Test transaction wrappers handle rollbacks properly
  • Verify full example application starts and serves pages
  • Check PostgreSQL schema creation and sample data insertion
  • Test CRUD operations through web interface

🤖 Generated with Claude Code

@svenwltr svenwltr self-assigned this Sep 8, 2025
@svenwltr svenwltr force-pushed the add-sqlutil-package branch from 9cdb9ea to 0207cbe Compare September 8, 2025 14:18
This commit introduces comprehensive database functionality to the rebuy-go-sdk:

- New pgutil package with PostgreSQL utilities and connection management
- SQLC integration for type-safe database operations
- Complete database layer implementation in the full example
- Migration support with embedded SQL files
- DataDog tracing integration for database operations
- Updated handlers, workers, and templates to use database operations

The implementation replaces hardcoded data with real database CRUD operations and provides a solid foundation for database-driven applications.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@svenwltr svenwltr force-pushed the add-sqlutil-package branch from a1af3a6 to f860218 Compare September 8, 2025 20:30
svenwltr and others added 3 commits September 9, 2025 12:04
- Replace standalone README.md with enhanced doc.go package documentation
- Add complete usage examples including dependency injection with dig
- Include transaction support and connection hijacking patterns
- Provide configuration templates and quick start guide
- Remove redundant README file in favor of godoc format

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Only ListUsers query is actually used in the codebase. Removed:
- All post queries (9 queries): GetPostByID, ListPosts, ListPublishedPosts, etc.
- Unused user queries (7 queries): GetUserByID, CreateUser, UpdateUser, etc.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
The templates were moved to comprehensive godoc documentation
in the previous commit, making these separate files redundant.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@svenwltr svenwltr marked this pull request as ready for review September 9, 2025 10:22
@svenwltr svenwltr requested a review from a team as a code owner September 9, 2025 10:22
@svenwltr svenwltr requested a review from der-eismann September 9, 2025 12:59
Replace all references to 'sqlutil' with 'pgutil' in function documentation
comments to maintain consistency throughout the package.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@svenwltr svenwltr changed the title Add sqlutil package with SQLC integration PF-3943 Add sqlutil package with SQLC integration Sep 9, 2025
@svenwltr svenwltr merged commit 68450e1 into main Sep 9, 2025
1 check passed
@svenwltr svenwltr deleted the add-sqlutil-package branch September 9, 2025 19:02
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