refac: migration crash, real-database tests, site deleted during create, ruels out of the repo, lists
This commit is contained in:
1 parent
680b9a1308
commit
9d284e65a9
62 files changed
+1858
-987
No files matched your search
@@ -26,6 +26,7 @@ const (
|
||||
postgresLockNotAvailable = "55P03"
|
||||
postgresDeadlockDetected = "40P01"
|
||||
postgresSerializationFailure = "40001"
|
||||
postgresUniqueViolation = "23505"
|
||||
)
|
||||
|
||||
var timeType = reflect.TypeOf(time.Time{})
|
||||
@@ -115,6 +116,14 @@ func (postgresDriver) NewBackup(db *gorm.DB, directory string, now func() time.T
|
||||
var postgresContentionCodes = []string{postgresLockNotAvailable, postgresDeadlockDetected, postgresSerializationFailure}
|
||||
|
||||
func (postgresDriver) IsLockContention(err error) bool {
|
||||
return hasPostgresCode(err, postgresContentionCodes)
|
||||
}
|
||||
|
||||
func (postgresDriver) IsUniqueViolation(err error) bool {
|
||||
return hasPostgresCode(err, []string{postgresUniqueViolation})
|
||||
}
|
||||
|
||||
func hasPostgresCode(err error, codes []string) bool {
|
||||
var failure *pgconn.PgError
|
||||
return errors.As(err, &failure) && slices.Contains(postgresContentionCodes, failure.Code)
|
||||
return errors.As(err, &failure) && slices.Contains(codes, failure.Code)
|
||||
}
|
||||
Reference in new issue
Block a user