Add webhook-event retention job, schema, and testdb pre-flight hint

square_webhook_events is now CREATE TABLE IF NOT EXISTS, registered as the 24th maintenance job (sweep-square-webhook-events, daily 2:30am) pruning rows older than 90 days, and testdb gives a clear docker compose hint when the admin DB connection fails.
This commit is contained in:
2026-08-22 00:34:49 +01:00
parent 5ea89da2ad
commit 8720e28dbe
5 changed files with 155 additions and 2 deletions
+7
View File
@@ -53,6 +53,13 @@ func CreateTestDatabase(dbName string) *pgxpool.Pool {
}
defer adminPool.Close()
// Pre-flight check: pgxpool.New is lazy, so surface the admin connection
// failure here with actionable guidance instead of a confusing
// "database \"crussell_test_...\" does not exist" error further down.
if err := adminPool.Ping(ctx); err != nil {
log.Fatalf("testdb: run `docker compose up -d postgres` (see README Getting Started) — test database admin connection failed: %v", err)
}
safeName := pgx.Identifier{dbName}.Sanitize()
// Drop existing database with retries (terminate connections first)