first commit

This commit is contained in:
Beyhan Oğur
2026-04-26 21:35:24 +03:00
commit bbbf76b184
592 changed files with 246870 additions and 0 deletions

19
pkg/utils/db_utils.go Normal file
View File

@@ -0,0 +1,19 @@
package utils
import (
"errors"
"strings"
"github.com/jackc/pgx/v5/pgconn"
)
// IsDuplicateKeyError checks if the error is a PostgreSQL duplicate key violation
func IsDuplicateKeyError(err error) bool {
var pgErr *pgconn.PgError
if errors.As(err, &pgErr) {
// 23505 is the PostgreSQL error code for unique_violation
return pgErr.Code == "23505"
}
// Fallback for other drivers or if error wrapping is different
return strings.Contains(err.Error(), "duplicate key value violates unique constraint")
}