refactor(db): replace sqlc with handwritten pgx repos

- Finish Paddle-to-Stripe billing migration; drop paddle/stripe libs
- Renumber migrations; add 00012 memberships+manage_token,
  00013 location_type_capacity
- Add tests: admin, auth, bookings customer service
- Remove graphify-out artifacts and stale env files

Authored By: TDvorak <[email protected]>

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
Tomas DvorakandDevin committed 2026-09-17 20:21:34 +02:00
1 parent 2039669e2c
commit f2f7439050
93 files changed
+6987 -69060

No files matched your search

@@ -0,0 +1,55 @@
package db
import (
"context"
)
func (r *PGRepository) ListEmailTemplates(ctx context.Context, tenantID string) ([]EmailTemplateRecord, error) {
rows, err := r.pool.Query(ctx, `
SELECT id, tenant_id, type, subject, body_html, body_text, is_enabled, updated_at
FROM email_templates
WHERE tenant_id = $1
ORDER BY type
`, tenantID)
if err != nil {
return nil, err
}
defer rows.Close()
var records []EmailTemplateRecord
for rows.Next() {
var rec EmailTemplateRecord
if err := rows.Scan(&rec.ID, &rec.TenantID, &rec.Type, &rec.Subject, &rec.BodyHTML, &rec.BodyText, &rec.IsEnabled, &rec.UpdatedAt); err != nil {
return nil, err
}
records = append(records, rec)
}
return records, rows.Err()
}
func (r *PGRepository) GetEmailTemplate(ctx context.Context, tenantID string, templateType string) (EmailTemplateRecord, error) {
var rec EmailTemplateRecord
err := r.pool.QueryRow(ctx, `
SELECT id, tenant_id, type, subject, body_html, body_text, is_enabled, updated_at
FROM email_templates
WHERE tenant_id = $1 AND type = $2
`, tenantID, templateType).Scan(&rec.ID, &rec.TenantID, &rec.Type, &rec.Subject, &rec.BodyHTML, &rec.BodyText, &rec.IsEnabled, &rec.UpdatedAt)
return rec, err
}
func (r *PGRepository) UpsertEmailTemplate(ctx context.Context, params EmailTemplateRecord) (EmailTemplateRecord, error) {
var rec EmailTemplateRecord
err := r.pool.QueryRow(ctx, `
INSERT INTO email_templates (tenant_id, type, subject, body_html, body_text, is_enabled)
VALUES ($1, $2, $3, $4, $5, $6)
ON CONFLICT (tenant_id, type) DO UPDATE SET
subject = EXCLUDED.subject,
body_html = EXCLUDED.body_html,
body_text = EXCLUDED.body_text,
is_enabled = EXCLUDED.is_enabled,
updated_at = now()
RETURNING id, tenant_id, type, subject, body_html, body_text, is_enabled, updated_at
`, params.TenantID, params.Type, params.Subject, params.BodyHTML, params.BodyText, params.IsEnabled).Scan(
&rec.ID, &rec.TenantID, &rec.Type, &rec.Subject, &rec.BodyHTML, &rec.BodyText, &rec.IsEnabled, &rec.UpdatedAt)
return rec, err
}