1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

Compare commits

..

2 Commits

Author SHA1 Message Date
Ferdinand Mütsch
eca443be35
Merge pull request #507 from cbrand/master
fix failing migration which prohibits startup
2023-07-21 08:50:42 +02:00
Christoph Brand
04ec44dcef fix: failing migration
Fix an issue in migration which results in the following error message
due to wrong and or precedence configuration:
```
panic: runtime error: index out of range [0] with length 0
```
2023-07-20 18:44:26 +02:00

View File

@ -1,12 +1,13 @@
package migrations
import (
"regexp"
"strings"
"github.com/emvi/logbuch"
"github.com/muety/wakapi/config"
"github.com/muety/wakapi/models"
"gorm.io/gorm"
"regexp"
"strings"
)
// due to an error in the model definition, idx_time_user used to only cover 'user_id', but not time column
@ -37,7 +38,7 @@ func init() {
}
matches := regexp.MustCompile("(?i)\\((.+)\\)$").FindStringSubmatch(ddl)
if len(matches) > 0 && !strings.Contains(matches[0], "`user_id`") || !strings.Contains(matches[0], "`time`") {
if len(matches) > 0 && (!strings.Contains(matches[0], "`user_id`") || !strings.Contains(matches[0], "`time`")) {
drop = true
}
} else {