Files
photoprism/internal/entity/migrate/errors.go
2025-01-17 06:24:29 +01:00

33 lines
854 B
Go

package migrate
import "strings"
type QueryErr map[string][]string
// Matches checks if there is a match for the specified query and error string.
func (m QueryErr) Matches(query, err string) bool {
query = strings.ToLower(query)
err = strings.ToLower(err)
for substr, e := range m {
if strings.Contains(query, substr) {
for _, s := range e {
if strings.Contains(err, s) {
return true
}
}
}
}
return false
}
var IgnoreErr = QueryErr{
"rename": {"no such", "already exists"},
"replace": {"no such", "exist", "exists"},
" ignore ": {"no such", "exist", "exists"},
"drop index ": {"drop"},
"drop table ": {"drop"},
"alter table ": {"duplicate", "exist", "unknown", "1054", "1146"},
"alter ignore table ": {"duplicate", "exist", "unknown", "1054", "1146"},
}