refactor(backend): migrate db.DB to db.Conn PoolProxy across all handlers
Replace direct *pgxpool.Pool usage with PoolProxy wrapper across the entire backend: - db.DB renamed to db.Conn (*pgxpool.Pool -> *PoolProxy) - JWT functions now accept context.Context instead of using context.Background() - Handler DB calls route through PoolProxy for per-test transaction support - Fixture/helper/testdb functions accept Querier interface for decoupling - Query ordering fixed in bookings handlers: COUNT after data query to avoid pgx conn busy - Time truncation fixed: time.Date instead of Truncate(24*time.Hour) for week start calc - testmain_test.go files updated with SeedBaseline and NewPoolProxy Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -92,7 +92,7 @@ func CreateGuestUserHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// Check if email already exists with a registered (non-guest) role
|
||||
var existingRole string
|
||||
err = db.DB.QueryRow(r.Context(), `
|
||||
err = db.Conn.QueryRow(r.Context(), `
|
||||
SELECT account_role FROM users WHERE email = $1
|
||||
`, req.Email).Scan(&existingRole)
|
||||
|
||||
@@ -106,7 +106,7 @@ func CreateGuestUserHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// Create new guest user
|
||||
var userID string
|
||||
err = db.DB.QueryRow(r.Context(), `
|
||||
err = db.Conn.QueryRow(r.Context(), `
|
||||
INSERT INTO users
|
||||
(n_first_name, n_last_name, email, phone, date_of_birth,
|
||||
account_role, account_type, password_hash, privacy_policy_and_terms_consent)
|
||||
@@ -148,7 +148,7 @@ func CheckEmailHandler(w http.ResponseWriter, r *http.Request) {
|
||||
phone := strings.TrimSpace(r.URL.Query().Get("phone"))
|
||||
|
||||
var dbFirstName, dbLastName, dbPhone *string
|
||||
err := db.DB.QueryRow(r.Context(), `
|
||||
err := db.Conn.QueryRow(r.Context(), `
|
||||
SELECT n_first_name, n_last_name, phone
|
||||
FROM users
|
||||
WHERE email = $1 AND account_role != 'guest'
|
||||
|
||||
Reference in New Issue
Block a user