fix:#16 fixed database search for module in migration

This commit is contained in:
Elmar Kresse
2023-10-25 18:39:22 +02:00
parent 9513fc06d0
commit 1e3e48422d

View File

@@ -30,7 +30,7 @@ func MigrateFeedJson(app *pocketbase.PocketBase) error {
var uuidFeedCollections []model.FeedCollection
for _, module := range modules {
uuid := searchUUIDForModule(app, module.Name)
uuid := searchUUIDForModule(app, module)
if uuid != "" {
uuidFeedCollections = append(uuidFeedCollections, model.FeedCollection{UUID: uuid, Name: module.Name, Course: module.Course, UserDefinedName: module.UserDefinedName})
@@ -48,9 +48,9 @@ func MigrateFeedJson(app *pocketbase.PocketBase) error {
return nil
}
func searchUUIDForModule(app *pocketbase.PocketBase, moduleName string) string {
func searchUUIDForModule(app *pocketbase.PocketBase, module model.FeedCollection) string {
var event model.Event
err := app.Dao().DB().Select("*").From("events").Where(dbx.NewExp("Name = {:name}", dbx.Params{"name": moduleName})).One(&event)
err := app.Dao().DB().Select("*").From("events").Where(dbx.NewExp("Name = {:name} AND course = {:course}", dbx.Params{"name": module.Name, "course": module.Course})).One(&event)
if err != nil {
return ""
}