From 5580832675d382cfca33021f456701068b70c750 Mon Sep 17 00:00:00 2001 From: Christian Beutel <> Date: Fri, 19 Sep 2025 14:02:03 +0200 Subject: [PATCH] fixes waypoint update/delete --- db/migrations/1758283285_updated_waypoints.go | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 db/migrations/1758283285_updated_waypoints.go diff --git a/db/migrations/1758283285_updated_waypoints.go b/db/migrations/1758283285_updated_waypoints.go new file mode 100644 index 00000000..ac5ee8ee --- /dev/null +++ b/db/migrations/1758283285_updated_waypoints.go @@ -0,0 +1,42 @@ +package migrations + +import ( + "encoding/json" + + "github.com/pocketbase/pocketbase/core" + m "github.com/pocketbase/pocketbase/migrations" +) + +func init() { + m.Register(func(app core.App) error { + collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9") + if err != nil { + return err + } + + // update collection data + if err := json.Unmarshal([]byte(`{ + "deleteRule": "@request.auth.id != \"\" && (trail.author.user = @request.auth.id || author = @request.auth.id)", + "updateRule": "@request.auth.id != \"\" && (trail.author.user = @request.auth.id || author = @request.auth.id)" + }`), &collection); err != nil { + return err + } + + return app.Save(collection) + }, func(app core.App) error { + collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9") + if err != nil { + return err + } + + // update collection data + if err := json.Unmarshal([]byte(`{ + "deleteRule": "@request.auth.id != \"\" && ((@collection.trails.waypoints.id ?= id && @collection.trails.author.user = @request.auth.id) || author = @request.auth.id)", + "updateRule": "@request.auth.id != \"\" && ((@collection.trails.waypoints.id ?= id && @collection.trails.author.user = @request.auth.id) || author = @request.auth.id)" + }`), &collection); err != nil { + return err + } + + return app.Save(collection) + }) +}