photoprism/internal/migrate/errors.go
Michael Mayer e3bb8b19dd Routing: Prefix frontend UI routes with /library #840 #2466
Also improves migrations and updates the db schema docs.

Signed-off-by: Michael Mayer <michael@photoprism.app>
2022-10-15 21:54:11 +02:00

32 lines
701 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"},
}