updates migrations
This commit is contained in:
@@ -22,7 +22,7 @@ import (
|
|||||||
"pocketbase/integrations/komoot"
|
"pocketbase/integrations/komoot"
|
||||||
"pocketbase/integrations/strava"
|
"pocketbase/integrations/strava"
|
||||||
|
|
||||||
// _ "pocketbase/migrations"
|
_ "pocketbase/migrations"
|
||||||
"pocketbase/util"
|
"pocketbase/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ func main() {
|
|||||||
app := pocketbase.New()
|
app := pocketbase.New()
|
||||||
client := initializeMeiliSearch()
|
client := initializeMeiliSearch()
|
||||||
|
|
||||||
// registerMigrations(app)
|
registerMigrations(app)
|
||||||
setupEventHandlers(app, client)
|
setupEventHandlers(app, client)
|
||||||
|
|
||||||
if err := app.Start(); err != nil {
|
if err := app.Start(); err != nil {
|
||||||
@@ -489,7 +489,9 @@ func onBeforeServeHandler(app *pocketbase.PocketBase, client meilisearch.Service
|
|||||||
return func(e *core.ServeEvent) error {
|
return func(e *core.ServeEvent) error {
|
||||||
registerRoutes(e, app, client)
|
registerRoutes(e, app, client)
|
||||||
registerCronJobs(app)
|
registerCronJobs(app)
|
||||||
return bootstrapData(app, client)
|
bootstrapData(app, client)
|
||||||
|
|
||||||
|
return e.Next()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ func init() {
|
|||||||
"name": "users",
|
"name": "users",
|
||||||
"type": "auth",
|
"type": "auth",
|
||||||
"system": false,
|
"system": false,
|
||||||
"schema": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "dlzhxcn2",
|
"id": "dlzhxcn2",
|
||||||
@@ -73,13 +73,11 @@ func init() {
|
|||||||
"required": false,
|
"required": false,
|
||||||
"presentable": false,
|
"presentable": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"options": {
|
"maxSelect": 1,
|
||||||
"maxSelect": 1,
|
"values": [
|
||||||
"values": [
|
"metric",
|
||||||
"metric",
|
"imperial"
|
||||||
"imperial"
|
]
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"system": false,
|
"system": false,
|
||||||
@@ -89,13 +87,11 @@ func init() {
|
|||||||
"required": false,
|
"required": false,
|
||||||
"presentable": false,
|
"presentable": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"options": {
|
"maxSelect": 1,
|
||||||
"maxSelect": 1,
|
"values": [
|
||||||
"values": [
|
"en",
|
||||||
"en",
|
"de"
|
||||||
"de"
|
]
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"system": false,
|
"system": false,
|
||||||
@@ -105,9 +101,7 @@ func init() {
|
|||||||
"required": false,
|
"required": false,
|
||||||
"presentable": false,
|
"presentable": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"options": {
|
"maxSize": 2000000
|
||||||
"maxSize": 2000000
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"indexes": [],
|
"indexes": [],
|
||||||
@@ -135,7 +129,7 @@ func init() {
|
|||||||
"name": "trails",
|
"name": "trails",
|
||||||
"type": "base",
|
"type": "base",
|
||||||
"system": false,
|
"system": false,
|
||||||
"schema": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "wquvuytd",
|
"id": "wquvuytd",
|
||||||
@@ -172,11 +166,9 @@ func init() {
|
|||||||
"required": false,
|
"required": false,
|
||||||
"presentable": false,
|
"presentable": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"options": {
|
"min": null,
|
||||||
"min": null,
|
"max": null,
|
||||||
"max": null,
|
"pattern": ""
|
||||||
"pattern": ""
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"system": false,
|
"system": false,
|
||||||
@@ -196,11 +188,9 @@ func init() {
|
|||||||
"required": false,
|
"required": false,
|
||||||
"presentable": false,
|
"presentable": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"options": {
|
"min": 0,
|
||||||
"min": 0,
|
"max": null,
|
||||||
"max": null,
|
"noDecimal": false
|
||||||
"noDecimal": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"system": false,
|
"system": false,
|
||||||
@@ -210,11 +200,9 @@ func init() {
|
|||||||
"required": false,
|
"required": false,
|
||||||
"presentable": false,
|
"presentable": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"options": {
|
"min": null,
|
||||||
"min": null,
|
"max": null,
|
||||||
"max": null,
|
"onlyInt": true
|
||||||
"noDecimal": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"system": false,
|
"system": false,
|
||||||
@@ -224,11 +212,9 @@ func init() {
|
|||||||
"required": false,
|
"required": false,
|
||||||
"presentable": false,
|
"presentable": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"options": {
|
"min": 0,
|
||||||
"min": 0,
|
"max": null,
|
||||||
"max": null,
|
"onlyInt": true
|
||||||
"noDecimal": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"system": false,
|
"system": false,
|
||||||
@@ -390,7 +376,7 @@ func init() {
|
|||||||
"name": "categories",
|
"name": "categories",
|
||||||
"type": "base",
|
"type": "base",
|
||||||
"system": false,
|
"system": false,
|
||||||
"schema": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "38tbd8u4",
|
"id": "38tbd8u4",
|
||||||
@@ -437,7 +423,7 @@ func init() {
|
|||||||
"name": "waypoints",
|
"name": "waypoints",
|
||||||
"type": "base",
|
"type": "base",
|
||||||
"system": false,
|
"system": false,
|
||||||
"schema": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "2yegzjtk",
|
"id": "2yegzjtk",
|
||||||
@@ -524,7 +510,7 @@ func init() {
|
|||||||
"name": "summit_logs",
|
"name": "summit_logs",
|
||||||
"type": "base",
|
"type": "base",
|
||||||
"system": false,
|
"system": false,
|
||||||
"schema": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "gxq1yeld",
|
"id": "gxq1yeld",
|
||||||
@@ -568,7 +554,7 @@ func init() {
|
|||||||
"name": "lists",
|
"name": "lists",
|
||||||
"type": "base",
|
"type": "base",
|
||||||
"system": false,
|
"system": false,
|
||||||
"schema": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "0goi1ipa",
|
"id": "0goi1ipa",
|
||||||
|
|||||||
@@ -3,23 +3,20 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// update
|
// update
|
||||||
edit_photo := &schema.SchemaField{}
|
edit_photo := &core.FileField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "tfhs3juh",
|
"id": "tfhs3juh",
|
||||||
@@ -42,19 +39,18 @@ func init() {
|
|||||||
"protected": false
|
"protected": false
|
||||||
}
|
}
|
||||||
}`), edit_photo)
|
}`), edit_photo)
|
||||||
collection.Schema.AddField(edit_photo)
|
collection.Fields.Add(edit_photo)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// update
|
// update
|
||||||
edit_photo := &schema.SchemaField{}
|
edit_photo := &core.FileField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "tfhs3juh",
|
"id": "tfhs3juh",
|
||||||
@@ -77,8 +73,8 @@ func init() {
|
|||||||
"protected": false
|
"protected": false
|
||||||
}
|
}
|
||||||
}`), edit_photo)
|
}`), edit_photo)
|
||||||
collection.Schema.AddField(edit_photo)
|
collection.Fields.Add(edit_photo)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,23 +3,20 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_author := &schema.SchemaField{}
|
new_author := &core.RelationField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "8qbxrsd8",
|
"id": "8qbxrsd8",
|
||||||
@@ -36,20 +33,19 @@ func init() {
|
|||||||
"displayFields": null
|
"displayFields": null
|
||||||
}
|
}
|
||||||
}`), new_author)
|
}`), new_author)
|
||||||
collection.Schema.AddField(new_author)
|
collection.Fields.Add(new_author)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("8qbxrsd8")
|
collection.Fields.RemoveById("8qbxrsd8")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,15 @@
|
|||||||
package migrations
|
package migrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -20,11 +18,10 @@ func init() {
|
|||||||
|
|
||||||
collection.DeleteRule = types.Pointer("@request.auth.id != \"\" && ((@collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id)) || @request.data.author = @request.auth.id)")
|
collection.DeleteRule = types.Pointer("@request.auth.id != \"\" && ((@collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id)) || @request.data.author = @request.auth.id)")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -33,6 +30,6 @@ func init() {
|
|||||||
|
|
||||||
collection.DeleteRule = types.Pointer("@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id)")
|
collection.DeleteRule = types.Pointer("@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id)")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,34 +1,31 @@
|
|||||||
package migrations
|
package migrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
collection.UpdateRule = types.Pointer("")
|
collection.UpdateRule = types.Pointer("")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
collection.UpdateRule = types.Pointer("@request.auth.id != \"\" && ((@collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id)) || @request.data.author = @request.auth.id)")
|
collection.UpdateRule = types.Pointer("@request.auth.id != \"\" && ((@collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id)) || @request.data.author = @request.auth.id)")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,15 @@
|
|||||||
package migrations
|
package migrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -20,11 +18,10 @@ func init() {
|
|||||||
|
|
||||||
collection.DeleteRule = types.Pointer("@request.auth.id != \"\" && ((@collection.trails.waypoints.id ?= id && @collection.trails.author = @request.auth.id) || @request.data.author = @request.auth.id)")
|
collection.DeleteRule = types.Pointer("@request.auth.id != \"\" && ((@collection.trails.waypoints.id ?= id && @collection.trails.author = @request.auth.id) || @request.data.author = @request.auth.id)")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -33,6 +30,6 @@ func init() {
|
|||||||
|
|
||||||
collection.DeleteRule = types.Pointer("@request.auth.id != \"\" && ((@collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id)) || @request.data.author = @request.auth.id)")
|
collection.DeleteRule = types.Pointer("@request.auth.id != \"\" && ((@collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id)) || @request.data.author = @request.auth.id)")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,15 @@
|
|||||||
package migrations
|
package migrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -20,11 +18,10 @@ func init() {
|
|||||||
|
|
||||||
collection.DeleteRule = types.Pointer("@request.auth.id != \"\" && ((@collection.trails.waypoints.id ?= id && @collection.trails.author = @request.auth.id) || @collection.waypoints.author = @request.auth.id)")
|
collection.DeleteRule = types.Pointer("@request.auth.id != \"\" && ((@collection.trails.waypoints.id ?= id && @collection.trails.author = @request.auth.id) || @collection.waypoints.author = @request.auth.id)")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -33,6 +30,6 @@ func init() {
|
|||||||
|
|
||||||
collection.DeleteRule = types.Pointer("@request.auth.id != \"\" && ((@collection.trails.waypoints.id ?= id && @collection.trails.author = @request.auth.id) || @request.data.author = @request.auth.id)")
|
collection.DeleteRule = types.Pointer("@request.auth.id != \"\" && ((@collection.trails.waypoints.id ?= id && @collection.trails.author = @request.auth.id) || @request.data.author = @request.auth.id)")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,15 @@
|
|||||||
package migrations
|
package migrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -20,11 +18,10 @@ func init() {
|
|||||||
|
|
||||||
collection.DeleteRule = types.Pointer("@request.auth.id != \"\" && ((@collection.trails.waypoints.id ?= id && @collection.trails.author = @request.auth.id) || author = @request.auth.id)")
|
collection.DeleteRule = types.Pointer("@request.auth.id != \"\" && ((@collection.trails.waypoints.id ?= id && @collection.trails.author = @request.auth.id) || author = @request.auth.id)")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -33,6 +30,6 @@ func init() {
|
|||||||
|
|
||||||
collection.DeleteRule = types.Pointer("@request.auth.id != \"\" && ((@collection.trails.waypoints.id ?= id && @collection.trails.author = @request.auth.id) || @collection.waypoints.author = @request.auth.id)")
|
collection.DeleteRule = types.Pointer("@request.auth.id != \"\" && ((@collection.trails.waypoints.id ?= id && @collection.trails.author = @request.auth.id) || @collection.waypoints.author = @request.auth.id)")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,23 +3,20 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// update
|
// update
|
||||||
edit_photos := &schema.SchemaField{}
|
edit_photos := &core.FileField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "tfhs3juh",
|
"id": "tfhs3juh",
|
||||||
@@ -42,19 +39,18 @@ func init() {
|
|||||||
"protected": false
|
"protected": false
|
||||||
}
|
}
|
||||||
}`), edit_photos)
|
}`), edit_photos)
|
||||||
collection.Schema.AddField(edit_photos)
|
collection.Fields.Add(edit_photos)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// update
|
// update
|
||||||
edit_photos := &schema.SchemaField{}
|
edit_photos := &core.FileField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "tfhs3juh",
|
"id": "tfhs3juh",
|
||||||
@@ -77,8 +73,8 @@ func init() {
|
|||||||
"protected": false
|
"protected": false
|
||||||
}
|
}
|
||||||
}`), edit_photos)
|
}`), edit_photos)
|
||||||
collection.Schema.AddField(edit_photos)
|
collection.Fields.Add(edit_photos)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,34 +1,31 @@
|
|||||||
package migrations
|
package migrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
collection.UpdateRule = types.Pointer("")
|
collection.UpdateRule = types.Pointer("")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
collection.UpdateRule = types.Pointer("@request.auth.id != \"\" && ((@collection.trails.waypoints.id ?= id && @collection.trails.author = @request.auth.id) || author = @request.auth.id)")
|
collection.UpdateRule = types.Pointer("@request.auth.id != \"\" && ((@collection.trails.waypoints.id ?= id && @collection.trails.author = @request.auth.id) || author = @request.auth.id)")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,34 +1,31 @@
|
|||||||
package migrations
|
package migrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
collection.UpdateRule = types.Pointer("@request.auth.id != \"\" && ((@collection.trails.waypoints.id ?= id && @collection.trails.author = @request.auth.id) || author = @request.auth.id)")
|
collection.UpdateRule = types.Pointer("@request.auth.id != \"\" && ((@collection.trails.waypoints.id ?= id && @collection.trails.author = @request.auth.id) || author = @request.auth.id)")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
collection.UpdateRule = types.Pointer("")
|
collection.UpdateRule = types.Pointer("")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,34 +1,31 @@
|
|||||||
package migrations
|
package migrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
collection.ViewRule = types.Pointer("@request.auth.id != \"\" && (@collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true) || author = @request.auth.id)")
|
collection.ViewRule = types.Pointer("@request.auth.id != \"\" && (@collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true) || author = @request.auth.id)")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
collection.ViewRule = types.Pointer("@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)")
|
collection.ViewRule = types.Pointer("@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,34 +1,31 @@
|
|||||||
package migrations
|
package migrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
collection.ListRule = types.Pointer("@request.auth.id != \"\" && (@collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true) || author = @request.auth.id)")
|
collection.ListRule = types.Pointer("@request.auth.id != \"\" && (@collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true) || author = @request.auth.id)")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
collection.ListRule = types.Pointer("@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)")
|
collection.ListRule = types.Pointer("@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,23 +3,20 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
|
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// update
|
// update
|
||||||
edit_language := &schema.SchemaField{}
|
edit_language := &core.SelectField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "t1wlsqyp",
|
"id": "t1wlsqyp",
|
||||||
@@ -39,19 +36,18 @@ func init() {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}`), edit_language)
|
}`), edit_language)
|
||||||
collection.Schema.AddField(edit_language)
|
collection.Fields.Add(edit_language)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
|
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// update
|
// update
|
||||||
edit_language := &schema.SchemaField{}
|
edit_language := &core.SelectField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "t1wlsqyp",
|
"id": "t1wlsqyp",
|
||||||
@@ -68,8 +64,8 @@ func init() {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}`), edit_language)
|
}`), edit_language)
|
||||||
collection.Schema.AddField(edit_language)
|
collection.Fields.Add(edit_language)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,23 +3,20 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
|
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// update
|
// update
|
||||||
edit_language := &schema.SchemaField{}
|
edit_language := &core.SelectField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "t1wlsqyp",
|
"id": "t1wlsqyp",
|
||||||
@@ -40,19 +37,18 @@ func init() {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}`), edit_language)
|
}`), edit_language)
|
||||||
collection.Schema.AddField(edit_language)
|
collection.Fields.Add(edit_language)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
|
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// update
|
// update
|
||||||
edit_language := &schema.SchemaField{}
|
edit_language := &core.SelectField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "t1wlsqyp",
|
"id": "t1wlsqyp",
|
||||||
@@ -72,8 +68,8 @@ func init() {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}`), edit_language)
|
}`), edit_language)
|
||||||
collection.Schema.AddField(edit_language)
|
collection.Fields.Add(edit_language)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,23 +3,20 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
|
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// update
|
// update
|
||||||
edit_language := &schema.SchemaField{}
|
edit_language := &core.SelectField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "t1wlsqyp",
|
"id": "t1wlsqyp",
|
||||||
@@ -41,19 +38,18 @@ func init() {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}`), edit_language)
|
}`), edit_language)
|
||||||
collection.Schema.AddField(edit_language)
|
collection.Fields.Add(edit_language)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
|
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// update
|
// update
|
||||||
edit_language := &schema.SchemaField{}
|
edit_language := &core.SelectField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "t1wlsqyp",
|
"id": "t1wlsqyp",
|
||||||
@@ -74,8 +70,8 @@ func init() {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}`), edit_language)
|
}`), edit_language)
|
||||||
collection.Schema.AddField(edit_language)
|
collection.Fields.Add(edit_language)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,12 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
jsonData := `{
|
jsonData := `{
|
||||||
"id": "4wbv9tz5zjdrjh1",
|
"id": "4wbv9tz5zjdrjh1",
|
||||||
"created": "2024-04-01 17:47:10.015Z",
|
"created": "2024-04-01 17:47:10.015Z",
|
||||||
@@ -43,20 +41,19 @@ func init() {
|
|||||||
}
|
}
|
||||||
}`
|
}`
|
||||||
|
|
||||||
collection := &models.Collection{}
|
collection := &core.Collection{}
|
||||||
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return daos.New(db).SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return dao.DeleteCollection(collection)
|
return app.Delete(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,32 +3,25 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
options := map[string]any{}
|
collection.ViewQuery = "SELECT (ROW_NUMBER() OVER()) as id, MAX(trails.distance) AS max_distance, MAX(trails.elevation_gain) AS max_elevation_gain, MAX(trails.duration) AS max_duration, MIN(trails.distance) AS min_distance, MIN(trails.elevation_gain) AS min_elevation_gain, MIN(trails.duration) AS min_duration FROM trails;"
|
||||||
json.Unmarshal([]byte(`{
|
|
||||||
"query": "SELECT (ROW_NUMBER() OVER()) as id, MAX(trails.distance) AS max_distance, MAX(trails.elevation_gain) AS max_elevation_gain, MAX(trails.duration) AS max_duration, MIN(trails.distance) AS min_distance, MIN(trails.elevation_gain) AS min_elevation_gain, MIN(trails.duration) AS min_duration FROM trails;"
|
|
||||||
}`), &options)
|
|
||||||
collection.SetOptions(options)
|
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("ovledory")
|
collection.Fields.RemoveById("ovledory")
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_max_distance := &schema.SchemaField{}
|
new_max_distance := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "3neuurse",
|
"id": "3neuurse",
|
||||||
@@ -41,10 +34,10 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), new_max_distance)
|
}`), new_max_distance)
|
||||||
collection.Schema.AddField(new_max_distance)
|
collection.Fields.Add(new_max_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_max_elevation_gain := &schema.SchemaField{}
|
new_max_elevation_gain := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "oynpksx3",
|
"id": "oynpksx3",
|
||||||
@@ -57,10 +50,10 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), new_max_elevation_gain)
|
}`), new_max_elevation_gain)
|
||||||
collection.Schema.AddField(new_max_elevation_gain)
|
collection.Fields.Add(new_max_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_max_duration := &schema.SchemaField{}
|
new_max_duration := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "tkoppkjw",
|
"id": "tkoppkjw",
|
||||||
@@ -73,10 +66,10 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), new_max_duration)
|
}`), new_max_duration)
|
||||||
collection.Schema.AddField(new_max_duration)
|
collection.Fields.Add(new_max_duration)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_min_distance := &schema.SchemaField{}
|
new_min_distance := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "uxc0eimu",
|
"id": "uxc0eimu",
|
||||||
@@ -89,10 +82,10 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), new_min_distance)
|
}`), new_min_distance)
|
||||||
collection.Schema.AddField(new_min_distance)
|
collection.Fields.Add(new_min_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_min_elevation_gain := &schema.SchemaField{}
|
new_min_elevation_gain := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "qcktbht6",
|
"id": "qcktbht6",
|
||||||
@@ -105,10 +98,10 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), new_min_elevation_gain)
|
}`), new_min_elevation_gain)
|
||||||
collection.Schema.AddField(new_min_elevation_gain)
|
collection.Fields.Add(new_min_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_min_duration := &schema.SchemaField{}
|
new_min_duration := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "qpkhyujt",
|
"id": "qpkhyujt",
|
||||||
@@ -121,25 +114,20 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), new_min_duration)
|
}`), new_min_duration)
|
||||||
collection.Schema.AddField(new_min_duration)
|
collection.Fields.Add(new_min_duration)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
options := map[string]any{}
|
collection.ViewQuery = "SELECT (ROW_NUMBER() OVER()) as id, MAX(trails.distance) AS max_distance FROM trails;"
|
||||||
json.Unmarshal([]byte(`{
|
|
||||||
"query": "SELECT (ROW_NUMBER() OVER()) as id, MAX(trails.distance) AS max_distance FROM trails;"
|
|
||||||
}`), &options)
|
|
||||||
collection.SetOptions(options)
|
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_max_distance := &schema.SchemaField{}
|
del_max_distance := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "ovledory",
|
"id": "ovledory",
|
||||||
@@ -152,26 +140,26 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), del_max_distance)
|
}`), del_max_distance)
|
||||||
collection.Schema.AddField(del_max_distance)
|
collection.Fields.Add(del_max_distance)
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("3neuurse")
|
collection.Fields.RemoveById("3neuurse")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("oynpksx3")
|
collection.Fields.RemoveById("oynpksx3")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("tkoppkjw")
|
collection.Fields.RemoveById("tkoppkjw")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("uxc0eimu")
|
collection.Fields.RemoveById("uxc0eimu")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("qcktbht6")
|
collection.Fields.RemoveById("qcktbht6")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("qpkhyujt")
|
collection.Fields.RemoveById("qpkhyujt")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,18 +3,15 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -22,25 +19,25 @@ func init() {
|
|||||||
collection.ListRule = types.Pointer("@request.auth.id != \"\"")
|
collection.ListRule = types.Pointer("@request.auth.id != \"\"")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("3neuurse")
|
collection.Fields.RemoveById("3neuurse")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("oynpksx3")
|
collection.Fields.RemoveById("oynpksx3")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("tkoppkjw")
|
collection.Fields.RemoveById("tkoppkjw")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("uxc0eimu")
|
collection.Fields.RemoveById("uxc0eimu")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("qcktbht6")
|
collection.Fields.RemoveById("qcktbht6")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("qpkhyujt")
|
collection.Fields.RemoveById("qpkhyujt")
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_max_distance := &schema.SchemaField{}
|
new_max_distance := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "54a1hvuq",
|
"id": "54a1hvuq",
|
||||||
@@ -53,10 +50,10 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), new_max_distance)
|
}`), new_max_distance)
|
||||||
collection.Schema.AddField(new_max_distance)
|
collection.Fields.Add(new_max_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_max_elevation_gain := &schema.SchemaField{}
|
new_max_elevation_gain := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "stcnunkf",
|
"id": "stcnunkf",
|
||||||
@@ -69,10 +66,10 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), new_max_elevation_gain)
|
}`), new_max_elevation_gain)
|
||||||
collection.Schema.AddField(new_max_elevation_gain)
|
collection.Fields.Add(new_max_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_max_duration := &schema.SchemaField{}
|
new_max_duration := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "bholagx7",
|
"id": "bholagx7",
|
||||||
@@ -85,10 +82,10 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), new_max_duration)
|
}`), new_max_duration)
|
||||||
collection.Schema.AddField(new_max_duration)
|
collection.Fields.Add(new_max_duration)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_min_distance := &schema.SchemaField{}
|
new_min_distance := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "qjrtggwi",
|
"id": "qjrtggwi",
|
||||||
@@ -101,10 +98,10 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), new_min_distance)
|
}`), new_min_distance)
|
||||||
collection.Schema.AddField(new_min_distance)
|
collection.Fields.Add(new_min_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_min_elevation_gain := &schema.SchemaField{}
|
new_min_elevation_gain := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "wtlhqwd2",
|
"id": "wtlhqwd2",
|
||||||
@@ -117,10 +114,10 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), new_min_elevation_gain)
|
}`), new_min_elevation_gain)
|
||||||
collection.Schema.AddField(new_min_elevation_gain)
|
collection.Fields.Add(new_min_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_min_duration := &schema.SchemaField{}
|
new_min_duration := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "sputfuyq",
|
"id": "sputfuyq",
|
||||||
@@ -133,13 +130,12 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), new_min_duration)
|
}`), new_min_duration)
|
||||||
collection.Schema.AddField(new_min_duration)
|
collection.Fields.Add(new_min_duration)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -147,7 +143,7 @@ func init() {
|
|||||||
collection.ListRule = nil
|
collection.ListRule = nil
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_max_distance := &schema.SchemaField{}
|
del_max_distance := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "3neuurse",
|
"id": "3neuurse",
|
||||||
@@ -160,10 +156,10 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), del_max_distance)
|
}`), del_max_distance)
|
||||||
collection.Schema.AddField(del_max_distance)
|
collection.Fields.Add(del_max_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_max_elevation_gain := &schema.SchemaField{}
|
del_max_elevation_gain := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "oynpksx3",
|
"id": "oynpksx3",
|
||||||
@@ -176,10 +172,10 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), del_max_elevation_gain)
|
}`), del_max_elevation_gain)
|
||||||
collection.Schema.AddField(del_max_elevation_gain)
|
collection.Fields.Add(del_max_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_max_duration := &schema.SchemaField{}
|
del_max_duration := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "tkoppkjw",
|
"id": "tkoppkjw",
|
||||||
@@ -192,10 +188,10 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), del_max_duration)
|
}`), del_max_duration)
|
||||||
collection.Schema.AddField(del_max_duration)
|
collection.Fields.Add(del_max_duration)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_min_distance := &schema.SchemaField{}
|
del_min_distance := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "uxc0eimu",
|
"id": "uxc0eimu",
|
||||||
@@ -208,10 +204,10 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), del_min_distance)
|
}`), del_min_distance)
|
||||||
collection.Schema.AddField(del_min_distance)
|
collection.Fields.Add(del_min_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_min_elevation_gain := &schema.SchemaField{}
|
del_min_elevation_gain := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "qcktbht6",
|
"id": "qcktbht6",
|
||||||
@@ -224,10 +220,10 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), del_min_elevation_gain)
|
}`), del_min_elevation_gain)
|
||||||
collection.Schema.AddField(del_min_elevation_gain)
|
collection.Fields.Add(del_min_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_min_duration := &schema.SchemaField{}
|
del_min_duration := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "qpkhyujt",
|
"id": "qpkhyujt",
|
||||||
@@ -240,26 +236,26 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), del_min_duration)
|
}`), del_min_duration)
|
||||||
collection.Schema.AddField(del_min_duration)
|
collection.Fields.Add(del_min_duration)
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("54a1hvuq")
|
collection.Fields.RemoveById("54a1hvuq")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("stcnunkf")
|
collection.Fields.RemoveById("stcnunkf")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("bholagx7")
|
collection.Fields.RemoveById("bholagx7")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("qjrtggwi")
|
collection.Fields.RemoveById("qjrtggwi")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("wtlhqwd2")
|
collection.Fields.RemoveById("wtlhqwd2")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("sputfuyq")
|
collection.Fields.RemoveById("sputfuyq")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,47 +3,40 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
options := map[string]any{}
|
collection.ViewQuery = "SELECT users.id, MAX(trails.distance) AS max_distance, MAX(trails.elevation_gain) AS max_elevation_gain, MAX(trails.duration) AS max_duration, MIN(trails.distance) AS min_distance, MIN(trails.elevation_gain) AS min_elevation_gain, MIN(trails.duration) AS min_duration FROM users JOIN trails ON users.id = trails.author GROUP BY users.id;"
|
||||||
json.Unmarshal([]byte(`{
|
|
||||||
"query": "SELECT users.id, MAX(trails.distance) AS max_distance, MAX(trails.elevation_gain) AS max_elevation_gain, MAX(trails.duration) AS max_duration, MIN(trails.distance) AS min_distance, MIN(trails.elevation_gain) AS min_elevation_gain, MIN(trails.duration) AS min_duration FROM users JOIN trails ON users.id = trails.author GROUP BY users.id;"
|
|
||||||
}`), &options)
|
|
||||||
collection.SetOptions(options)
|
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("54a1hvuq")
|
collection.Fields.RemoveById("54a1hvuq")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("stcnunkf")
|
collection.Fields.RemoveById("stcnunkf")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("bholagx7")
|
collection.Fields.RemoveById("bholagx7")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("qjrtggwi")
|
collection.Fields.RemoveById("qjrtggwi")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("wtlhqwd2")
|
collection.Fields.RemoveById("wtlhqwd2")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("sputfuyq")
|
collection.Fields.RemoveById("sputfuyq")
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_max_distance := &schema.SchemaField{}
|
new_max_distance := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "5udo4avx",
|
"id": "5udo4avx",
|
||||||
@@ -56,10 +49,10 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), new_max_distance)
|
}`), new_max_distance)
|
||||||
collection.Schema.AddField(new_max_distance)
|
collection.Fields.Add(new_max_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_max_elevation_gain := &schema.SchemaField{}
|
new_max_elevation_gain := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "omuxiatj",
|
"id": "omuxiatj",
|
||||||
@@ -72,10 +65,10 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), new_max_elevation_gain)
|
}`), new_max_elevation_gain)
|
||||||
collection.Schema.AddField(new_max_elevation_gain)
|
collection.Fields.Add(new_max_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_max_duration := &schema.SchemaField{}
|
new_max_duration := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "yq4snqnf",
|
"id": "yq4snqnf",
|
||||||
@@ -88,10 +81,10 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), new_max_duration)
|
}`), new_max_duration)
|
||||||
collection.Schema.AddField(new_max_duration)
|
collection.Fields.Add(new_max_duration)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_min_distance := &schema.SchemaField{}
|
new_min_distance := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "q8d41loj",
|
"id": "q8d41loj",
|
||||||
@@ -104,10 +97,10 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), new_min_distance)
|
}`), new_min_distance)
|
||||||
collection.Schema.AddField(new_min_distance)
|
collection.Fields.Add(new_min_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_min_elevation_gain := &schema.SchemaField{}
|
new_min_elevation_gain := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "xsetw0o6",
|
"id": "xsetw0o6",
|
||||||
@@ -120,10 +113,10 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), new_min_elevation_gain)
|
}`), new_min_elevation_gain)
|
||||||
collection.Schema.AddField(new_min_elevation_gain)
|
collection.Fields.Add(new_min_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_min_duration := &schema.SchemaField{}
|
new_min_duration := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "n4pq80mu",
|
"id": "n4pq80mu",
|
||||||
@@ -136,25 +129,20 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), new_min_duration)
|
}`), new_min_duration)
|
||||||
collection.Schema.AddField(new_min_duration)
|
collection.Fields.Add(new_min_duration)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
options := map[string]any{}
|
collection.ViewQuery = "SELECT (ROW_NUMBER() OVER()) as id, MAX(trails.distance) AS max_distance, MAX(trails.elevation_gain) AS max_elevation_gain, MAX(trails.duration) AS max_duration, MIN(trails.distance) AS min_distance, MIN(trails.elevation_gain) AS min_elevation_gain, MIN(trails.duration) AS min_duration FROM trails;"
|
||||||
json.Unmarshal([]byte(`{
|
|
||||||
"query": "SELECT (ROW_NUMBER() OVER()) as id, MAX(trails.distance) AS max_distance, MAX(trails.elevation_gain) AS max_elevation_gain, MAX(trails.duration) AS max_duration, MIN(trails.distance) AS min_distance, MIN(trails.elevation_gain) AS min_elevation_gain, MIN(trails.duration) AS min_duration FROM trails;"
|
|
||||||
}`), &options)
|
|
||||||
collection.SetOptions(options)
|
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_max_distance := &schema.SchemaField{}
|
del_max_distance := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "54a1hvuq",
|
"id": "54a1hvuq",
|
||||||
@@ -167,10 +155,10 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), del_max_distance)
|
}`), del_max_distance)
|
||||||
collection.Schema.AddField(del_max_distance)
|
collection.Fields.Add(del_max_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_max_elevation_gain := &schema.SchemaField{}
|
del_max_elevation_gain := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "stcnunkf",
|
"id": "stcnunkf",
|
||||||
@@ -183,10 +171,10 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), del_max_elevation_gain)
|
}`), del_max_elevation_gain)
|
||||||
collection.Schema.AddField(del_max_elevation_gain)
|
collection.Fields.Add(del_max_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_max_duration := &schema.SchemaField{}
|
del_max_duration := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "bholagx7",
|
"id": "bholagx7",
|
||||||
@@ -199,10 +187,10 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), del_max_duration)
|
}`), del_max_duration)
|
||||||
collection.Schema.AddField(del_max_duration)
|
collection.Fields.Add(del_max_duration)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_min_distance := &schema.SchemaField{}
|
del_min_distance := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "qjrtggwi",
|
"id": "qjrtggwi",
|
||||||
@@ -215,10 +203,10 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), del_min_distance)
|
}`), del_min_distance)
|
||||||
collection.Schema.AddField(del_min_distance)
|
collection.Fields.Add(del_min_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_min_elevation_gain := &schema.SchemaField{}
|
del_min_elevation_gain := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "wtlhqwd2",
|
"id": "wtlhqwd2",
|
||||||
@@ -231,10 +219,10 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), del_min_elevation_gain)
|
}`), del_min_elevation_gain)
|
||||||
collection.Schema.AddField(del_min_elevation_gain)
|
collection.Fields.Add(del_min_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_min_duration := &schema.SchemaField{}
|
del_min_duration := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "sputfuyq",
|
"id": "sputfuyq",
|
||||||
@@ -247,26 +235,26 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), del_min_duration)
|
}`), del_min_duration)
|
||||||
collection.Schema.AddField(del_min_duration)
|
collection.Fields.Add(del_min_duration)
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("5udo4avx")
|
collection.Fields.RemoveById("5udo4avx")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("omuxiatj")
|
collection.Fields.RemoveById("omuxiatj")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("yq4snqnf")
|
collection.Fields.RemoveById("yq4snqnf")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("q8d41loj")
|
collection.Fields.RemoveById("q8d41loj")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("xsetw0o6")
|
collection.Fields.RemoveById("xsetw0o6")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("n4pq80mu")
|
collection.Fields.RemoveById("n4pq80mu")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,18 +3,15 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -24,25 +21,25 @@ func init() {
|
|||||||
collection.ViewRule = types.Pointer("@request.auth.id = id")
|
collection.ViewRule = types.Pointer("@request.auth.id = id")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("5udo4avx")
|
collection.Fields.RemoveById("5udo4avx")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("omuxiatj")
|
collection.Fields.RemoveById("omuxiatj")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("yq4snqnf")
|
collection.Fields.RemoveById("yq4snqnf")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("q8d41loj")
|
collection.Fields.RemoveById("q8d41loj")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("xsetw0o6")
|
collection.Fields.RemoveById("xsetw0o6")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("n4pq80mu")
|
collection.Fields.RemoveById("n4pq80mu")
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_max_distance := &schema.SchemaField{}
|
new_max_distance := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "nqiuah7b",
|
"id": "nqiuah7b",
|
||||||
@@ -55,10 +52,10 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), new_max_distance)
|
}`), new_max_distance)
|
||||||
collection.Schema.AddField(new_max_distance)
|
collection.Fields.Add(new_max_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_max_elevation_gain := &schema.SchemaField{}
|
new_max_elevation_gain := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "rpzvilry",
|
"id": "rpzvilry",
|
||||||
@@ -71,10 +68,10 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), new_max_elevation_gain)
|
}`), new_max_elevation_gain)
|
||||||
collection.Schema.AddField(new_max_elevation_gain)
|
collection.Fields.Add(new_max_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_max_duration := &schema.SchemaField{}
|
new_max_duration := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "pfppgcfx",
|
"id": "pfppgcfx",
|
||||||
@@ -87,10 +84,10 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), new_max_duration)
|
}`), new_max_duration)
|
||||||
collection.Schema.AddField(new_max_duration)
|
collection.Fields.Add(new_max_duration)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_min_distance := &schema.SchemaField{}
|
new_min_distance := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "jrqp7c8d",
|
"id": "jrqp7c8d",
|
||||||
@@ -103,10 +100,10 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), new_min_distance)
|
}`), new_min_distance)
|
||||||
collection.Schema.AddField(new_min_distance)
|
collection.Fields.Add(new_min_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_min_elevation_gain := &schema.SchemaField{}
|
new_min_elevation_gain := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "xjcpg4su",
|
"id": "xjcpg4su",
|
||||||
@@ -119,10 +116,10 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), new_min_elevation_gain)
|
}`), new_min_elevation_gain)
|
||||||
collection.Schema.AddField(new_min_elevation_gain)
|
collection.Fields.Add(new_min_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_min_duration := &schema.SchemaField{}
|
new_min_duration := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "cuj9awlq",
|
"id": "cuj9awlq",
|
||||||
@@ -135,13 +132,12 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), new_min_duration)
|
}`), new_min_duration)
|
||||||
collection.Schema.AddField(new_min_duration)
|
collection.Fields.Add(new_min_duration)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -151,7 +147,7 @@ func init() {
|
|||||||
collection.ViewRule = nil
|
collection.ViewRule = nil
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_max_distance := &schema.SchemaField{}
|
del_max_distance := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "5udo4avx",
|
"id": "5udo4avx",
|
||||||
@@ -164,10 +160,10 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), del_max_distance)
|
}`), del_max_distance)
|
||||||
collection.Schema.AddField(del_max_distance)
|
collection.Fields.Add(del_max_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_max_elevation_gain := &schema.SchemaField{}
|
del_max_elevation_gain := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "omuxiatj",
|
"id": "omuxiatj",
|
||||||
@@ -180,10 +176,10 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), del_max_elevation_gain)
|
}`), del_max_elevation_gain)
|
||||||
collection.Schema.AddField(del_max_elevation_gain)
|
collection.Fields.Add(del_max_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_max_duration := &schema.SchemaField{}
|
del_max_duration := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "yq4snqnf",
|
"id": "yq4snqnf",
|
||||||
@@ -196,10 +192,10 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), del_max_duration)
|
}`), del_max_duration)
|
||||||
collection.Schema.AddField(del_max_duration)
|
collection.Fields.Add(del_max_duration)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_min_distance := &schema.SchemaField{}
|
del_min_distance := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "q8d41loj",
|
"id": "q8d41loj",
|
||||||
@@ -212,10 +208,10 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), del_min_distance)
|
}`), del_min_distance)
|
||||||
collection.Schema.AddField(del_min_distance)
|
collection.Fields.Add(del_min_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_min_elevation_gain := &schema.SchemaField{}
|
del_min_elevation_gain := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "xsetw0o6",
|
"id": "xsetw0o6",
|
||||||
@@ -228,10 +224,10 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), del_min_elevation_gain)
|
}`), del_min_elevation_gain)
|
||||||
collection.Schema.AddField(del_min_elevation_gain)
|
collection.Fields.Add(del_min_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_min_duration := &schema.SchemaField{}
|
del_min_duration := &core.JSONField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "n4pq80mu",
|
"id": "n4pq80mu",
|
||||||
@@ -244,26 +240,26 @@ func init() {
|
|||||||
"maxSize": 1
|
"maxSize": 1
|
||||||
}
|
}
|
||||||
}`), del_min_duration)
|
}`), del_min_duration)
|
||||||
collection.Schema.AddField(del_min_duration)
|
collection.Fields.Add(del_min_duration)
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("nqiuah7b")
|
collection.Fields.RemoveById("nqiuah7b")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("rpzvilry")
|
collection.Fields.RemoveById("rpzvilry")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("pfppgcfx")
|
collection.Fields.RemoveById("pfppgcfx")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("jrqp7c8d")
|
collection.Fields.RemoveById("jrqp7c8d")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("xjcpg4su")
|
collection.Fields.RemoveById("xjcpg4su")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("cuj9awlq")
|
collection.Fields.RemoveById("cuj9awlq")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,23 +3,20 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
|
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// update
|
// update
|
||||||
edit_language := &schema.SchemaField{}
|
edit_language := &core.SelectField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "t1wlsqyp",
|
"id": "t1wlsqyp",
|
||||||
@@ -42,19 +39,18 @@ func init() {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}`), edit_language)
|
}`), edit_language)
|
||||||
collection.Schema.AddField(edit_language)
|
collection.Fields.Add(edit_language)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
|
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// update
|
// update
|
||||||
edit_language := &schema.SchemaField{}
|
edit_language := &core.SelectField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "t1wlsqyp",
|
"id": "t1wlsqyp",
|
||||||
@@ -76,8 +72,8 @@ func init() {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}`), edit_language)
|
}`), edit_language)
|
||||||
collection.Schema.AddField(edit_language)
|
collection.Fields.Add(edit_language)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,12 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
jsonData := `{
|
jsonData := `{
|
||||||
"id": "lf06qip3f4d11yk",
|
"id": "lf06qip3f4d11yk",
|
||||||
"created": "2024-04-03 18:44:47.201Z",
|
"created": "2024-04-03 18:44:47.201Z",
|
||||||
@@ -73,20 +71,19 @@ func init() {
|
|||||||
"options": {}
|
"options": {}
|
||||||
}`
|
}`
|
||||||
|
|
||||||
collection := &models.Collection{}
|
collection := &core.Collection{}
|
||||||
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return daos.New(db).SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("lf06qip3f4d11yk")
|
collection, err := app.FindCollectionByNameOrId("lf06qip3f4d11yk")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return dao.DeleteCollection(collection)
|
return app.Delete(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,23 +3,20 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
|
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_comments := &schema.SchemaField{}
|
new_comments := &core.RelationField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "phhhroww",
|
"id": "phhhroww",
|
||||||
@@ -36,20 +33,19 @@ func init() {
|
|||||||
"displayFields": null
|
"displayFields": null
|
||||||
}
|
}
|
||||||
}`), new_comments)
|
}`), new_comments)
|
||||||
collection.Schema.AddField(new_comments)
|
collection.Fields.Add(new_comments)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
|
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("phhhroww")
|
collection.Fields.RemoveById("phhhroww")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,23 +3,20 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("lf06qip3f4d11yk")
|
collection, err := app.FindCollectionByNameOrId("lf06qip3f4d11yk")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_trail := &schema.SchemaField{}
|
new_trail := &core.RelationField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "snrlpxar",
|
"id": "snrlpxar",
|
||||||
@@ -36,20 +33,19 @@ func init() {
|
|||||||
"displayFields": null
|
"displayFields": null
|
||||||
}
|
}
|
||||||
}`), new_trail)
|
}`), new_trail)
|
||||||
collection.Schema.AddField(new_trail)
|
collection.Fields.Add(new_trail)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("lf06qip3f4d11yk")
|
collection, err := app.FindCollectionByNameOrId("lf06qip3f4d11yk")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("snrlpxar")
|
collection.Fields.RemoveById("snrlpxar")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,35 +3,31 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
|
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("phhhroww")
|
collection.Fields.RemoveById("phhhroww")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
|
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_comments := &schema.SchemaField{}
|
del_comments := &core.RelationField{}
|
||||||
json.Unmarshal([]byte(`{
|
json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "phhhroww",
|
"id": "phhhroww",
|
||||||
@@ -48,8 +44,8 @@ func init() {
|
|||||||
"displayFields": null
|
"displayFields": null
|
||||||
}
|
}
|
||||||
}`), del_comments)
|
}`), del_comments)
|
||||||
collection.Schema.AddField(del_comments)
|
collection.Fields.Add(del_comments)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,49 +3,40 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
options := map[string]any{}
|
collection.ViewQuery = "SELECT users.id, COALESCE(MAX(trails.distance), 0) AS max_distance, MAX(trails.elevation_gain) AS max_elevation_gain, MAX(trails.duration) AS max_duration, MIN(trails.distance) AS min_distance, MIN(trails.elevation_gain) AS min_elevation_gain, MIN(trails.duration) AS min_duration FROM users JOIN trails ON users.id = trails.author GROUP BY users.id;"
|
||||||
if err := json.Unmarshal([]byte(`{
|
|
||||||
"query": "SELECT users.id, COALESCE(MAX(trails.distance), 0) AS max_distance, MAX(trails.elevation_gain) AS max_elevation_gain, MAX(trails.duration) AS max_duration, MIN(trails.distance) AS min_distance, MIN(trails.elevation_gain) AS min_elevation_gain, MIN(trails.duration) AS min_duration FROM users JOIN trails ON users.id = trails.author GROUP BY users.id;"
|
|
||||||
}`), &options); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
collection.SetOptions(options)
|
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("nqiuah7b")
|
collection.Fields.RemoveById("nqiuah7b")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("rpzvilry")
|
collection.Fields.RemoveById("rpzvilry")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("pfppgcfx")
|
collection.Fields.RemoveById("pfppgcfx")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("jrqp7c8d")
|
collection.Fields.RemoveById("jrqp7c8d")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("xjcpg4su")
|
collection.Fields.RemoveById("xjcpg4su")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("cuj9awlq")
|
collection.Fields.RemoveById("cuj9awlq")
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_max_distance := &schema.SchemaField{}
|
new_max_distance := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "265lcwyn",
|
"id": "265lcwyn",
|
||||||
@@ -60,10 +51,10 @@ func init() {
|
|||||||
}`), new_max_distance); err != nil {
|
}`), new_max_distance); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_max_distance)
|
collection.Fields.Add(new_max_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_max_elevation_gain := &schema.SchemaField{}
|
new_max_elevation_gain := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "8udbn3hb",
|
"id": "8udbn3hb",
|
||||||
@@ -78,10 +69,10 @@ func init() {
|
|||||||
}`), new_max_elevation_gain); err != nil {
|
}`), new_max_elevation_gain); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_max_elevation_gain)
|
collection.Fields.Add(new_max_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_max_duration := &schema.SchemaField{}
|
new_max_duration := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "0mw2f9gg",
|
"id": "0mw2f9gg",
|
||||||
@@ -96,10 +87,10 @@ func init() {
|
|||||||
}`), new_max_duration); err != nil {
|
}`), new_max_duration); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_max_duration)
|
collection.Fields.Add(new_max_duration)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_min_distance := &schema.SchemaField{}
|
new_min_distance := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "qumwuc7g",
|
"id": "qumwuc7g",
|
||||||
@@ -114,10 +105,10 @@ func init() {
|
|||||||
}`), new_min_distance); err != nil {
|
}`), new_min_distance); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_min_distance)
|
collection.Fields.Add(new_min_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_min_elevation_gain := &schema.SchemaField{}
|
new_min_elevation_gain := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "sins29kl",
|
"id": "sins29kl",
|
||||||
@@ -132,10 +123,10 @@ func init() {
|
|||||||
}`), new_min_elevation_gain); err != nil {
|
}`), new_min_elevation_gain); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_min_elevation_gain)
|
collection.Fields.Add(new_min_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_min_duration := &schema.SchemaField{}
|
new_min_duration := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "dgfnqloa",
|
"id": "dgfnqloa",
|
||||||
@@ -150,27 +141,20 @@ func init() {
|
|||||||
}`), new_min_duration); err != nil {
|
}`), new_min_duration); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_min_duration)
|
collection.Fields.Add(new_min_duration)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
options := map[string]any{}
|
collection.ViewQuery = "SELECT users.id, MAX(trails.distance) AS max_distance, MAX(trails.elevation_gain) AS max_elevation_gain, MAX(trails.duration) AS max_duration, MIN(trails.distance) AS min_distance, MIN(trails.elevation_gain) AS min_elevation_gain, MIN(trails.duration) AS min_duration FROM users JOIN trails ON users.id = trails.author GROUP BY users.id;"
|
||||||
if err := json.Unmarshal([]byte(`{
|
|
||||||
"query": "SELECT users.id, MAX(trails.distance) AS max_distance, MAX(trails.elevation_gain) AS max_elevation_gain, MAX(trails.duration) AS max_duration, MIN(trails.distance) AS min_distance, MIN(trails.elevation_gain) AS min_elevation_gain, MIN(trails.duration) AS min_duration FROM users JOIN trails ON users.id = trails.author GROUP BY users.id;"
|
|
||||||
}`), &options); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
collection.SetOptions(options)
|
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_max_distance := &schema.SchemaField{}
|
del_max_distance := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "nqiuah7b",
|
"id": "nqiuah7b",
|
||||||
@@ -185,10 +169,10 @@ func init() {
|
|||||||
}`), del_max_distance); err != nil {
|
}`), del_max_distance); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_max_distance)
|
collection.Fields.Add(del_max_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_max_elevation_gain := &schema.SchemaField{}
|
del_max_elevation_gain := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "rpzvilry",
|
"id": "rpzvilry",
|
||||||
@@ -203,10 +187,10 @@ func init() {
|
|||||||
}`), del_max_elevation_gain); err != nil {
|
}`), del_max_elevation_gain); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_max_elevation_gain)
|
collection.Fields.Add(del_max_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_max_duration := &schema.SchemaField{}
|
del_max_duration := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "pfppgcfx",
|
"id": "pfppgcfx",
|
||||||
@@ -221,10 +205,10 @@ func init() {
|
|||||||
}`), del_max_duration); err != nil {
|
}`), del_max_duration); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_max_duration)
|
collection.Fields.Add(del_max_duration)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_min_distance := &schema.SchemaField{}
|
del_min_distance := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "jrqp7c8d",
|
"id": "jrqp7c8d",
|
||||||
@@ -239,10 +223,10 @@ func init() {
|
|||||||
}`), del_min_distance); err != nil {
|
}`), del_min_distance); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_min_distance)
|
collection.Fields.Add(del_min_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_min_elevation_gain := &schema.SchemaField{}
|
del_min_elevation_gain := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "xjcpg4su",
|
"id": "xjcpg4su",
|
||||||
@@ -257,10 +241,10 @@ func init() {
|
|||||||
}`), del_min_elevation_gain); err != nil {
|
}`), del_min_elevation_gain); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_min_elevation_gain)
|
collection.Fields.Add(del_min_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_min_duration := &schema.SchemaField{}
|
del_min_duration := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "cuj9awlq",
|
"id": "cuj9awlq",
|
||||||
@@ -275,26 +259,26 @@ func init() {
|
|||||||
}`), del_min_duration); err != nil {
|
}`), del_min_duration); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_min_duration)
|
collection.Fields.Add(del_min_duration)
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("265lcwyn")
|
collection.Fields.RemoveById("265lcwyn")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("8udbn3hb")
|
collection.Fields.RemoveById("8udbn3hb")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("0mw2f9gg")
|
collection.Fields.RemoveById("0mw2f9gg")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("qumwuc7g")
|
collection.Fields.RemoveById("qumwuc7g")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("sins29kl")
|
collection.Fields.RemoveById("sins29kl")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("dgfnqloa")
|
collection.Fields.RemoveById("dgfnqloa")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,49 +3,40 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
options := map[string]any{}
|
collection.ViewQuery = "SELECT users.id, COALESCE(MAX(trails.distance), 0) AS max_distance, MAX(trails.elevation_gain) AS max_elevation_gain, MAX(trails.duration) AS max_duration, MIN(trails.distance) AS min_distance, MIN(trails.elevation_gain) AS min_elevation_gain, MIN(trails.duration) AS min_duration FROM users LEFT JOIN trails ON users.id = trails.author GROUP BY users.id;"
|
||||||
if err := json.Unmarshal([]byte(`{
|
|
||||||
"query": "SELECT users.id, COALESCE(MAX(trails.distance), 0) AS max_distance, MAX(trails.elevation_gain) AS max_elevation_gain, MAX(trails.duration) AS max_duration, MIN(trails.distance) AS min_distance, MIN(trails.elevation_gain) AS min_elevation_gain, MIN(trails.duration) AS min_duration FROM users LEFT JOIN trails ON users.id = trails.author GROUP BY users.id;"
|
|
||||||
}`), &options); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
collection.SetOptions(options)
|
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("265lcwyn")
|
collection.Fields.RemoveById("265lcwyn")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("8udbn3hb")
|
collection.Fields.RemoveById("8udbn3hb")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("0mw2f9gg")
|
collection.Fields.RemoveById("0mw2f9gg")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("qumwuc7g")
|
collection.Fields.RemoveById("qumwuc7g")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("sins29kl")
|
collection.Fields.RemoveById("sins29kl")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("dgfnqloa")
|
collection.Fields.RemoveById("dgfnqloa")
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_max_distance := &schema.SchemaField{}
|
new_max_distance := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "jahzab8l",
|
"id": "jahzab8l",
|
||||||
@@ -60,10 +51,10 @@ func init() {
|
|||||||
}`), new_max_distance); err != nil {
|
}`), new_max_distance); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_max_distance)
|
collection.Fields.Add(new_max_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_max_elevation_gain := &schema.SchemaField{}
|
new_max_elevation_gain := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "hz8wiojq",
|
"id": "hz8wiojq",
|
||||||
@@ -78,10 +69,10 @@ func init() {
|
|||||||
}`), new_max_elevation_gain); err != nil {
|
}`), new_max_elevation_gain); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_max_elevation_gain)
|
collection.Fields.Add(new_max_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_max_duration := &schema.SchemaField{}
|
new_max_duration := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "mhdukuxo",
|
"id": "mhdukuxo",
|
||||||
@@ -96,10 +87,10 @@ func init() {
|
|||||||
}`), new_max_duration); err != nil {
|
}`), new_max_duration); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_max_duration)
|
collection.Fields.Add(new_max_duration)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_min_distance := &schema.SchemaField{}
|
new_min_distance := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "yl7yh4fi",
|
"id": "yl7yh4fi",
|
||||||
@@ -114,10 +105,10 @@ func init() {
|
|||||||
}`), new_min_distance); err != nil {
|
}`), new_min_distance); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_min_distance)
|
collection.Fields.Add(new_min_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_min_elevation_gain := &schema.SchemaField{}
|
new_min_elevation_gain := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "mmdluwag",
|
"id": "mmdluwag",
|
||||||
@@ -132,10 +123,10 @@ func init() {
|
|||||||
}`), new_min_elevation_gain); err != nil {
|
}`), new_min_elevation_gain); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_min_elevation_gain)
|
collection.Fields.Add(new_min_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_min_duration := &schema.SchemaField{}
|
new_min_duration := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "rruyzzld",
|
"id": "rruyzzld",
|
||||||
@@ -150,13 +141,12 @@ func init() {
|
|||||||
}`), new_min_duration); err != nil {
|
}`), new_min_duration); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_min_duration)
|
collection.Fields.Add(new_min_duration)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -167,10 +157,10 @@ func init() {
|
|||||||
}`), &options); err != nil {
|
}`), &options); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.SetOptions(options)
|
collection.ViewQuery = "SELECT users.id, COALESCE(MAX(trails.distance), 0) AS max_distance, MAX(trails.elevation_gain) AS max_elevation_gain, MAX(trails.duration) AS max_duration, MIN(trails.distance) AS min_distance, MIN(trails.elevation_gain) AS min_elevation_gain, MIN(trails.duration) AS min_duration FROM users JOIN trails ON users.id = trails.author GROUP BY users.id;"
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_max_distance := &schema.SchemaField{}
|
del_max_distance := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "265lcwyn",
|
"id": "265lcwyn",
|
||||||
@@ -185,10 +175,10 @@ func init() {
|
|||||||
}`), del_max_distance); err != nil {
|
}`), del_max_distance); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_max_distance)
|
collection.Fields.Add(del_max_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_max_elevation_gain := &schema.SchemaField{}
|
del_max_elevation_gain := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "8udbn3hb",
|
"id": "8udbn3hb",
|
||||||
@@ -203,10 +193,10 @@ func init() {
|
|||||||
}`), del_max_elevation_gain); err != nil {
|
}`), del_max_elevation_gain); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_max_elevation_gain)
|
collection.Fields.Add(del_max_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_max_duration := &schema.SchemaField{}
|
del_max_duration := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "0mw2f9gg",
|
"id": "0mw2f9gg",
|
||||||
@@ -221,10 +211,10 @@ func init() {
|
|||||||
}`), del_max_duration); err != nil {
|
}`), del_max_duration); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_max_duration)
|
collection.Fields.Add(del_max_duration)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_min_distance := &schema.SchemaField{}
|
del_min_distance := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "qumwuc7g",
|
"id": "qumwuc7g",
|
||||||
@@ -239,10 +229,10 @@ func init() {
|
|||||||
}`), del_min_distance); err != nil {
|
}`), del_min_distance); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_min_distance)
|
collection.Fields.Add(del_min_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_min_elevation_gain := &schema.SchemaField{}
|
del_min_elevation_gain := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "sins29kl",
|
"id": "sins29kl",
|
||||||
@@ -257,10 +247,10 @@ func init() {
|
|||||||
}`), del_min_elevation_gain); err != nil {
|
}`), del_min_elevation_gain); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_min_elevation_gain)
|
collection.Fields.Add(del_min_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_min_duration := &schema.SchemaField{}
|
del_min_duration := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "dgfnqloa",
|
"id": "dgfnqloa",
|
||||||
@@ -275,26 +265,26 @@ func init() {
|
|||||||
}`), del_min_duration); err != nil {
|
}`), del_min_duration); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_min_duration)
|
collection.Fields.Add(del_min_duration)
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("jahzab8l")
|
collection.Fields.RemoveById("jahzab8l")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("hz8wiojq")
|
collection.Fields.RemoveById("hz8wiojq")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("mhdukuxo")
|
collection.Fields.RemoveById("mhdukuxo")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("yl7yh4fi")
|
collection.Fields.RemoveById("yl7yh4fi")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("mmdluwag")
|
collection.Fields.RemoveById("mmdluwag")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("rruyzzld")
|
collection.Fields.RemoveById("rruyzzld")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,49 +3,40 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
options := map[string]any{}
|
collection.ViewQuery = "SELECT users.id, COALESCE(MAX(trails.distance), 0) AS max_distance, COALESCE(MAX(trails.elevation_gain), 0) AS max_elevation_gain, COALESCE(MAX(trails.duration), 0) AS max_duration, COALESCE(MIN(trails.distance), 0) AS min_distance, COALESCE(MIN(trails.elevation_gain), 0) AS min_elevation_gain, COALESCE(MIN(trails.duration), 0) AS min_duration FROM users LEFT JOIN trails ON users.id = trails.author GROUP BY users.id;"
|
||||||
if err := json.Unmarshal([]byte(`{
|
|
||||||
"query": "SELECT users.id, COALESCE(MAX(trails.distance), 0) AS max_distance, COALESCE(MAX(trails.elevation_gain), 0) AS max_elevation_gain, COALESCE(MAX(trails.duration), 0) AS max_duration, COALESCE(MIN(trails.distance), 0) AS min_distance, COALESCE(MIN(trails.elevation_gain), 0) AS min_elevation_gain, COALESCE(MIN(trails.duration), 0) AS min_duration FROM users LEFT JOIN trails ON users.id = trails.author GROUP BY users.id;"
|
|
||||||
}`), &options); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
collection.SetOptions(options)
|
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("jahzab8l")
|
collection.Fields.RemoveById("jahzab8l")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("hz8wiojq")
|
collection.Fields.RemoveById("hz8wiojq")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("mhdukuxo")
|
collection.Fields.RemoveById("mhdukuxo")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("yl7yh4fi")
|
collection.Fields.RemoveById("yl7yh4fi")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("mmdluwag")
|
collection.Fields.RemoveById("mmdluwag")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("rruyzzld")
|
collection.Fields.RemoveById("rruyzzld")
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_max_distance := &schema.SchemaField{}
|
new_max_distance := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "n42yecz5",
|
"id": "n42yecz5",
|
||||||
@@ -60,10 +51,10 @@ func init() {
|
|||||||
}`), new_max_distance); err != nil {
|
}`), new_max_distance); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_max_distance)
|
collection.Fields.Add(new_max_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_max_elevation_gain := &schema.SchemaField{}
|
new_max_elevation_gain := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "de8wl3e5",
|
"id": "de8wl3e5",
|
||||||
@@ -78,10 +69,10 @@ func init() {
|
|||||||
}`), new_max_elevation_gain); err != nil {
|
}`), new_max_elevation_gain); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_max_elevation_gain)
|
collection.Fields.Add(new_max_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_max_duration := &schema.SchemaField{}
|
new_max_duration := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "lqhk4k6e",
|
"id": "lqhk4k6e",
|
||||||
@@ -96,10 +87,10 @@ func init() {
|
|||||||
}`), new_max_duration); err != nil {
|
}`), new_max_duration); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_max_duration)
|
collection.Fields.Add(new_max_duration)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_min_distance := &schema.SchemaField{}
|
new_min_distance := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "ug5lh6ku",
|
"id": "ug5lh6ku",
|
||||||
@@ -114,10 +105,10 @@ func init() {
|
|||||||
}`), new_min_distance); err != nil {
|
}`), new_min_distance); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_min_distance)
|
collection.Fields.Add(new_min_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_min_elevation_gain := &schema.SchemaField{}
|
new_min_elevation_gain := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "lkrr7zr4",
|
"id": "lkrr7zr4",
|
||||||
@@ -132,10 +123,10 @@ func init() {
|
|||||||
}`), new_min_elevation_gain); err != nil {
|
}`), new_min_elevation_gain); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_min_elevation_gain)
|
collection.Fields.Add(new_min_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_min_duration := &schema.SchemaField{}
|
new_min_duration := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "sxhh02md",
|
"id": "sxhh02md",
|
||||||
@@ -150,27 +141,25 @@ func init() {
|
|||||||
}`), new_min_duration); err != nil {
|
}`), new_min_duration); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_min_duration)
|
collection.Fields.Add(new_min_duration)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
options := map[string]any{}
|
options := map[string]any{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"query": "SELECT users.id, COALESCE(MAX(trails.distance), 0) AS max_distance, MAX(trails.elevation_gain) AS max_elevation_gain, MAX(trails.duration) AS max_duration, MIN(trails.distance) AS min_distance, MIN(trails.elevation_gain) AS min_elevation_gain, MIN(trails.duration) AS min_duration FROM users LEFT JOIN trails ON users.id = trails.author GROUP BY users.id;"
|
|
||||||
}`), &options); err != nil {
|
}`), &options); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.SetOptions(options)
|
collection.ViewQuery = "SELECT users.id, COALESCE(MAX(trails.distance), 0) AS max_distance, MAX(trails.elevation_gain) AS max_elevation_gain, MAX(trails.duration) AS max_duration, MIN(trails.distance) AS min_distance, MIN(trails.elevation_gain) AS min_elevation_gain, MIN(trails.duration) AS min_duration FROM users LEFT JOIN trails ON users.id = trails.author GROUP BY users.id;"
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_max_distance := &schema.SchemaField{}
|
del_max_distance := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "jahzab8l",
|
"id": "jahzab8l",
|
||||||
@@ -185,10 +174,10 @@ func init() {
|
|||||||
}`), del_max_distance); err != nil {
|
}`), del_max_distance); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_max_distance)
|
collection.Fields.Add(del_max_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_max_elevation_gain := &schema.SchemaField{}
|
del_max_elevation_gain := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "hz8wiojq",
|
"id": "hz8wiojq",
|
||||||
@@ -203,10 +192,10 @@ func init() {
|
|||||||
}`), del_max_elevation_gain); err != nil {
|
}`), del_max_elevation_gain); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_max_elevation_gain)
|
collection.Fields.Add(del_max_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_max_duration := &schema.SchemaField{}
|
del_max_duration := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "mhdukuxo",
|
"id": "mhdukuxo",
|
||||||
@@ -221,10 +210,10 @@ func init() {
|
|||||||
}`), del_max_duration); err != nil {
|
}`), del_max_duration); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_max_duration)
|
collection.Fields.Add(del_max_duration)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_min_distance := &schema.SchemaField{}
|
del_min_distance := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "yl7yh4fi",
|
"id": "yl7yh4fi",
|
||||||
@@ -239,10 +228,10 @@ func init() {
|
|||||||
}`), del_min_distance); err != nil {
|
}`), del_min_distance); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_min_distance)
|
collection.Fields.Add(del_min_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_min_elevation_gain := &schema.SchemaField{}
|
del_min_elevation_gain := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "mmdluwag",
|
"id": "mmdluwag",
|
||||||
@@ -257,10 +246,10 @@ func init() {
|
|||||||
}`), del_min_elevation_gain); err != nil {
|
}`), del_min_elevation_gain); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_min_elevation_gain)
|
collection.Fields.Add(del_min_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_min_duration := &schema.SchemaField{}
|
del_min_duration := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "rruyzzld",
|
"id": "rruyzzld",
|
||||||
@@ -275,26 +264,26 @@ func init() {
|
|||||||
}`), del_min_duration); err != nil {
|
}`), del_min_duration); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_min_duration)
|
collection.Fields.Add(del_min_duration)
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("n42yecz5")
|
collection.Fields.RemoveById("n42yecz5")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("de8wl3e5")
|
collection.Fields.RemoveById("de8wl3e5")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("lqhk4k6e")
|
collection.Fields.RemoveById("lqhk4k6e")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("ug5lh6ku")
|
collection.Fields.RemoveById("ug5lh6ku")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("lkrr7zr4")
|
collection.Fields.RemoveById("lkrr7zr4")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("sxhh02md")
|
collection.Fields.RemoveById("sxhh02md")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,34 +1,31 @@
|
|||||||
package migrations
|
package migrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
|
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
collection.ListRule = types.Pointer("@request.auth.id != \"\"")
|
collection.ListRule = types.Pointer("@request.auth.id != \"\"")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
|
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
collection.ListRule = types.Pointer("id = @request.auth.id")
|
collection.ListRule = types.Pointer("id = @request.auth.id")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,34 +1,31 @@
|
|||||||
package migrations
|
package migrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
|
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
collection.ViewRule = types.Pointer("@request.auth.id != \"\"")
|
collection.ViewRule = types.Pointer("@request.auth.id != \"\"")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
|
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
collection.ViewRule = types.Pointer("id = @request.auth.id")
|
collection.ViewRule = types.Pointer("id = @request.auth.id")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,23 +3,20 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
|
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_date := &schema.SchemaField{}
|
new_date := &core.DateField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "hovyvbtt",
|
"id": "hovyvbtt",
|
||||||
@@ -35,20 +32,19 @@ func init() {
|
|||||||
}`), new_date); err != nil {
|
}`), new_date); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_date)
|
collection.Fields.Add(new_date)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
|
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("hovyvbtt")
|
collection.Fields.RemoveById("hovyvbtt")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,15 @@
|
|||||||
package migrations
|
package migrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -20,11 +18,10 @@ func init() {
|
|||||||
|
|
||||||
collection.ViewRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && @collection.trails.author ?= @request.auth.id) || (@collection.trails.summit_logs.id ?= id && @collection.trails.public = true)")
|
collection.ViewRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && @collection.trails.author ?= @request.auth.id) || (@collection.trails.summit_logs.id ?= id && @collection.trails.public = true)")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -33,6 +30,6 @@ func init() {
|
|||||||
|
|
||||||
collection.ViewRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && @collection.trails.author ?= @request.auth.id) || @collection.trails.summit_logs.id ?= id && @collection.trails.public = true")
|
collection.ViewRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && @collection.trails.author ?= @request.auth.id) || @collection.trails.summit_logs.id ?= id && @collection.trails.public = true")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,15 @@
|
|||||||
package migrations
|
package migrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -20,11 +18,10 @@ func init() {
|
|||||||
|
|
||||||
collection.DeleteRule = types.Pointer("@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author ?= @request.auth.id)")
|
collection.DeleteRule = types.Pointer("@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author ?= @request.auth.id)")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -33,6 +30,6 @@ func init() {
|
|||||||
|
|
||||||
collection.DeleteRule = types.Pointer("@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author = @request.auth.id)")
|
collection.DeleteRule = types.Pointer("@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author = @request.auth.id)")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,12 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
jsonData := `{
|
jsonData := `{
|
||||||
"id": "uavt73rsqcn1n13",
|
"id": "uavt73rsqcn1n13",
|
||||||
"created": "2024-04-13 13:54:26.023Z",
|
"created": "2024-04-13 13:54:26.023Z",
|
||||||
@@ -111,20 +109,19 @@ func init() {
|
|||||||
"options": {}
|
"options": {}
|
||||||
}`
|
}`
|
||||||
|
|
||||||
collection := &models.Collection{}
|
collection := &core.Collection{}
|
||||||
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return daos.New(db).SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db)
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return dao.DeleteCollection(collection)
|
return app.Delete(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,48 +3,44 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models"
|
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db)
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
|
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("wjofulpg")
|
collection.Fields.RemoveById("wjofulpg")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("t1wlsqyp")
|
collection.Fields.RemoveById("t1wlsqyp")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("fhxhln9g")
|
collection.Fields.RemoveById("fhxhln9g")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("wosrk4ue")
|
collection.Fields.RemoveById("wosrk4ue")
|
||||||
|
|
||||||
query := dao.RecordQuery("_pb_users_auth_")
|
query := app.RecordQuery("_pb_users_auth_")
|
||||||
|
|
||||||
users := []*models.Record{}
|
users := []*core.Record{}
|
||||||
if err := query.All(&users); err != nil {
|
if err := query.All(&users); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
settingsCollection, err := dao.FindCollectionByNameOrId("settings")
|
settingsCollection, err := app.FindCollectionByNameOrId("settings")
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, user := range users {
|
for _, user := range users {
|
||||||
settings := models.NewRecord(settingsCollection)
|
settings := core.NewRecord(settingsCollection)
|
||||||
language := user.Get("language")
|
language := user.Get("language")
|
||||||
unit := user.Get("unit")
|
unit := user.Get("unit")
|
||||||
location := user.Get("location")
|
location := user.Get("location")
|
||||||
@@ -53,22 +49,21 @@ func init() {
|
|||||||
settings.Set("location", location)
|
settings.Set("location", location)
|
||||||
settings.Set("user", user.Id)
|
settings.Set("user", user.Id)
|
||||||
settings.Set("mapFocus", "location")
|
settings.Set("mapFocus", "location")
|
||||||
if err := dao.SaveRecord(settings); err != nil {
|
if err := app.Save(settings); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db)
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
|
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_unit := &schema.SchemaField{}
|
del_unit := &core.SelectField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "wjofulpg",
|
"id": "wjofulpg",
|
||||||
@@ -87,10 +82,10 @@ func init() {
|
|||||||
}`), del_unit); err != nil {
|
}`), del_unit); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_unit)
|
collection.Fields.Add(del_unit)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_language := &schema.SchemaField{}
|
del_language := &core.SelectField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "t1wlsqyp",
|
"id": "t1wlsqyp",
|
||||||
@@ -115,10 +110,10 @@ func init() {
|
|||||||
}`), del_language); err != nil {
|
}`), del_language); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_language)
|
collection.Fields.Add(del_language)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_mapView := &schema.SchemaField{}
|
del_mapView := &core.SelectField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "fhxhln9g",
|
"id": "fhxhln9g",
|
||||||
@@ -137,10 +132,10 @@ func init() {
|
|||||||
}`), del_mapView); err != nil {
|
}`), del_mapView); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_mapView)
|
collection.Fields.Add(del_mapView)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_location := &schema.SchemaField{}
|
del_location := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "wosrk4ue",
|
"id": "wosrk4ue",
|
||||||
@@ -155,8 +150,8 @@ func init() {
|
|||||||
}`), del_location); err != nil {
|
}`), del_location); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_location)
|
collection.Fields.Add(del_location)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,15 @@
|
|||||||
package migrations
|
package migrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -24,11 +22,10 @@ func init() {
|
|||||||
|
|
||||||
collection.UpdateRule = types.Pointer("user = @request.auth.id")
|
collection.UpdateRule = types.Pointer("user = @request.auth.id")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -41,6 +38,6 @@ func init() {
|
|||||||
|
|
||||||
collection.UpdateRule = nil
|
collection.UpdateRule = nil
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,12 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
jsonData := `{
|
jsonData := `{
|
||||||
"id": "urytyc428mwlbqq",
|
"id": "urytyc428mwlbqq",
|
||||||
"created": "2024-04-13 17:00:41.541Z",
|
"created": "2024-04-13 17:00:41.541Z",
|
||||||
@@ -79,20 +77,19 @@ func init() {
|
|||||||
}
|
}
|
||||||
}`
|
}`
|
||||||
|
|
||||||
collection := &models.Collection{}
|
collection := &core.Collection{}
|
||||||
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return daos.New(db).SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db)
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("urytyc428mwlbqq")
|
collection, err := app.FindCollectionByNameOrId("urytyc428mwlbqq")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return dao.DeleteCollection(collection)
|
return app.Delete(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,18 +3,15 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("urytyc428mwlbqq")
|
collection, err := app.FindCollectionByNameOrId("urytyc428mwlbqq")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -22,19 +19,19 @@ func init() {
|
|||||||
collection.ViewRule = types.Pointer("@request.auth.id = id")
|
collection.ViewRule = types.Pointer("@request.auth.id = id")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("iyhsoisl")
|
collection.Fields.RemoveById("iyhsoisl")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("kx2qfztr")
|
collection.Fields.RemoveById("kx2qfztr")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("z4qsnjeb")
|
collection.Fields.RemoveById("z4qsnjeb")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("p66xomdb")
|
collection.Fields.RemoveById("p66xomdb")
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_max_lat := &schema.SchemaField{}
|
new_max_lat := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "osfey1yx",
|
"id": "osfey1yx",
|
||||||
@@ -49,10 +46,10 @@ func init() {
|
|||||||
}`), new_max_lat); err != nil {
|
}`), new_max_lat); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_max_lat)
|
collection.Fields.Add(new_max_lat)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_max_lon := &schema.SchemaField{}
|
new_max_lon := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "eohslzky",
|
"id": "eohslzky",
|
||||||
@@ -67,10 +64,10 @@ func init() {
|
|||||||
}`), new_max_lon); err != nil {
|
}`), new_max_lon); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_max_lon)
|
collection.Fields.Add(new_max_lon)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_min_lat := &schema.SchemaField{}
|
new_min_lat := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "kigvankd",
|
"id": "kigvankd",
|
||||||
@@ -85,10 +82,10 @@ func init() {
|
|||||||
}`), new_min_lat); err != nil {
|
}`), new_min_lat); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_min_lat)
|
collection.Fields.Add(new_min_lat)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_min_lon := &schema.SchemaField{}
|
new_min_lon := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "ifnks9mg",
|
"id": "ifnks9mg",
|
||||||
@@ -103,13 +100,12 @@ func init() {
|
|||||||
}`), new_min_lon); err != nil {
|
}`), new_min_lon); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_min_lon)
|
collection.Fields.Add(new_min_lon)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("urytyc428mwlbqq")
|
collection, err := app.FindCollectionByNameOrId("urytyc428mwlbqq")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -117,7 +113,7 @@ func init() {
|
|||||||
collection.ViewRule = nil
|
collection.ViewRule = nil
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_max_lat := &schema.SchemaField{}
|
del_max_lat := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "iyhsoisl",
|
"id": "iyhsoisl",
|
||||||
@@ -132,10 +128,10 @@ func init() {
|
|||||||
}`), del_max_lat); err != nil {
|
}`), del_max_lat); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_max_lat)
|
collection.Fields.Add(del_max_lat)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_max_lon := &schema.SchemaField{}
|
del_max_lon := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "kx2qfztr",
|
"id": "kx2qfztr",
|
||||||
@@ -150,10 +146,10 @@ func init() {
|
|||||||
}`), del_max_lon); err != nil {
|
}`), del_max_lon); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_max_lon)
|
collection.Fields.Add(del_max_lon)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_min_lat := &schema.SchemaField{}
|
del_min_lat := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "z4qsnjeb",
|
"id": "z4qsnjeb",
|
||||||
@@ -168,10 +164,10 @@ func init() {
|
|||||||
}`), del_min_lat); err != nil {
|
}`), del_min_lat); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_min_lat)
|
collection.Fields.Add(del_min_lat)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_min_lon := &schema.SchemaField{}
|
del_min_lon := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "p66xomdb",
|
"id": "p66xomdb",
|
||||||
@@ -186,20 +182,20 @@ func init() {
|
|||||||
}`), del_min_lon); err != nil {
|
}`), del_min_lon); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_min_lon)
|
collection.Fields.Add(del_min_lon)
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("osfey1yx")
|
collection.Fields.RemoveById("osfey1yx")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("eohslzky")
|
collection.Fields.RemoveById("eohslzky")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("kigvankd")
|
collection.Fields.RemoveById("kigvankd")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("ifnks9mg")
|
collection.Fields.RemoveById("ifnks9mg")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,15 @@
|
|||||||
package migrations
|
package migrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("lf06qip3f4d11yk")
|
collection, err := app.FindCollectionByNameOrId("lf06qip3f4d11yk")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -26,11 +24,10 @@ func init() {
|
|||||||
|
|
||||||
collection.DeleteRule = types.Pointer("@request.auth.id = author")
|
collection.DeleteRule = types.Pointer("@request.auth.id = author")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("lf06qip3f4d11yk")
|
collection, err := app.FindCollectionByNameOrId("lf06qip3f4d11yk")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -45,6 +42,6 @@ func init() {
|
|||||||
|
|
||||||
collection.DeleteRule = types.Pointer("")
|
collection.DeleteRule = types.Pointer("")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,15 @@
|
|||||||
package migrations
|
package migrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -20,11 +18,10 @@ func init() {
|
|||||||
|
|
||||||
collection.ViewRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && @collection.trails.author ?= @request.auth.id) || (@collection.trails.waypoints.id ?= id && @collection.trails.public ?= true) || (author = @request.auth.id)")
|
collection.ViewRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && @collection.trails.author ?= @request.auth.id) || (@collection.trails.waypoints.id ?= id && @collection.trails.public ?= true) || (author = @request.auth.id)")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -33,6 +30,6 @@ func init() {
|
|||||||
|
|
||||||
collection.ViewRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && @collection.trails.author ?= @request.auth.id) || (@collection.trails.waypoints.id ?= id && @collection.trails.public ?= true) || author = @request.auth.id")
|
collection.ViewRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && @collection.trails.author ?= @request.auth.id) || (@collection.trails.waypoints.id ?= id && @collection.trails.public ?= true) || author = @request.auth.id")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,12 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
jsonData := `{
|
jsonData := `{
|
||||||
"id": "xku110v5a5xbufa",
|
"id": "xku110v5a5xbufa",
|
||||||
"created": "2024-05-09 17:39:57.419Z",
|
"created": "2024-05-09 17:39:57.419Z",
|
||||||
@@ -45,20 +43,19 @@ func init() {
|
|||||||
}
|
}
|
||||||
}`
|
}`
|
||||||
|
|
||||||
collection := &models.Collection{}
|
collection := &core.Collection{}
|
||||||
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return daos.New(db).SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("xku110v5a5xbufa")
|
collection, err := app.FindCollectionByNameOrId("xku110v5a5xbufa")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return dao.DeleteCollection(collection)
|
return app.Delete(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,18 +3,15 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db)
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("xku110v5a5xbufa")
|
collection, err := app.FindCollectionByNameOrId("xku110v5a5xbufa")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -24,10 +21,10 @@ func init() {
|
|||||||
collection.ViewRule = types.Pointer("@request.auth.id != \"\"")
|
collection.ViewRule = types.Pointer("@request.auth.id != \"\"")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("cknini6y")
|
collection.Fields.RemoveById("cknini6y")
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_username := &schema.SchemaField{}
|
new_username := &core.TextField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "qzkmy7nv",
|
"id": "qzkmy7nv",
|
||||||
@@ -44,13 +41,12 @@ func init() {
|
|||||||
}`), new_username); err != nil {
|
}`), new_username); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_username)
|
collection.Fields.Add(new_username)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db)
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("xku110v5a5xbufa")
|
collection, err := app.FindCollectionByNameOrId("xku110v5a5xbufa")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -60,7 +56,7 @@ func init() {
|
|||||||
collection.ViewRule = nil
|
collection.ViewRule = nil
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_username := &schema.SchemaField{}
|
del_username := &core.TextField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "cknini6y",
|
"id": "cknini6y",
|
||||||
@@ -77,11 +73,11 @@ func init() {
|
|||||||
}`), del_username); err != nil {
|
}`), del_username); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_username)
|
collection.Fields.Add(del_username)
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("qzkmy7nv")
|
collection.Fields.RemoveById("qzkmy7nv")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,12 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
jsonData := `{
|
jsonData := `{
|
||||||
"id": "1mns8mlal6uf9ku",
|
"id": "1mns8mlal6uf9ku",
|
||||||
"created": "2024-05-09 17:48:01.382Z",
|
"created": "2024-05-09 17:48:01.382Z",
|
||||||
@@ -77,20 +75,19 @@ func init() {
|
|||||||
"options": {}
|
"options": {}
|
||||||
}`
|
}`
|
||||||
|
|
||||||
collection := &models.Collection{}
|
collection := &core.Collection{}
|
||||||
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return daos.New(db).SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("1mns8mlal6uf9ku")
|
collection, err := app.FindCollectionByNameOrId("1mns8mlal6uf9ku")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return dao.DeleteCollection(collection)
|
return app.Delete(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,34 +3,25 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("xku110v5a5xbufa")
|
collection, err := app.FindCollectionByNameOrId("xku110v5a5xbufa")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
options := map[string]any{}
|
collection.ViewQuery = "SELECT id, username, avatar FROM users"
|
||||||
if err := json.Unmarshal([]byte(`{
|
|
||||||
"query": "SELECT id, username, avatar FROM users"
|
|
||||||
}`), &options); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
collection.SetOptions(options)
|
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("qzkmy7nv")
|
collection.Fields.RemoveById("qzkmy7nv")
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_username := &schema.SchemaField{}
|
new_username := &core.TextField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "mbokwbb3",
|
"id": "mbokwbb3",
|
||||||
@@ -47,10 +38,10 @@ func init() {
|
|||||||
}`), new_username); err != nil {
|
}`), new_username); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_username)
|
collection.Fields.Add(new_username)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_avatar := &schema.SchemaField{}
|
new_avatar := &core.FileField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "60wozbto",
|
"id": "60wozbto",
|
||||||
@@ -75,27 +66,20 @@ func init() {
|
|||||||
}`), new_avatar); err != nil {
|
}`), new_avatar); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_avatar)
|
collection.Fields.Add(new_avatar)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("xku110v5a5xbufa")
|
collection, err := app.FindCollectionByNameOrId("xku110v5a5xbufa")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
options := map[string]any{}
|
collection.ViewQuery = "SELECT id, username FROM users"
|
||||||
if err := json.Unmarshal([]byte(`{
|
|
||||||
"query": "SELECT id, username FROM users"
|
|
||||||
}`), &options); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
collection.SetOptions(options)
|
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_username := &schema.SchemaField{}
|
del_username := &core.TextField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "qzkmy7nv",
|
"id": "qzkmy7nv",
|
||||||
@@ -112,14 +96,14 @@ func init() {
|
|||||||
}`), del_username); err != nil {
|
}`), del_username); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_username)
|
collection.Fields.Add(del_username)
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("mbokwbb3")
|
collection.Fields.RemoveById("mbokwbb3")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("60wozbto")
|
collection.Fields.RemoveById("60wozbto")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,15 @@
|
|||||||
package migrations
|
package migrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
|
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -20,11 +18,10 @@ func init() {
|
|||||||
|
|
||||||
collection.ViewRule = types.Pointer("id = @request.auth.id")
|
collection.ViewRule = types.Pointer("id = @request.auth.id")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
|
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -33,6 +30,6 @@ func init() {
|
|||||||
|
|
||||||
collection.ViewRule = types.Pointer("@request.auth.id != \"\"")
|
collection.ViewRule = types.Pointer("@request.auth.id != \"\"")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,15 @@
|
|||||||
package migrations
|
package migrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
|
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -20,11 +18,10 @@ func init() {
|
|||||||
|
|
||||||
collection.ViewRule = types.Pointer("author = @request.auth.id || public = true || (trail_share_via_trail.trail = id && trail_share_via_trail.user = @request.auth.id)")
|
collection.ViewRule = types.Pointer("author = @request.auth.id || public = true || (trail_share_via_trail.trail = id && trail_share_via_trail.user = @request.auth.id)")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
|
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -33,6 +30,6 @@ func init() {
|
|||||||
|
|
||||||
collection.ViewRule = types.Pointer("author = @request.auth.id || public = true")
|
collection.ViewRule = types.Pointer("author = @request.auth.id || public = true")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,15 @@
|
|||||||
package migrations
|
package migrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
|
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -22,11 +20,10 @@ func init() {
|
|||||||
|
|
||||||
collection.UpdateRule = types.Pointer("author = @request.auth.id || (trail_share_via_trail.trail = id && trail_share_via_trail.user = @request.auth.id && trail_share_via_trail.permission = \"edit\")")
|
collection.UpdateRule = types.Pointer("author = @request.auth.id || (trail_share_via_trail.trail = id && trail_share_via_trail.user = @request.auth.id && trail_share_via_trail.permission = \"edit\")")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
|
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -37,6 +34,6 @@ func init() {
|
|||||||
|
|
||||||
collection.UpdateRule = types.Pointer("author = @request.auth.id ")
|
collection.UpdateRule = types.Pointer("author = @request.auth.id ")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,15 @@
|
|||||||
package migrations
|
package migrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("1mns8mlal6uf9ku")
|
collection, err := app.FindCollectionByNameOrId("1mns8mlal6uf9ku")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -20,11 +18,10 @@ func init() {
|
|||||||
|
|
||||||
collection.ViewRule = types.Pointer("trail.author = @request.auth.id || user = @request.auth.id")
|
collection.ViewRule = types.Pointer("trail.author = @request.auth.id || user = @request.auth.id")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("1mns8mlal6uf9ku")
|
collection, err := app.FindCollectionByNameOrId("1mns8mlal6uf9ku")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -33,6 +30,6 @@ func init() {
|
|||||||
|
|
||||||
collection.ViewRule = types.Pointer("trail.author = @request.auth.id")
|
collection.ViewRule = types.Pointer("trail.author = @request.auth.id")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,34 +1,31 @@
|
|||||||
package migrations
|
package migrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
|
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
collection.ViewRule = types.Pointer("author = @request.auth.id || public = true || (trail_share_via_trail.user ?= @request.auth.id)")
|
collection.ViewRule = types.Pointer("author = @request.auth.id || public = true || (trail_share_via_trail.user ?= @request.auth.id)")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
|
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
collection.ViewRule = types.Pointer("author = @request.auth.id || public = true || (trail_share_via_trail.user = @request.auth.id)")
|
collection.ViewRule = types.Pointer("author = @request.auth.id || public = true || (trail_share_via_trail.user = @request.auth.id)")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,34 +1,31 @@
|
|||||||
package migrations
|
package migrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
|
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
collection.ListRule = types.Pointer("author = @request.auth.id || public = true || (trail_share_via_trail.user ?= @request.auth.id)")
|
collection.ListRule = types.Pointer("author = @request.auth.id || public = true || (trail_share_via_trail.user ?= @request.auth.id)")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
|
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
collection.ListRule = types.Pointer("author = @request.auth.id || public = true || (trail_share_via_trail.user = @request.auth.id)")
|
collection.ListRule = types.Pointer("author = @request.auth.id || public = true || (trail_share_via_trail.user = @request.auth.id)")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,34 +1,31 @@
|
|||||||
package migrations
|
package migrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
|
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
collection.UpdateRule = types.Pointer("author = @request.auth.id || (trail_share_via_trail.trail = id && trail_share_via_trail.user ?= @request.auth.id && trail_share_via_trail.permission = \"edit\")")
|
collection.UpdateRule = types.Pointer("author = @request.auth.id || (trail_share_via_trail.trail = id && trail_share_via_trail.user ?= @request.auth.id && trail_share_via_trail.permission = \"edit\")")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
|
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
collection.UpdateRule = types.Pointer("author = @request.auth.id || (trail_share_via_trail.trail = id && trail_share_via_trail.user = @request.auth.id && trail_share_via_trail.permission = \"edit\")")
|
collection.UpdateRule = types.Pointer("author = @request.auth.id || (trail_share_via_trail.trail = id && trail_share_via_trail.user = @request.auth.id && trail_share_via_trail.permission = \"edit\")")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,16 +5,15 @@ import (
|
|||||||
"pocketbase/util"
|
"pocketbase/util"
|
||||||
|
|
||||||
"github.com/meilisearch/meilisearch-go"
|
"github.com/meilisearch/meilisearch-go"
|
||||||
"github.com/pocketbase/dbx"
|
|
||||||
|
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
client := meilisearch.New(os.Getenv("MEILI_URL"), meilisearch.WithAPIKey(os.Getenv("MEILI_MASTER_KEY")))
|
client := meilisearch.New(os.Getenv("MEILI_URL"), meilisearch.WithAPIKey(os.Getenv("MEILI_MASTER_KEY")))
|
||||||
|
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
_, err := client.Index("trails").UpdateFilterableAttributes(&[]string{
|
_, err := client.Index("trails").UpdateFilterableAttributes(&[]string{
|
||||||
"_geo", "author", "category", "completed", "date", "difficulty", "distance", "elevation_gain", "public", "shares",
|
"_geo", "author", "category", "completed", "date", "difficulty", "distance", "elevation_gain", "public", "shares",
|
||||||
})
|
})
|
||||||
@@ -23,18 +22,15 @@ func init() {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
dao := daos.New(db)
|
|
||||||
|
|
||||||
var usernames []string
|
var usernames []string
|
||||||
err = db.NewQuery("SELECT username FROM users").Column(&usernames)
|
err = app.DB().NewQuery("SELECT username FROM users").Column(&usernames)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, username := range usernames {
|
for _, username := range usernames {
|
||||||
|
record, err := app.FindFirstRecordByData("users", "username", username)
|
||||||
record, err := dao.FindAuthRecordByUsername("users", username)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -51,7 +47,7 @@ func init() {
|
|||||||
} else {
|
} else {
|
||||||
record.Set("token", token)
|
record.Set("token", token)
|
||||||
|
|
||||||
if err := dao.SaveRecord(record); err != nil {
|
if err := app.Save(record); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -59,7 +55,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
// add down queries...
|
// add down queries...
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -1,17 +1,15 @@
|
|||||||
package migrations
|
package migrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("lf06qip3f4d11yk")
|
collection, err := app.FindCollectionByNameOrId("lf06qip3f4d11yk")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -22,11 +20,10 @@ func init() {
|
|||||||
|
|
||||||
collection.CreateRule = types.Pointer("@request.auth.id != \"\" && (trail.author = @request.auth.id || trail.public = true || trail.trail_share_via_trail.user ?= @request.auth.id)")
|
collection.CreateRule = types.Pointer("@request.auth.id != \"\" && (trail.author = @request.auth.id || trail.public = true || trail.trail_share_via_trail.user ?= @request.auth.id)")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("lf06qip3f4d11yk")
|
collection, err := app.FindCollectionByNameOrId("lf06qip3f4d11yk")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -37,6 +34,6 @@ func init() {
|
|||||||
|
|
||||||
collection.CreateRule = types.Pointer("@request.auth.id != \"\" && (trail.author = @request.auth.id || trail.public = true)")
|
collection.CreateRule = types.Pointer("@request.auth.id != \"\" && (trail.author = @request.auth.id || trail.public = true)")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,15 @@
|
|||||||
package migrations
|
package migrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
|
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -22,11 +20,10 @@ func init() {
|
|||||||
|
|
||||||
collection.UpdateRule = types.Pointer("author = @request.auth.id || (@request.auth.id != \"\" && trail_share_via_trail.trail = id && trail_share_via_trail.user ?= @request.auth.id && trail_share_via_trail.permission = \"edit\")")
|
collection.UpdateRule = types.Pointer("author = @request.auth.id || (@request.auth.id != \"\" && trail_share_via_trail.trail = id && trail_share_via_trail.user ?= @request.auth.id && trail_share_via_trail.permission = \"edit\")")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
|
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -37,6 +34,6 @@ func init() {
|
|||||||
|
|
||||||
collection.UpdateRule = types.Pointer("author = @request.auth.id || (trail_share_via_trail.trail = id && trail_share_via_trail.user ?= @request.auth.id && trail_share_via_trail.permission = \"edit\")")
|
collection.UpdateRule = types.Pointer("author = @request.auth.id || (trail_share_via_trail.trail = id && trail_share_via_trail.user ?= @request.auth.id && trail_share_via_trail.permission = \"edit\")")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,15 +4,15 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/meilisearch/meilisearch-go"
|
"github.com/meilisearch/meilisearch-go"
|
||||||
"github.com/pocketbase/dbx"
|
|
||||||
|
|
||||||
|
"github.com/pocketbase/pocketbase/core"
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
client := meilisearch.New(os.Getenv("MEILI_URL"), meilisearch.WithAPIKey(os.Getenv("MEILI_MASTER_KEY")))
|
client := meilisearch.New(os.Getenv("MEILI_URL"), meilisearch.WithAPIKey(os.Getenv("MEILI_MASTER_KEY")))
|
||||||
|
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
_, err := client.Index("trails").UpdateSortableAttributes(&[]string{
|
_, err := client.Index("trails").UpdateSortableAttributes(&[]string{
|
||||||
"created", "date", "difficulty", "distance", "elevation_gain", "name",
|
"created", "date", "difficulty", "distance", "elevation_gain", "name",
|
||||||
})
|
})
|
||||||
@@ -22,7 +22,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
_, err := client.Index("trails").UpdateSortableAttributes(&[]string{
|
_, err := client.Index("trails").UpdateSortableAttributes(&[]string{
|
||||||
"created", "difficulty", "distance", "elevation_gain", "name",
|
"created", "difficulty", "distance", "elevation_gain", "name",
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -3,23 +3,20 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// update
|
// update
|
||||||
edit_language := &schema.SchemaField{}
|
edit_language := &core.SelectField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "0sepzvkh",
|
"id": "0sepzvkh",
|
||||||
@@ -45,19 +42,18 @@ func init() {
|
|||||||
}`), edit_language); err != nil {
|
}`), edit_language); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(edit_language)
|
collection.Fields.Add(edit_language)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// update
|
// update
|
||||||
edit_language := &schema.SchemaField{}
|
edit_language := &core.SelectField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "0sepzvkh",
|
"id": "0sepzvkh",
|
||||||
@@ -82,8 +78,8 @@ func init() {
|
|||||||
}`), edit_language); err != nil {
|
}`), edit_language); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(edit_language)
|
collection.Fields.Add(edit_language)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,23 +3,20 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_category := &schema.SchemaField{}
|
new_category := &core.RelationField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "owlyzl1x",
|
"id": "owlyzl1x",
|
||||||
@@ -38,20 +35,19 @@ func init() {
|
|||||||
}`), new_category); err != nil {
|
}`), new_category); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_category)
|
collection.Fields.Add(new_category)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("owlyzl1x")
|
collection.Fields.RemoveById("owlyzl1x")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,23 +3,20 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_tilesets := &schema.SchemaField{}
|
new_tilesets := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "xdbayoqg",
|
"id": "xdbayoqg",
|
||||||
@@ -34,20 +31,19 @@ func init() {
|
|||||||
}`), new_tilesets); err != nil {
|
}`), new_tilesets); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_tilesets)
|
collection.Fields.Add(new_tilesets)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("xdbayoqg")
|
collection.Fields.RemoveById("xdbayoqg")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,23 +3,20 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
|
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// update
|
// update
|
||||||
edit_photos := &schema.SchemaField{}
|
edit_photos := &core.FileField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "aqbpyawe",
|
"id": "aqbpyawe",
|
||||||
@@ -45,19 +42,18 @@ func init() {
|
|||||||
}`), edit_photos); err != nil {
|
}`), edit_photos); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(edit_photos)
|
collection.Fields.Add(edit_photos)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
|
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// update
|
// update
|
||||||
edit_photos := &schema.SchemaField{}
|
edit_photos := &core.FileField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "aqbpyawe",
|
"id": "aqbpyawe",
|
||||||
@@ -82,8 +78,8 @@ func init() {
|
|||||||
}`), edit_photos); err != nil {
|
}`), edit_photos); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(edit_photos)
|
collection.Fields.Add(edit_photos)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,12 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
jsonData := `{
|
jsonData := `{
|
||||||
"id": "1kot7t9na3hi0gl",
|
"id": "1kot7t9na3hi0gl",
|
||||||
"created": "2024-09-13 12:40:20.308Z",
|
"created": "2024-09-13 12:40:20.308Z",
|
||||||
@@ -77,20 +75,19 @@ func init() {
|
|||||||
"options": {}
|
"options": {}
|
||||||
}`
|
}`
|
||||||
|
|
||||||
collection := &models.Collection{}
|
collection := &core.Collection{}
|
||||||
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return daos.New(db).SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("1kot7t9na3hi0gl")
|
collection, err := app.FindCollectionByNameOrId("1kot7t9na3hi0gl")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return dao.DeleteCollection(collection)
|
return app.Delete(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,15 @@
|
|||||||
package migrations
|
package migrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("1kot7t9na3hi0gl")
|
collection, err := app.FindCollectionByNameOrId("1kot7t9na3hi0gl")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -26,11 +24,10 @@ func init() {
|
|||||||
|
|
||||||
collection.DeleteRule = types.Pointer("list.author = @request.auth.id")
|
collection.DeleteRule = types.Pointer("list.author = @request.auth.id")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("1kot7t9na3hi0gl")
|
collection, err := app.FindCollectionByNameOrId("1kot7t9na3hi0gl")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -45,6 +42,6 @@ func init() {
|
|||||||
|
|
||||||
collection.DeleteRule = nil
|
collection.DeleteRule = nil
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,15 @@
|
|||||||
package migrations
|
package migrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("r6gu2ajyidy1x69")
|
collection, err := app.FindCollectionByNameOrId("r6gu2ajyidy1x69")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -24,11 +22,10 @@ func init() {
|
|||||||
|
|
||||||
collection.UpdateRule = types.Pointer("author = @request.auth.id || (@request.auth.id != \"\" && list_share_via_list.list = id && list_share_via_list.user ?= @request.auth.id && list_share_via_list.permission = \"edit\")")
|
collection.UpdateRule = types.Pointer("author = @request.auth.id || (@request.auth.id != \"\" && list_share_via_list.list = id && list_share_via_list.user ?= @request.auth.id && list_share_via_list.permission = \"edit\")")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("r6gu2ajyidy1x69")
|
collection, err := app.FindCollectionByNameOrId("r6gu2ajyidy1x69")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -41,6 +38,6 @@ func init() {
|
|||||||
|
|
||||||
collection.UpdateRule = types.Pointer("author = @request.auth.id ")
|
collection.UpdateRule = types.Pointer("author = @request.auth.id ")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,49 +3,40 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
options := map[string]any{}
|
collection.ViewQuery = "SELECT users.id, COALESCE(MAX(trails.distance), 0) AS max_distance, COALESCE(MAX(trails.elevation_gain), 0) AS max_elevation_gain, COALESCE(MAX(trails.duration), 0) AS max_duration, COALESCE(MIN(trails.distance), 0) AS min_distance, COALESCE(MIN(trails.elevation_gain), 0) AS min_elevation_gain, COALESCE(MIN(trails.duration), 0) AS min_duration FROM users LEFT JOIN trails ON users.id = trails.author OR trails.public = 1 OR EXISTS (\n SELECT 1 \n FROM trail_share \n WHERE trail_share.trail = trails.id \n AND trail_share.user = users.id\n ) GROUP BY users.id;"
|
||||||
if err := json.Unmarshal([]byte(`{
|
|
||||||
"query": "SELECT users.id, COALESCE(MAX(trails.distance), 0) AS max_distance, COALESCE(MAX(trails.elevation_gain), 0) AS max_elevation_gain, COALESCE(MAX(trails.duration), 0) AS max_duration, COALESCE(MIN(trails.distance), 0) AS min_distance, COALESCE(MIN(trails.elevation_gain), 0) AS min_elevation_gain, COALESCE(MIN(trails.duration), 0) AS min_duration FROM users LEFT JOIN trails ON users.id = trails.author OR trails.public = 1 OR EXISTS (\n SELECT 1 \n FROM trail_share \n WHERE trail_share.trail = trails.id \n AND trail_share.user = users.id\n ) GROUP BY users.id;"
|
|
||||||
}`), &options); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
collection.SetOptions(options)
|
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("6tuhuumw")
|
collection.Fields.RemoveById("6tuhuumw")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("xarhom23")
|
collection.Fields.RemoveById("xarhom23")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("kl9wsxwf")
|
collection.Fields.RemoveById("kl9wsxwf")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("ipd1ohgc")
|
collection.Fields.RemoveById("ipd1ohgc")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("o4s7acfv")
|
collection.Fields.RemoveById("o4s7acfv")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("d9lfg9vd")
|
collection.Fields.RemoveById("d9lfg9vd")
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_max_distance := &schema.SchemaField{}
|
new_max_distance := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "ixfa8u8m",
|
"id": "ixfa8u8m",
|
||||||
@@ -60,10 +51,10 @@ func init() {
|
|||||||
}`), new_max_distance); err != nil {
|
}`), new_max_distance); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_max_distance)
|
collection.Fields.Add(new_max_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_max_elevation_gain := &schema.SchemaField{}
|
new_max_elevation_gain := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "bhn0jj40",
|
"id": "bhn0jj40",
|
||||||
@@ -78,10 +69,10 @@ func init() {
|
|||||||
}`), new_max_elevation_gain); err != nil {
|
}`), new_max_elevation_gain); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_max_elevation_gain)
|
collection.Fields.Add(new_max_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_max_duration := &schema.SchemaField{}
|
new_max_duration := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "3kujiwzh",
|
"id": "3kujiwzh",
|
||||||
@@ -96,10 +87,10 @@ func init() {
|
|||||||
}`), new_max_duration); err != nil {
|
}`), new_max_duration); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_max_duration)
|
collection.Fields.Add(new_max_duration)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_min_distance := &schema.SchemaField{}
|
new_min_distance := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "yf3zwzn4",
|
"id": "yf3zwzn4",
|
||||||
@@ -114,10 +105,10 @@ func init() {
|
|||||||
}`), new_min_distance); err != nil {
|
}`), new_min_distance); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_min_distance)
|
collection.Fields.Add(new_min_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_min_elevation_gain := &schema.SchemaField{}
|
new_min_elevation_gain := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "skvtkith",
|
"id": "skvtkith",
|
||||||
@@ -132,10 +123,10 @@ func init() {
|
|||||||
}`), new_min_elevation_gain); err != nil {
|
}`), new_min_elevation_gain); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_min_elevation_gain)
|
collection.Fields.Add(new_min_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_min_duration := &schema.SchemaField{}
|
new_min_duration := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "gydvo1ug",
|
"id": "gydvo1ug",
|
||||||
@@ -150,27 +141,25 @@ func init() {
|
|||||||
}`), new_min_duration); err != nil {
|
}`), new_min_duration); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_min_duration)
|
collection.Fields.Add(new_min_duration)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
options := map[string]any{}
|
options := map[string]any{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"query": "SELECT users.id, COALESCE(MAX(trails.distance), 0) AS max_distance, COALESCE(MAX(trails.elevation_gain), 0) AS max_elevation_gain, COALESCE(MAX(trails.duration), 0) AS max_duration, COALESCE(MIN(trails.distance), 0) AS min_distance, COALESCE(MIN(trails.elevation_gain), 0) AS min_elevation_gain, COALESCE(MIN(trails.duration), 0) AS min_duration FROM users LEFT JOIN trails ON users.id = trails.author OR trails.public = 1 OR EXISTS (\n SELECT 1 \n FROM trail_share \n WHERE trail_share.trail = trails.id \n AND trail_share.user = users.id\n );"
|
|
||||||
}`), &options); err != nil {
|
}`), &options); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.SetOptions(options)
|
collection.ViewQuery = "SELECT users.id, COALESCE(MAX(trails.distance), 0) AS max_distance, COALESCE(MAX(trails.elevation_gain), 0) AS max_elevation_gain, COALESCE(MAX(trails.duration), 0) AS max_duration, COALESCE(MIN(trails.distance), 0) AS min_distance, COALESCE(MIN(trails.elevation_gain), 0) AS min_elevation_gain, COALESCE(MIN(trails.duration), 0) AS min_duration FROM users LEFT JOIN trails ON users.id = trails.author OR trails.public = 1 OR EXISTS (\n SELECT 1 \n FROM trail_share \n WHERE trail_share.trail = trails.id \n AND trail_share.user = users.id\n );"
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_max_distance := &schema.SchemaField{}
|
del_max_distance := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "6tuhuumw",
|
"id": "6tuhuumw",
|
||||||
@@ -185,10 +174,10 @@ func init() {
|
|||||||
}`), del_max_distance); err != nil {
|
}`), del_max_distance); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_max_distance)
|
collection.Fields.Add(del_max_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_max_elevation_gain := &schema.SchemaField{}
|
del_max_elevation_gain := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "xarhom23",
|
"id": "xarhom23",
|
||||||
@@ -203,10 +192,10 @@ func init() {
|
|||||||
}`), del_max_elevation_gain); err != nil {
|
}`), del_max_elevation_gain); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_max_elevation_gain)
|
collection.Fields.Add(del_max_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_max_duration := &schema.SchemaField{}
|
del_max_duration := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "kl9wsxwf",
|
"id": "kl9wsxwf",
|
||||||
@@ -221,10 +210,10 @@ func init() {
|
|||||||
}`), del_max_duration); err != nil {
|
}`), del_max_duration); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_max_duration)
|
collection.Fields.Add(del_max_duration)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_min_distance := &schema.SchemaField{}
|
del_min_distance := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "ipd1ohgc",
|
"id": "ipd1ohgc",
|
||||||
@@ -239,10 +228,10 @@ func init() {
|
|||||||
}`), del_min_distance); err != nil {
|
}`), del_min_distance); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_min_distance)
|
collection.Fields.Add(del_min_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_min_elevation_gain := &schema.SchemaField{}
|
del_min_elevation_gain := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "o4s7acfv",
|
"id": "o4s7acfv",
|
||||||
@@ -257,10 +246,10 @@ func init() {
|
|||||||
}`), del_min_elevation_gain); err != nil {
|
}`), del_min_elevation_gain); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_min_elevation_gain)
|
collection.Fields.Add(del_min_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_min_duration := &schema.SchemaField{}
|
del_min_duration := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "d9lfg9vd",
|
"id": "d9lfg9vd",
|
||||||
@@ -275,26 +264,26 @@ func init() {
|
|||||||
}`), del_min_duration); err != nil {
|
}`), del_min_duration); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_min_duration)
|
collection.Fields.Add(del_min_duration)
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("ixfa8u8m")
|
collection.Fields.RemoveById("ixfa8u8m")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("bhn0jj40")
|
collection.Fields.RemoveById("bhn0jj40")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("3kujiwzh")
|
collection.Fields.RemoveById("3kujiwzh")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("yf3zwzn4")
|
collection.Fields.RemoveById("yf3zwzn4")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("skvtkith")
|
collection.Fields.RemoveById("skvtkith")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("gydvo1ug")
|
collection.Fields.RemoveById("gydvo1ug")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,23 +3,20 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_gpx := &schema.SchemaField{}
|
new_gpx := &core.FileField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "rfwmdcpt",
|
"id": "rfwmdcpt",
|
||||||
@@ -38,20 +35,19 @@ func init() {
|
|||||||
}`), new_gpx); err != nil {
|
}`), new_gpx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_gpx)
|
collection.Fields.Add(new_gpx)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("rfwmdcpt")
|
collection.Fields.RemoveById("rfwmdcpt")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,18 +3,15 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -28,7 +25,7 @@ func init() {
|
|||||||
collection.DeleteRule = types.Pointer("@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author ?= @request.auth.id) || (author = @request.auth.id)")
|
collection.DeleteRule = types.Pointer("@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author ?= @request.auth.id) || (author = @request.auth.id)")
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_author := &schema.SchemaField{}
|
new_author := &core.RelationField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "r0mj3tkr",
|
"id": "r0mj3tkr",
|
||||||
@@ -47,13 +44,12 @@ func init() {
|
|||||||
}`), new_author); err != nil {
|
}`), new_author); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_author)
|
collection.Fields.Add(new_author)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -67,8 +63,8 @@ func init() {
|
|||||||
collection.DeleteRule = types.Pointer("@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author ?= @request.auth.id)")
|
collection.DeleteRule = types.Pointer("@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author ?= @request.auth.id)")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("r0mj3tkr")
|
collection.Fields.RemoveById("r0mj3tkr")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,23 +3,20 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db)
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_distance := &schema.SchemaField{}
|
new_distance := &core.NumberField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "jovws28m",
|
"id": "jovws28m",
|
||||||
@@ -36,10 +33,10 @@ func init() {
|
|||||||
}`), new_distance); err != nil {
|
}`), new_distance); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_distance)
|
collection.Fields.Add(new_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_elevation_gain := &schema.SchemaField{}
|
new_elevation_gain := &core.NumberField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "m2kndtwn",
|
"id": "m2kndtwn",
|
||||||
@@ -56,10 +53,10 @@ func init() {
|
|||||||
}`), new_elevation_gain); err != nil {
|
}`), new_elevation_gain); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_elevation_gain)
|
collection.Fields.Add(new_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_elevation_loss := &schema.SchemaField{}
|
new_elevation_loss := &core.NumberField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "uqqo9cws",
|
"id": "uqqo9cws",
|
||||||
@@ -76,10 +73,10 @@ func init() {
|
|||||||
}`), new_elevation_loss); err != nil {
|
}`), new_elevation_loss); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_elevation_loss)
|
collection.Fields.Add(new_elevation_loss)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_duration := &schema.SchemaField{}
|
new_duration := &core.NumberField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "vwxjsrae",
|
"id": "vwxjsrae",
|
||||||
@@ -96,29 +93,28 @@ func init() {
|
|||||||
}`), new_duration); err != nil {
|
}`), new_duration); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_duration)
|
collection.Fields.Add(new_duration)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db)
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("jovws28m")
|
collection.Fields.RemoveById("jovws28m")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("m2kndtwn")
|
collection.Fields.RemoveById("m2kndtwn")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("uqqo9cws")
|
collection.Fields.RemoveById("uqqo9cws")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("vwxjsrae")
|
collection.Fields.RemoveById("vwxjsrae")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,23 +3,20 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
|
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_elevation_loss := &schema.SchemaField{}
|
new_elevation_loss := &core.NumberField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "xutbwpq4",
|
"id": "xutbwpq4",
|
||||||
@@ -36,20 +33,19 @@ func init() {
|
|||||||
}`), new_elevation_loss); err != nil {
|
}`), new_elevation_loss); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_elevation_loss)
|
collection.Fields.Add(new_elevation_loss)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
|
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("xutbwpq4")
|
collection.Fields.RemoveById("xutbwpq4")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,49 +3,45 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
options := map[string]any{}
|
options := map[string]any{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"query": "SELECT users.id, COALESCE(MAX(trails.distance), 0) AS max_distance,\n COALESCE(MAX(trails.elevation_gain), 0) AS max_elevation_gain, \n COALESCE(MAX(trails.elevation_loss), 0) AS max_elevation_loss, \n COALESCE(MAX(trails.duration), 0) AS max_duration, \n COALESCE(MIN(trails.distance), 0) AS min_distance, \n COALESCE(MIN(trails.elevation_gain), 0) AS min_elevation_gain, \n COALESCE(MIN(trails.elevation_loss), 0) AS min_elevation_loss, \n COALESCE(MIN(trails.duration), 0) AS min_duration \nFROM users \n LEFT JOIN trails ON \n users.id = trails.author OR \n trails.public = 1 OR \n EXISTS (\n SELECT 1 \n FROM trail_share \n WHERE trail_share.trail = trails.id \n AND trail_share.user = users.id\n ) GROUP BY users.id;"
|
|
||||||
}`), &options); err != nil {
|
}`), &options); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.SetOptions(options)
|
collection.ViewQuery = "SELECT users.id, COALESCE(MAX(trails.distance), 0) AS max_distance,\n COALESCE(MAX(trails.elevation_gain), 0) AS max_elevation_gain, \n COALESCE(MAX(trails.elevation_loss), 0) AS max_elevation_loss, \n COALESCE(MAX(trails.duration), 0) AS max_duration, \n COALESCE(MIN(trails.distance), 0) AS min_distance, \n COALESCE(MIN(trails.elevation_gain), 0) AS min_elevation_gain, \n COALESCE(MIN(trails.elevation_loss), 0) AS min_elevation_loss, \n COALESCE(MIN(trails.duration), 0) AS min_duration \nFROM users \n LEFT JOIN trails ON \n users.id = trails.author OR \n trails.public = 1 OR \n EXISTS (\n SELECT 1 \n FROM trail_share \n WHERE trail_share.trail = trails.id \n AND trail_share.user = users.id\n ) GROUP BY users.id;"
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("ixfa8u8m")
|
collection.Fields.RemoveById("ixfa8u8m")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("bhn0jj40")
|
collection.Fields.RemoveById("bhn0jj40")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("3kujiwzh")
|
collection.Fields.RemoveById("3kujiwzh")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("yf3zwzn4")
|
collection.Fields.RemoveById("yf3zwzn4")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("skvtkith")
|
collection.Fields.RemoveById("skvtkith")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("gydvo1ug")
|
collection.Fields.RemoveById("gydvo1ug")
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_max_distance := &schema.SchemaField{}
|
new_max_distance := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "oyvx8oaq",
|
"id": "oyvx8oaq",
|
||||||
@@ -60,10 +56,10 @@ func init() {
|
|||||||
}`), new_max_distance); err != nil {
|
}`), new_max_distance); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_max_distance)
|
collection.Fields.Add(new_max_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_max_elevation_gain := &schema.SchemaField{}
|
new_max_elevation_gain := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "4xu7voeh",
|
"id": "4xu7voeh",
|
||||||
@@ -78,10 +74,10 @@ func init() {
|
|||||||
}`), new_max_elevation_gain); err != nil {
|
}`), new_max_elevation_gain); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_max_elevation_gain)
|
collection.Fields.Add(new_max_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_max_elevation_loss := &schema.SchemaField{}
|
new_max_elevation_loss := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "sqzilovv",
|
"id": "sqzilovv",
|
||||||
@@ -96,10 +92,10 @@ func init() {
|
|||||||
}`), new_max_elevation_loss); err != nil {
|
}`), new_max_elevation_loss); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_max_elevation_loss)
|
collection.Fields.Add(new_max_elevation_loss)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_max_duration := &schema.SchemaField{}
|
new_max_duration := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "rupidtew",
|
"id": "rupidtew",
|
||||||
@@ -114,10 +110,10 @@ func init() {
|
|||||||
}`), new_max_duration); err != nil {
|
}`), new_max_duration); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_max_duration)
|
collection.Fields.Add(new_max_duration)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_min_distance := &schema.SchemaField{}
|
new_min_distance := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "2y7dbhf9",
|
"id": "2y7dbhf9",
|
||||||
@@ -132,10 +128,10 @@ func init() {
|
|||||||
}`), new_min_distance); err != nil {
|
}`), new_min_distance); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_min_distance)
|
collection.Fields.Add(new_min_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_min_elevation_gain := &schema.SchemaField{}
|
new_min_elevation_gain := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "ooiwexpc",
|
"id": "ooiwexpc",
|
||||||
@@ -150,10 +146,10 @@ func init() {
|
|||||||
}`), new_min_elevation_gain); err != nil {
|
}`), new_min_elevation_gain); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_min_elevation_gain)
|
collection.Fields.Add(new_min_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_min_elevation_loss := &schema.SchemaField{}
|
new_min_elevation_loss := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "ondmfwce",
|
"id": "ondmfwce",
|
||||||
@@ -168,10 +164,10 @@ func init() {
|
|||||||
}`), new_min_elevation_loss); err != nil {
|
}`), new_min_elevation_loss); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_min_elevation_loss)
|
collection.Fields.Add(new_min_elevation_loss)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_min_duration := &schema.SchemaField{}
|
new_min_duration := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "kcrhzmaw",
|
"id": "kcrhzmaw",
|
||||||
@@ -186,27 +182,25 @@ func init() {
|
|||||||
}`), new_min_duration); err != nil {
|
}`), new_min_duration); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_min_duration)
|
collection.Fields.Add(new_min_duration)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
options := map[string]any{}
|
options := map[string]any{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"query": "SELECT users.id, COALESCE(MAX(trails.distance), 0) AS max_distance, COALESCE(MAX(trails.elevation_gain), 0) AS max_elevation_gain, COALESCE(MAX(trails.duration), 0) AS max_duration, COALESCE(MIN(trails.distance), 0) AS min_distance, COALESCE(MIN(trails.elevation_gain), 0) AS min_elevation_gain, COALESCE(MIN(trails.duration), 0) AS min_duration FROM users LEFT JOIN trails ON users.id = trails.author OR trails.public = 1 OR EXISTS (\n SELECT 1 \n FROM trail_share \n WHERE trail_share.trail = trails.id \n AND trail_share.user = users.id\n ) GROUP BY users.id;"
|
|
||||||
}`), &options); err != nil {
|
}`), &options); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.SetOptions(options)
|
collection.ViewQuery = "SELECT users.id, COALESCE(MAX(trails.distance), 0) AS max_distance, COALESCE(MAX(trails.elevation_gain), 0) AS max_elevation_gain, COALESCE(MAX(trails.duration), 0) AS max_duration, COALESCE(MIN(trails.distance), 0) AS min_distance, COALESCE(MIN(trails.elevation_gain), 0) AS min_elevation_gain, COALESCE(MIN(trails.duration), 0) AS min_duration FROM users LEFT JOIN trails ON users.id = trails.author OR trails.public = 1 OR EXISTS (\n SELECT 1 \n FROM trail_share \n WHERE trail_share.trail = trails.id \n AND trail_share.user = users.id\n ) GROUP BY users.id;"
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_max_distance := &schema.SchemaField{}
|
del_max_distance := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "ixfa8u8m",
|
"id": "ixfa8u8m",
|
||||||
@@ -221,10 +215,10 @@ func init() {
|
|||||||
}`), del_max_distance); err != nil {
|
}`), del_max_distance); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_max_distance)
|
collection.Fields.Add(del_max_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_max_elevation_gain := &schema.SchemaField{}
|
del_max_elevation_gain := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "bhn0jj40",
|
"id": "bhn0jj40",
|
||||||
@@ -239,10 +233,10 @@ func init() {
|
|||||||
}`), del_max_elevation_gain); err != nil {
|
}`), del_max_elevation_gain); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_max_elevation_gain)
|
collection.Fields.Add(del_max_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_max_duration := &schema.SchemaField{}
|
del_max_duration := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "3kujiwzh",
|
"id": "3kujiwzh",
|
||||||
@@ -257,10 +251,10 @@ func init() {
|
|||||||
}`), del_max_duration); err != nil {
|
}`), del_max_duration); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_max_duration)
|
collection.Fields.Add(del_max_duration)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_min_distance := &schema.SchemaField{}
|
del_min_distance := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "yf3zwzn4",
|
"id": "yf3zwzn4",
|
||||||
@@ -275,10 +269,10 @@ func init() {
|
|||||||
}`), del_min_distance); err != nil {
|
}`), del_min_distance); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_min_distance)
|
collection.Fields.Add(del_min_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_min_elevation_gain := &schema.SchemaField{}
|
del_min_elevation_gain := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "skvtkith",
|
"id": "skvtkith",
|
||||||
@@ -293,10 +287,10 @@ func init() {
|
|||||||
}`), del_min_elevation_gain); err != nil {
|
}`), del_min_elevation_gain); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_min_elevation_gain)
|
collection.Fields.Add(del_min_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_min_duration := &schema.SchemaField{}
|
del_min_duration := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "gydvo1ug",
|
"id": "gydvo1ug",
|
||||||
@@ -311,32 +305,32 @@ func init() {
|
|||||||
}`), del_min_duration); err != nil {
|
}`), del_min_duration); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_min_duration)
|
collection.Fields.Add(del_min_duration)
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("oyvx8oaq")
|
collection.Fields.RemoveById("oyvx8oaq")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("4xu7voeh")
|
collection.Fields.RemoveById("4xu7voeh")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("sqzilovv")
|
collection.Fields.RemoveById("sqzilovv")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("rupidtew")
|
collection.Fields.RemoveById("rupidtew")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("2y7dbhf9")
|
collection.Fields.RemoveById("2y7dbhf9")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("ooiwexpc")
|
collection.Fields.RemoveById("ooiwexpc")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("ondmfwce")
|
collection.Fields.RemoveById("ondmfwce")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("kcrhzmaw")
|
collection.Fields.RemoveById("kcrhzmaw")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,15 +4,15 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/meilisearch/meilisearch-go"
|
"github.com/meilisearch/meilisearch-go"
|
||||||
"github.com/pocketbase/dbx"
|
|
||||||
|
|
||||||
|
"github.com/pocketbase/pocketbase/core"
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
client := meilisearch.New(os.Getenv("MEILI_URL"), meilisearch.WithAPIKey(os.Getenv("MEILI_MASTER_KEY")))
|
client := meilisearch.New(os.Getenv("MEILI_URL"), meilisearch.WithAPIKey(os.Getenv("MEILI_MASTER_KEY")))
|
||||||
|
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
_, err := client.Index("trails").UpdateSortableAttributes(&[]string{
|
_, err := client.Index("trails").UpdateSortableAttributes(&[]string{
|
||||||
"created", "date", "difficulty", "distance", "elevation_gain", "elevation_loss", "name",
|
"created", "date", "difficulty", "distance", "elevation_gain", "elevation_loss", "name",
|
||||||
})
|
})
|
||||||
@@ -30,7 +30,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
_, err := client.Index("trails").UpdateSortableAttributes(&[]string{
|
_, err := client.Index("trails").UpdateSortableAttributes(&[]string{
|
||||||
"created", "date", "difficulty", "distance", "elevation_gain", "name",
|
"created", "date", "difficulty", "distance", "elevation_gain", "name",
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,17 +1,15 @@
|
|||||||
package migrations
|
package migrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -20,11 +18,10 @@ func init() {
|
|||||||
|
|
||||||
collection.ViewRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && @collection.trails.author ?= @request.auth.id) || (@collection.trails.summit_logs.id ?= id && @collection.trails.public ?= true) || (author = @request.auth.id)")
|
collection.ViewRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && @collection.trails.author ?= @request.auth.id) || (@collection.trails.summit_logs.id ?= id && @collection.trails.public ?= true) || (author = @request.auth.id)")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -33,6 +30,6 @@ func init() {
|
|||||||
|
|
||||||
collection.ViewRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && @collection.trails.author ?= @request.auth.id) || (@collection.trails.summit_logs.id ?= id && @collection.trails.public = true) || (author = @request.auth.id)")
|
collection.ViewRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && @collection.trails.author ?= @request.auth.id) || (@collection.trails.summit_logs.id ?= id && @collection.trails.public = true) || (author = @request.auth.id)")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,37 +3,28 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("xku110v5a5xbufa")
|
collection, err := app.FindCollectionByNameOrId("xku110v5a5xbufa")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
options := map[string]any{}
|
collection.ViewQuery = "SELECT id, username, avatar, created FROM users"
|
||||||
if err := json.Unmarshal([]byte(`{
|
|
||||||
"query": "SELECT id, username, avatar, created FROM users"
|
|
||||||
}`), &options); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
collection.SetOptions(options)
|
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("ogrxf4ps")
|
collection.Fields.RemoveById("ogrxf4ps")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("7k4bozux")
|
collection.Fields.RemoveById("7k4bozux")
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_username := &schema.SchemaField{}
|
new_username := &core.TextField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "kvteagv6",
|
"id": "kvteagv6",
|
||||||
@@ -50,10 +41,10 @@ func init() {
|
|||||||
}`), new_username); err != nil {
|
}`), new_username); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_username)
|
collection.Fields.Add(new_username)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_avatar := &schema.SchemaField{}
|
new_avatar := &core.FileField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "m9efnpak",
|
"id": "m9efnpak",
|
||||||
@@ -78,27 +69,20 @@ func init() {
|
|||||||
}`), new_avatar); err != nil {
|
}`), new_avatar); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_avatar)
|
collection.Fields.Add(new_avatar)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("xku110v5a5xbufa")
|
collection, err := app.FindCollectionByNameOrId("xku110v5a5xbufa")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
options := map[string]any{}
|
collection.ViewQuery = "SELECT id, username, avatar FROM users"
|
||||||
if err := json.Unmarshal([]byte(`{
|
|
||||||
"query": "SELECT id, username, avatar FROM users"
|
|
||||||
}`), &options); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
collection.SetOptions(options)
|
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_username := &schema.SchemaField{}
|
del_username := &core.TextField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "ogrxf4ps",
|
"id": "ogrxf4ps",
|
||||||
@@ -115,10 +99,10 @@ func init() {
|
|||||||
}`), del_username); err != nil {
|
}`), del_username); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_username)
|
collection.Fields.Add(del_username)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_avatar := &schema.SchemaField{}
|
del_avatar := &core.FileField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "7k4bozux",
|
"id": "7k4bozux",
|
||||||
@@ -143,14 +127,14 @@ func init() {
|
|||||||
}`), del_avatar); err != nil {
|
}`), del_avatar); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_avatar)
|
collection.Fields.Add(del_avatar)
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("kvteagv6")
|
collection.Fields.RemoveById("kvteagv6")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("m9efnpak")
|
collection.Fields.RemoveById("m9efnpak")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,34 +1,31 @@
|
|||||||
package migrations
|
package migrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
collection.ViewRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && @collection.trails.author ?= @request.auth.id) || (@collection.trails.waypoints.id ?= id && @collection.trails.public ?= true) || \n(@collection.trail_share.trail.waypoints.id ?= id && @collection.trail_share.user ?= @request.auth.id) ||\n(author = @request.auth.id)")
|
collection.ViewRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && @collection.trails.author ?= @request.auth.id) || (@collection.trails.waypoints.id ?= id && @collection.trails.public ?= true) || \n(@collection.trail_share.trail.waypoints.id ?= id && @collection.trail_share.user ?= @request.auth.id) ||\n(author = @request.auth.id)")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
collection.ViewRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && @collection.trails.author ?= @request.auth.id) || (@collection.trails.waypoints.id ?= id && @collection.trails.public ?= true) || (author = @request.auth.id)")
|
collection.ViewRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && @collection.trails.author ?= @request.auth.id) || (@collection.trails.waypoints.id ?= id && @collection.trails.public ?= true) || (author = @request.auth.id)")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,15 @@
|
|||||||
package migrations
|
package migrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -20,11 +18,10 @@ func init() {
|
|||||||
|
|
||||||
collection.ViewRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && @collection.trails.author ?= @request.auth.id) || (@collection.trails.summit_logs.id ?= id && @collection.trails.public ?= true) || \n(@collection.trail_share.trail.summit_logs.id ?= id && @collection.trail_share.user ?= @request.auth.id) ||\n(author = @request.auth.id)")
|
collection.ViewRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && @collection.trails.author ?= @request.auth.id) || (@collection.trails.summit_logs.id ?= id && @collection.trails.public ?= true) || \n(@collection.trail_share.trail.summit_logs.id ?= id && @collection.trail_share.user ?= @request.auth.id) ||\n(author = @request.auth.id)")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -33,6 +30,6 @@ func init() {
|
|||||||
|
|
||||||
collection.ViewRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && @collection.trails.author ?= @request.auth.id) || (@collection.trails.summit_logs.id ?= id && @collection.trails.public ?= true) || (author = @request.auth.id)")
|
collection.ViewRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && @collection.trails.author ?= @request.auth.id) || (@collection.trails.summit_logs.id ?= id && @collection.trails.public ?= true) || (author = @request.auth.id)")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,19 @@
|
|||||||
package migrations
|
package migrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db)
|
|
||||||
settings, err := dao.FindSettings()
|
|
||||||
|
|
||||||
if err != nil {
|
settings := app.Settings()
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
settings.Meta.AppName = "wanderer"
|
settings.Meta.AppName = "wanderer"
|
||||||
settings.Meta.ResetPasswordTemplate.ActionUrl = "{APP_URL}/auth/confirm-reset/{TOKEN}"
|
// settings.Meta.ResetPasswordTemplate.ActionUrl = "{APP_URL}/auth/confirm-reset/{TOKEN}"
|
||||||
settings.Meta.VerificationTemplate.ActionUrl = "{APP_URL}/auth/confirm-verification/{TOKEN}"
|
// settings.Meta.VerificationTemplate.ActionUrl = "{APP_URL}/auth/confirm-verification/{TOKEN}"
|
||||||
settings.Meta.ConfirmEmailChangeTemplate.ActionUrl = "{APP_URL}/auth/confirm-email-change/{TOKEN}"
|
// settings.Meta.ConfirmEmailChangeTemplate.ActionUrl = "{APP_URL}/auth/confirm-email-change/{TOKEN}"
|
||||||
|
|
||||||
// settings.meta.verificationTemplate.subject = 'your default subject';
|
// settings.meta.verificationTemplate.subject = 'your default subject';
|
||||||
// settings.meta.verificationTemplate.body = '<p>Hello world - {ACTION_URL}!</p>';
|
// settings.meta.verificationTemplate.body = '<p>Hello world - {ACTION_URL}!</p>';
|
||||||
@@ -30,9 +25,9 @@ func init() {
|
|||||||
// use the https://pocketbase.io/docs/api-settings/ > Update settings
|
// use the https://pocketbase.io/docs/api-settings/ > Update settings
|
||||||
// "Body parameters" section as a reference
|
// "Body parameters" section as a reference
|
||||||
|
|
||||||
return dao.SaveSettings(settings)
|
return app.Save(settings)
|
||||||
|
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
// add down queries...
|
// add down queries...
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -3,18 +3,15 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("xku110v5a5xbufa")
|
collection, err := app.FindCollectionByNameOrId("xku110v5a5xbufa")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -24,13 +21,13 @@ func init() {
|
|||||||
collection.ViewRule = types.Pointer("")
|
collection.ViewRule = types.Pointer("")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("kvteagv6")
|
collection.Fields.RemoveById("kvteagv6")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("m9efnpak")
|
collection.Fields.RemoveById("m9efnpak")
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_username := &schema.SchemaField{}
|
new_username := &core.TextField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "femc0ok5",
|
"id": "femc0ok5",
|
||||||
@@ -47,10 +44,10 @@ func init() {
|
|||||||
}`), new_username); err != nil {
|
}`), new_username); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_username)
|
collection.Fields.Add(new_username)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_avatar := &schema.SchemaField{}
|
new_avatar := &core.FileField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "aglcodpn",
|
"id": "aglcodpn",
|
||||||
@@ -75,13 +72,12 @@ func init() {
|
|||||||
}`), new_avatar); err != nil {
|
}`), new_avatar); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_avatar)
|
collection.Fields.Add(new_avatar)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("xku110v5a5xbufa")
|
collection, err := app.FindCollectionByNameOrId("xku110v5a5xbufa")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -91,7 +87,7 @@ func init() {
|
|||||||
collection.ViewRule = types.Pointer("@request.auth.id != \"\"")
|
collection.ViewRule = types.Pointer("@request.auth.id != \"\"")
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_username := &schema.SchemaField{}
|
del_username := &core.TextField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "kvteagv6",
|
"id": "kvteagv6",
|
||||||
@@ -108,10 +104,10 @@ func init() {
|
|||||||
}`), del_username); err != nil {
|
}`), del_username); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_username)
|
collection.Fields.Add(del_username)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_avatar := &schema.SchemaField{}
|
del_avatar := &core.FileField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "m9efnpak",
|
"id": "m9efnpak",
|
||||||
@@ -136,14 +132,14 @@ func init() {
|
|||||||
}`), del_avatar); err != nil {
|
}`), del_avatar); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_avatar)
|
collection.Fields.Add(del_avatar)
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("femc0ok5")
|
collection.Fields.RemoveById("femc0ok5")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("aglcodpn")
|
collection.Fields.RemoveById("aglcodpn")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,23 +3,20 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_photos := &schema.SchemaField{}
|
new_photos := &core.FileField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "ixnksbkt",
|
"id": "ixnksbkt",
|
||||||
@@ -45,20 +42,19 @@ func init() {
|
|||||||
}`), new_photos); err != nil {
|
}`), new_photos); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_photos)
|
collection.Fields.Add(new_photos)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("ixnksbkt")
|
collection.Fields.RemoveById("ixnksbkt")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,23 +3,20 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_terrain := &schema.SchemaField{}
|
new_terrain := &core.URLField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "mvxf9llv",
|
"id": "mvxf9llv",
|
||||||
@@ -35,20 +32,19 @@ func init() {
|
|||||||
}`), new_terrain); err != nil {
|
}`), new_terrain); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_terrain)
|
collection.Fields.Add(new_terrain)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("mvxf9llv")
|
collection.Fields.RemoveById("mvxf9llv")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,26 +3,23 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("mvxf9llv")
|
collection.Fields.RemoveById("mvxf9llv")
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_terrain := &schema.SchemaField{}
|
new_terrain := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "unsh0qsp",
|
"id": "unsh0qsp",
|
||||||
@@ -37,19 +34,18 @@ func init() {
|
|||||||
}`), new_terrain); err != nil {
|
}`), new_terrain); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_terrain)
|
collection.Fields.Add(new_terrain)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_terrain := &schema.SchemaField{}
|
del_terrain := &core.URLField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "mvxf9llv",
|
"id": "mvxf9llv",
|
||||||
@@ -65,11 +61,11 @@ func init() {
|
|||||||
}`), del_terrain); err != nil {
|
}`), del_terrain); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_terrain)
|
collection.Fields.Add(del_terrain)
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("unsh0qsp")
|
collection.Fields.RemoveById("unsh0qsp")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,15 +4,15 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/meilisearch/meilisearch-go"
|
"github.com/meilisearch/meilisearch-go"
|
||||||
"github.com/pocketbase/dbx"
|
|
||||||
|
|
||||||
|
"github.com/pocketbase/pocketbase/core"
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
client := meilisearch.New(os.Getenv("MEILI_URL"), meilisearch.WithAPIKey(os.Getenv("MEILI_MASTER_KEY")))
|
client := meilisearch.New(os.Getenv("MEILI_URL"), meilisearch.WithAPIKey(os.Getenv("MEILI_MASTER_KEY")))
|
||||||
|
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
_, err := client.Index("trails").UpdateSortableAttributes(&[]string{
|
_, err := client.Index("trails").UpdateSortableAttributes(&[]string{
|
||||||
"created", "date", "difficulty", "distance", "elevation_gain", "elevation_loss", "name", "duration", "author",
|
"created", "date", "difficulty", "distance", "elevation_gain", "elevation_loss", "name", "duration", "author",
|
||||||
})
|
})
|
||||||
@@ -22,7 +22,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
_, err := client.Index("trails").UpdateSortableAttributes(&[]string{
|
_, err := client.Index("trails").UpdateSortableAttributes(&[]string{
|
||||||
"created", "date", "difficulty", "distance", "elevation_gain", "elevation_loss", "name",
|
"created", "date", "difficulty", "distance", "elevation_gain", "elevation_loss", "name",
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -3,23 +3,20 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
|
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_bio := &schema.SchemaField{}
|
new_bio := &core.TextField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "pd2cq8sq",
|
"id": "pd2cq8sq",
|
||||||
@@ -36,20 +33,19 @@ func init() {
|
|||||||
}`), new_bio); err != nil {
|
}`), new_bio); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_bio)
|
collection.Fields.Add(new_bio)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
|
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("pd2cq8sq")
|
collection.Fields.RemoveById("pd2cq8sq")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,37 +3,28 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("xku110v5a5xbufa")
|
collection, err := app.FindCollectionByNameOrId("xku110v5a5xbufa")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
options := map[string]any{}
|
collection.ViewQuery = "SELECT id, username, avatar, bio, created FROM users"
|
||||||
if err := json.Unmarshal([]byte(`{
|
|
||||||
"query": "SELECT id, username, avatar, bio, created FROM users"
|
|
||||||
}`), &options); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
collection.SetOptions(options)
|
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("femc0ok5")
|
collection.Fields.RemoveById("femc0ok5")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("aglcodpn")
|
collection.Fields.RemoveById("aglcodpn")
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_username := &schema.SchemaField{}
|
new_username := &core.TextField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "tkxbpwxe",
|
"id": "tkxbpwxe",
|
||||||
@@ -50,10 +41,10 @@ func init() {
|
|||||||
}`), new_username); err != nil {
|
}`), new_username); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_username)
|
collection.Fields.Add(new_username)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_avatar := &schema.SchemaField{}
|
new_avatar := &core.FileField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "xs5qvkih",
|
"id": "xs5qvkih",
|
||||||
@@ -78,10 +69,10 @@ func init() {
|
|||||||
}`), new_avatar); err != nil {
|
}`), new_avatar); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_avatar)
|
collection.Fields.Add(new_avatar)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_bio := &schema.SchemaField{}
|
new_bio := &core.TextField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "agsa8h5z",
|
"id": "agsa8h5z",
|
||||||
@@ -98,27 +89,20 @@ func init() {
|
|||||||
}`), new_bio); err != nil {
|
}`), new_bio); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_bio)
|
collection.Fields.Add(new_bio)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("xku110v5a5xbufa")
|
collection, err := app.FindCollectionByNameOrId("xku110v5a5xbufa")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
options := map[string]any{}
|
collection.ViewQuery = "SELECT id, username, avatar, created FROM users"
|
||||||
if err := json.Unmarshal([]byte(`{
|
|
||||||
"query": "SELECT id, username, avatar, created FROM users"
|
|
||||||
}`), &options); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
collection.SetOptions(options)
|
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_username := &schema.SchemaField{}
|
del_username := &core.TextField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "femc0ok5",
|
"id": "femc0ok5",
|
||||||
@@ -135,10 +119,10 @@ func init() {
|
|||||||
}`), del_username); err != nil {
|
}`), del_username); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_username)
|
collection.Fields.Add(del_username)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_avatar := &schema.SchemaField{}
|
del_avatar := &core.FileField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "aglcodpn",
|
"id": "aglcodpn",
|
||||||
@@ -163,17 +147,17 @@ func init() {
|
|||||||
}`), del_avatar); err != nil {
|
}`), del_avatar); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_avatar)
|
collection.Fields.Add(del_avatar)
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("tkxbpwxe")
|
collection.Fields.RemoveById("tkxbpwxe")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("xs5qvkih")
|
collection.Fields.RemoveById("xs5qvkih")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("agsa8h5z")
|
collection.Fields.RemoveById("agsa8h5z")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,18 +3,15 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("r6gu2ajyidy1x69")
|
collection, err := app.FindCollectionByNameOrId("r6gu2ajyidy1x69")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -24,7 +21,7 @@ func init() {
|
|||||||
collection.ViewRule = types.Pointer("author = @request.auth.id || public = true || (@request.auth.id != \"\" && list_share_via_list.user ?= @request.auth.id)")
|
collection.ViewRule = types.Pointer("author = @request.auth.id || public = true || (@request.auth.id != \"\" && list_share_via_list.user ?= @request.auth.id)")
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_public := &schema.SchemaField{}
|
new_public := &core.BoolField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "rolk3q3j",
|
"id": "rolk3q3j",
|
||||||
@@ -37,13 +34,12 @@ func init() {
|
|||||||
}`), new_public); err != nil {
|
}`), new_public); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_public)
|
collection.Fields.Add(new_public)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("r6gu2ajyidy1x69")
|
collection, err := app.FindCollectionByNameOrId("r6gu2ajyidy1x69")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -53,8 +49,8 @@ func init() {
|
|||||||
collection.ViewRule = types.Pointer("author = @request.auth.id || (@request.auth.id != \"\" && list_share_via_list.user ?= @request.auth.id)")
|
collection.ViewRule = types.Pointer("author = @request.auth.id || (@request.auth.id != \"\" && list_share_via_list.user ?= @request.auth.id)")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("rolk3q3j")
|
collection.Fields.RemoveById("rolk3q3j")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,12 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
jsonData := `{
|
jsonData := `{
|
||||||
"id": "t9lphichi5xwyeu",
|
"id": "t9lphichi5xwyeu",
|
||||||
"created": "2024-12-14 14:25:55.563Z",
|
"created": "2024-12-14 14:25:55.563Z",
|
||||||
@@ -163,20 +161,19 @@ func init() {
|
|||||||
}
|
}
|
||||||
}`
|
}`
|
||||||
|
|
||||||
collection := &models.Collection{}
|
collection := &core.Collection{}
|
||||||
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return daos.New(db).SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db)
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("t9lphichi5xwyeu")
|
collection, err := app.FindCollectionByNameOrId("t9lphichi5xwyeu")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return dao.DeleteCollection(collection)
|
return app.Delete(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,18 +3,15 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("t9lphichi5xwyeu")
|
collection, err := app.FindCollectionByNameOrId("t9lphichi5xwyeu")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -24,40 +21,40 @@ func init() {
|
|||||||
collection.ViewRule = types.Pointer("")
|
collection.ViewRule = types.Pointer("")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("zegqj8bt")
|
collection.Fields.RemoveById("zegqj8bt")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("mztv5od5")
|
collection.Fields.RemoveById("mztv5od5")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("4hq14mc5")
|
collection.Fields.RemoveById("4hq14mc5")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("hbyuxehw")
|
collection.Fields.RemoveById("hbyuxehw")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("syp8ya96")
|
collection.Fields.RemoveById("syp8ya96")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("rrfp5omm")
|
collection.Fields.RemoveById("rrfp5omm")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("tacveduk")
|
collection.Fields.RemoveById("tacveduk")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("ydhldat1")
|
collection.Fields.RemoveById("ydhldat1")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("9gg24ge8")
|
collection.Fields.RemoveById("9gg24ge8")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("ujsn6lqc")
|
collection.Fields.RemoveById("ujsn6lqc")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("nvvrulvj")
|
collection.Fields.RemoveById("nvvrulvj")
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_date := &schema.SchemaField{}
|
new_date := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "qejtfjom",
|
"id": "qejtfjom",
|
||||||
@@ -72,10 +69,10 @@ func init() {
|
|||||||
}`), new_date); err != nil {
|
}`), new_date); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_date)
|
collection.Fields.Add(new_date)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_name := &schema.SchemaField{}
|
new_name := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "nskezkjx",
|
"id": "nskezkjx",
|
||||||
@@ -90,10 +87,10 @@ func init() {
|
|||||||
}`), new_name); err != nil {
|
}`), new_name); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_name)
|
collection.Fields.Add(new_name)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_description := &schema.SchemaField{}
|
new_description := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "viedej4h",
|
"id": "viedej4h",
|
||||||
@@ -108,10 +105,10 @@ func init() {
|
|||||||
}`), new_description); err != nil {
|
}`), new_description); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_description)
|
collection.Fields.Add(new_description)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_gpx := &schema.SchemaField{}
|
new_gpx := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "vljhhvdy",
|
"id": "vljhhvdy",
|
||||||
@@ -126,10 +123,10 @@ func init() {
|
|||||||
}`), new_gpx); err != nil {
|
}`), new_gpx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_gpx)
|
collection.Fields.Add(new_gpx)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_author := &schema.SchemaField{}
|
new_author := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "z1uaeqzu",
|
"id": "z1uaeqzu",
|
||||||
@@ -144,10 +141,10 @@ func init() {
|
|||||||
}`), new_author); err != nil {
|
}`), new_author); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_author)
|
collection.Fields.Add(new_author)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_photos := &schema.SchemaField{}
|
new_photos := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "9nnpyhlq",
|
"id": "9nnpyhlq",
|
||||||
@@ -162,10 +159,10 @@ func init() {
|
|||||||
}`), new_photos); err != nil {
|
}`), new_photos); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_photos)
|
collection.Fields.Add(new_photos)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_distance := &schema.SchemaField{}
|
new_distance := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "7kzcclzu",
|
"id": "7kzcclzu",
|
||||||
@@ -180,10 +177,10 @@ func init() {
|
|||||||
}`), new_distance); err != nil {
|
}`), new_distance); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_distance)
|
collection.Fields.Add(new_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_duration := &schema.SchemaField{}
|
new_duration := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "gwpsktbu",
|
"id": "gwpsktbu",
|
||||||
@@ -198,10 +195,10 @@ func init() {
|
|||||||
}`), new_duration); err != nil {
|
}`), new_duration); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_duration)
|
collection.Fields.Add(new_duration)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_elevation_gain := &schema.SchemaField{}
|
new_elevation_gain := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "5tze9ybp",
|
"id": "5tze9ybp",
|
||||||
@@ -216,10 +213,10 @@ func init() {
|
|||||||
}`), new_elevation_gain); err != nil {
|
}`), new_elevation_gain); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_elevation_gain)
|
collection.Fields.Add(new_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_elevation_loss := &schema.SchemaField{}
|
new_elevation_loss := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "xkuz8ixp",
|
"id": "xkuz8ixp",
|
||||||
@@ -234,10 +231,10 @@ func init() {
|
|||||||
}`), new_elevation_loss); err != nil {
|
}`), new_elevation_loss); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_elevation_loss)
|
collection.Fields.Add(new_elevation_loss)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_type := &schema.SchemaField{}
|
new_type := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "soylsusn",
|
"id": "soylsusn",
|
||||||
@@ -252,13 +249,12 @@ func init() {
|
|||||||
}`), new_type); err != nil {
|
}`), new_type); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_type)
|
collection.Fields.Add(new_type)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("t9lphichi5xwyeu")
|
collection, err := app.FindCollectionByNameOrId("t9lphichi5xwyeu")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -268,7 +264,7 @@ func init() {
|
|||||||
collection.ViewRule = nil
|
collection.ViewRule = nil
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_date := &schema.SchemaField{}
|
del_date := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "zegqj8bt",
|
"id": "zegqj8bt",
|
||||||
@@ -283,10 +279,10 @@ func init() {
|
|||||||
}`), del_date); err != nil {
|
}`), del_date); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_date)
|
collection.Fields.Add(del_date)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_name := &schema.SchemaField{}
|
del_name := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "mztv5od5",
|
"id": "mztv5od5",
|
||||||
@@ -301,10 +297,10 @@ func init() {
|
|||||||
}`), del_name); err != nil {
|
}`), del_name); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_name)
|
collection.Fields.Add(del_name)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_description := &schema.SchemaField{}
|
del_description := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "4hq14mc5",
|
"id": "4hq14mc5",
|
||||||
@@ -319,10 +315,10 @@ func init() {
|
|||||||
}`), del_description); err != nil {
|
}`), del_description); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_description)
|
collection.Fields.Add(del_description)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_gpx := &schema.SchemaField{}
|
del_gpx := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "hbyuxehw",
|
"id": "hbyuxehw",
|
||||||
@@ -337,10 +333,10 @@ func init() {
|
|||||||
}`), del_gpx); err != nil {
|
}`), del_gpx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_gpx)
|
collection.Fields.Add(del_gpx)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_author := &schema.SchemaField{}
|
del_author := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "syp8ya96",
|
"id": "syp8ya96",
|
||||||
@@ -355,10 +351,10 @@ func init() {
|
|||||||
}`), del_author); err != nil {
|
}`), del_author); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_author)
|
collection.Fields.Add(del_author)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_photos := &schema.SchemaField{}
|
del_photos := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "rrfp5omm",
|
"id": "rrfp5omm",
|
||||||
@@ -373,10 +369,10 @@ func init() {
|
|||||||
}`), del_photos); err != nil {
|
}`), del_photos); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_photos)
|
collection.Fields.Add(del_photos)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_distance := &schema.SchemaField{}
|
del_distance := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "tacveduk",
|
"id": "tacveduk",
|
||||||
@@ -391,10 +387,10 @@ func init() {
|
|||||||
}`), del_distance); err != nil {
|
}`), del_distance); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_distance)
|
collection.Fields.Add(del_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_duration := &schema.SchemaField{}
|
del_duration := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "ydhldat1",
|
"id": "ydhldat1",
|
||||||
@@ -409,10 +405,10 @@ func init() {
|
|||||||
}`), del_duration); err != nil {
|
}`), del_duration); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_duration)
|
collection.Fields.Add(del_duration)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_elevation_gain := &schema.SchemaField{}
|
del_elevation_gain := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "9gg24ge8",
|
"id": "9gg24ge8",
|
||||||
@@ -427,10 +423,10 @@ func init() {
|
|||||||
}`), del_elevation_gain); err != nil {
|
}`), del_elevation_gain); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_elevation_gain)
|
collection.Fields.Add(del_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_elevation_loss := &schema.SchemaField{}
|
del_elevation_loss := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "ujsn6lqc",
|
"id": "ujsn6lqc",
|
||||||
@@ -445,10 +441,10 @@ func init() {
|
|||||||
}`), del_elevation_loss); err != nil {
|
}`), del_elevation_loss); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_elevation_loss)
|
collection.Fields.Add(del_elevation_loss)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_type := &schema.SchemaField{}
|
del_type := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "nvvrulvj",
|
"id": "nvvrulvj",
|
||||||
@@ -463,41 +459,41 @@ func init() {
|
|||||||
}`), del_type); err != nil {
|
}`), del_type); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_type)
|
collection.Fields.Add(del_type)
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("qejtfjom")
|
collection.Fields.RemoveById("qejtfjom")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("nskezkjx")
|
collection.Fields.RemoveById("nskezkjx")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("viedej4h")
|
collection.Fields.RemoveById("viedej4h")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("vljhhvdy")
|
collection.Fields.RemoveById("vljhhvdy")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("z1uaeqzu")
|
collection.Fields.RemoveById("z1uaeqzu")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("9nnpyhlq")
|
collection.Fields.RemoveById("9nnpyhlq")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("7kzcclzu")
|
collection.Fields.RemoveById("7kzcclzu")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("gwpsktbu")
|
collection.Fields.RemoveById("gwpsktbu")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("5tze9ybp")
|
collection.Fields.RemoveById("5tze9ybp")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("xkuz8ixp")
|
collection.Fields.RemoveById("xkuz8ixp")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("soylsusn")
|
collection.Fields.RemoveById("soylsusn")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,64 +3,55 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("t9lphichi5xwyeu")
|
collection, err := app.FindCollectionByNameOrId("t9lphichi5xwyeu")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
options := map[string]any{}
|
collection.ViewQuery = "SELECT id,trail_id,date,name,description,gpx,author,photos,distance,duration,elevation_gain,elevation_loss, type \nFROM (\n SELECT summit_logs.id,trails.id as trail_id,summit_logs.date,trails.name,text as description,summit_logs.gpx,summit_logs.author,summit_logs.photos,summit_logs.distance,summit_logs.duration,summit_logs.elevation_gain,summit_logs.elevation_loss,\"summit_log\" as type \n FROM summit_logs\n LEFT JOIN trails ON summit_logs.id IN (\n SELECT value\n FROM json_each(trails.summit_logs)\n )\n UNION\n SELECT id,id as trail_id,date,name,description,gpx,author,photos,distance,duration,elevation_gain,elevation_loss, \"trail\" as type \n FROM trails\n) ORDER BY date DESC"
|
||||||
if err := json.Unmarshal([]byte(`{
|
|
||||||
"query": "SELECT id,trail_id,date,name,description,gpx,author,photos,distance,duration,elevation_gain,elevation_loss, type \nFROM (\n SELECT summit_logs.id,trails.id as trail_id,summit_logs.date,trails.name,text as description,summit_logs.gpx,summit_logs.author,summit_logs.photos,summit_logs.distance,summit_logs.duration,summit_logs.elevation_gain,summit_logs.elevation_loss,\"summit_log\" as type \n FROM summit_logs\n LEFT JOIN trails ON summit_logs.id IN (\n SELECT value\n FROM json_each(trails.summit_logs)\n )\n UNION\n SELECT id,id as trail_id,date,name,description,gpx,author,photos,distance,duration,elevation_gain,elevation_loss, \"trail\" as type \n FROM trails\n) ORDER BY date DESC"
|
|
||||||
}`), &options); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
collection.SetOptions(options)
|
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("qejtfjom")
|
collection.Fields.RemoveById("qejtfjom")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("nskezkjx")
|
collection.Fields.RemoveById("nskezkjx")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("viedej4h")
|
collection.Fields.RemoveById("viedej4h")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("vljhhvdy")
|
collection.Fields.RemoveById("vljhhvdy")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("z1uaeqzu")
|
collection.Fields.RemoveById("z1uaeqzu")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("9nnpyhlq")
|
collection.Fields.RemoveById("9nnpyhlq")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("7kzcclzu")
|
collection.Fields.RemoveById("7kzcclzu")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("gwpsktbu")
|
collection.Fields.RemoveById("gwpsktbu")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("5tze9ybp")
|
collection.Fields.RemoveById("5tze9ybp")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("xkuz8ixp")
|
collection.Fields.RemoveById("xkuz8ixp")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("soylsusn")
|
collection.Fields.RemoveById("soylsusn")
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_trail_id := &schema.SchemaField{}
|
new_trail_id := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "xbcmb4ax",
|
"id": "xbcmb4ax",
|
||||||
@@ -75,10 +66,10 @@ func init() {
|
|||||||
}`), new_trail_id); err != nil {
|
}`), new_trail_id); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_trail_id)
|
collection.Fields.Add(new_trail_id)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_date := &schema.SchemaField{}
|
new_date := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "elenpjfu",
|
"id": "elenpjfu",
|
||||||
@@ -93,10 +84,10 @@ func init() {
|
|||||||
}`), new_date); err != nil {
|
}`), new_date); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_date)
|
collection.Fields.Add(new_date)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_name := &schema.SchemaField{}
|
new_name := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "gvcm04wv",
|
"id": "gvcm04wv",
|
||||||
@@ -111,10 +102,10 @@ func init() {
|
|||||||
}`), new_name); err != nil {
|
}`), new_name); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_name)
|
collection.Fields.Add(new_name)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_description := &schema.SchemaField{}
|
new_description := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "lzg9ifgi",
|
"id": "lzg9ifgi",
|
||||||
@@ -129,10 +120,10 @@ func init() {
|
|||||||
}`), new_description); err != nil {
|
}`), new_description); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_description)
|
collection.Fields.Add(new_description)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_gpx := &schema.SchemaField{}
|
new_gpx := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "rzqpztsp",
|
"id": "rzqpztsp",
|
||||||
@@ -147,10 +138,10 @@ func init() {
|
|||||||
}`), new_gpx); err != nil {
|
}`), new_gpx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_gpx)
|
collection.Fields.Add(new_gpx)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_author := &schema.SchemaField{}
|
new_author := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "oqzupzz2",
|
"id": "oqzupzz2",
|
||||||
@@ -165,10 +156,10 @@ func init() {
|
|||||||
}`), new_author); err != nil {
|
}`), new_author); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_author)
|
collection.Fields.Add(new_author)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_photos := &schema.SchemaField{}
|
new_photos := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "xmzmcgjm",
|
"id": "xmzmcgjm",
|
||||||
@@ -183,10 +174,10 @@ func init() {
|
|||||||
}`), new_photos); err != nil {
|
}`), new_photos); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_photos)
|
collection.Fields.Add(new_photos)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_distance := &schema.SchemaField{}
|
new_distance := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "rslhnvby",
|
"id": "rslhnvby",
|
||||||
@@ -201,10 +192,10 @@ func init() {
|
|||||||
}`), new_distance); err != nil {
|
}`), new_distance); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_distance)
|
collection.Fields.Add(new_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_duration := &schema.SchemaField{}
|
new_duration := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "xgfy26z9",
|
"id": "xgfy26z9",
|
||||||
@@ -219,10 +210,10 @@ func init() {
|
|||||||
}`), new_duration); err != nil {
|
}`), new_duration); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_duration)
|
collection.Fields.Add(new_duration)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_elevation_gain := &schema.SchemaField{}
|
new_elevation_gain := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "iuhfh4vo",
|
"id": "iuhfh4vo",
|
||||||
@@ -237,10 +228,10 @@ func init() {
|
|||||||
}`), new_elevation_gain); err != nil {
|
}`), new_elevation_gain); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_elevation_gain)
|
collection.Fields.Add(new_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_elevation_loss := &schema.SchemaField{}
|
new_elevation_loss := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "hoauojgi",
|
"id": "hoauojgi",
|
||||||
@@ -255,10 +246,10 @@ func init() {
|
|||||||
}`), new_elevation_loss); err != nil {
|
}`), new_elevation_loss); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_elevation_loss)
|
collection.Fields.Add(new_elevation_loss)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_type := &schema.SchemaField{}
|
new_type := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "7b25xfwx",
|
"id": "7b25xfwx",
|
||||||
@@ -273,27 +264,20 @@ func init() {
|
|||||||
}`), new_type); err != nil {
|
}`), new_type); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_type)
|
collection.Fields.Add(new_type)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("t9lphichi5xwyeu")
|
collection, err := app.FindCollectionByNameOrId("t9lphichi5xwyeu")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
options := map[string]any{}
|
collection.ViewQuery = "SELECT id,date,name,description,gpx,author,photos,distance,duration,elevation_gain,elevation_loss, type \nFROM (\n SELECT summit_logs.id,summit_logs.date,trails.name,text as description,summit_logs.gpx,summit_logs.author,summit_logs.photos,summit_logs.distance,summit_logs.duration,summit_logs.elevation_gain,summit_logs.elevation_loss,\"summit_log\" as type \n FROM summit_logs\n LEFT JOIN trails ON summit_logs.id IN (\n SELECT value\n FROM json_each(trails.summit_logs)\n )\n UNION\n SELECT id,date,name,description,gpx,author,photos,distance,duration,elevation_gain,elevation_loss, \"trail\" as type \n FROM trails\n) ORDER BY date DESC"
|
||||||
if err := json.Unmarshal([]byte(`{
|
|
||||||
"query": "SELECT id,date,name,description,gpx,author,photos,distance,duration,elevation_gain,elevation_loss, type \nFROM (\n SELECT summit_logs.id,summit_logs.date,trails.name,text as description,summit_logs.gpx,summit_logs.author,summit_logs.photos,summit_logs.distance,summit_logs.duration,summit_logs.elevation_gain,summit_logs.elevation_loss,\"summit_log\" as type \n FROM summit_logs\n LEFT JOIN trails ON summit_logs.id IN (\n SELECT value\n FROM json_each(trails.summit_logs)\n )\n UNION\n SELECT id,date,name,description,gpx,author,photos,distance,duration,elevation_gain,elevation_loss, \"trail\" as type \n FROM trails\n) ORDER BY date DESC"
|
|
||||||
}`), &options); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
collection.SetOptions(options)
|
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_date := &schema.SchemaField{}
|
del_date := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "qejtfjom",
|
"id": "qejtfjom",
|
||||||
@@ -308,10 +292,10 @@ func init() {
|
|||||||
}`), del_date); err != nil {
|
}`), del_date); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_date)
|
collection.Fields.Add(del_date)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_name := &schema.SchemaField{}
|
del_name := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "nskezkjx",
|
"id": "nskezkjx",
|
||||||
@@ -326,10 +310,10 @@ func init() {
|
|||||||
}`), del_name); err != nil {
|
}`), del_name); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_name)
|
collection.Fields.Add(del_name)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_description := &schema.SchemaField{}
|
del_description := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "viedej4h",
|
"id": "viedej4h",
|
||||||
@@ -344,10 +328,10 @@ func init() {
|
|||||||
}`), del_description); err != nil {
|
}`), del_description); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_description)
|
collection.Fields.Add(del_description)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_gpx := &schema.SchemaField{}
|
del_gpx := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "vljhhvdy",
|
"id": "vljhhvdy",
|
||||||
@@ -362,10 +346,10 @@ func init() {
|
|||||||
}`), del_gpx); err != nil {
|
}`), del_gpx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_gpx)
|
collection.Fields.Add(del_gpx)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_author := &schema.SchemaField{}
|
del_author := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "z1uaeqzu",
|
"id": "z1uaeqzu",
|
||||||
@@ -380,10 +364,10 @@ func init() {
|
|||||||
}`), del_author); err != nil {
|
}`), del_author); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_author)
|
collection.Fields.Add(del_author)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_photos := &schema.SchemaField{}
|
del_photos := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "9nnpyhlq",
|
"id": "9nnpyhlq",
|
||||||
@@ -398,10 +382,10 @@ func init() {
|
|||||||
}`), del_photos); err != nil {
|
}`), del_photos); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_photos)
|
collection.Fields.Add(del_photos)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_distance := &schema.SchemaField{}
|
del_distance := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "7kzcclzu",
|
"id": "7kzcclzu",
|
||||||
@@ -416,10 +400,10 @@ func init() {
|
|||||||
}`), del_distance); err != nil {
|
}`), del_distance); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_distance)
|
collection.Fields.Add(del_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_duration := &schema.SchemaField{}
|
del_duration := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "gwpsktbu",
|
"id": "gwpsktbu",
|
||||||
@@ -434,10 +418,10 @@ func init() {
|
|||||||
}`), del_duration); err != nil {
|
}`), del_duration); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_duration)
|
collection.Fields.Add(del_duration)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_elevation_gain := &schema.SchemaField{}
|
del_elevation_gain := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "5tze9ybp",
|
"id": "5tze9ybp",
|
||||||
@@ -452,10 +436,10 @@ func init() {
|
|||||||
}`), del_elevation_gain); err != nil {
|
}`), del_elevation_gain); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_elevation_gain)
|
collection.Fields.Add(del_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_elevation_loss := &schema.SchemaField{}
|
del_elevation_loss := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "xkuz8ixp",
|
"id": "xkuz8ixp",
|
||||||
@@ -470,10 +454,10 @@ func init() {
|
|||||||
}`), del_elevation_loss); err != nil {
|
}`), del_elevation_loss); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_elevation_loss)
|
collection.Fields.Add(del_elevation_loss)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_type := &schema.SchemaField{}
|
del_type := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "soylsusn",
|
"id": "soylsusn",
|
||||||
@@ -488,44 +472,44 @@ func init() {
|
|||||||
}`), del_type); err != nil {
|
}`), del_type); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_type)
|
collection.Fields.Add(del_type)
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("xbcmb4ax")
|
collection.Fields.RemoveById("xbcmb4ax")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("elenpjfu")
|
collection.Fields.RemoveById("elenpjfu")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("gvcm04wv")
|
collection.Fields.RemoveById("gvcm04wv")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("lzg9ifgi")
|
collection.Fields.RemoveById("lzg9ifgi")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("rzqpztsp")
|
collection.Fields.RemoveById("rzqpztsp")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("oqzupzz2")
|
collection.Fields.RemoveById("oqzupzz2")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("xmzmcgjm")
|
collection.Fields.RemoveById("xmzmcgjm")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("rslhnvby")
|
collection.Fields.RemoveById("rslhnvby")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("xgfy26z9")
|
collection.Fields.RemoveById("xgfy26z9")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("iuhfh4vo")
|
collection.Fields.RemoveById("iuhfh4vo")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("hoauojgi")
|
collection.Fields.RemoveById("hoauojgi")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("7b25xfwx")
|
collection.Fields.RemoveById("7b25xfwx")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,12 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
jsonData := `{
|
jsonData := `{
|
||||||
"id": "8obn1ukumze565i",
|
"id": "8obn1ukumze565i",
|
||||||
"created": "2024-12-14 17:17:00.381Z",
|
"created": "2024-12-14 17:17:00.381Z",
|
||||||
@@ -61,20 +59,19 @@ func init() {
|
|||||||
"options": {}
|
"options": {}
|
||||||
}`
|
}`
|
||||||
|
|
||||||
collection := &models.Collection{}
|
collection := &core.Collection{}
|
||||||
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return daos.New(db).SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db)
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("8obn1ukumze565i")
|
collection, err := app.FindCollectionByNameOrId("8obn1ukumze565i")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return dao.DeleteCollection(collection)
|
return app.Delete(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,12 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
jsonData := `{
|
jsonData := `{
|
||||||
"id": "j6w72f0kb5ivd7x",
|
"id": "j6w72f0kb5ivd7x",
|
||||||
"created": "2024-12-14 18:20:18.920Z",
|
"created": "2024-12-14 18:20:18.920Z",
|
||||||
@@ -55,20 +53,19 @@ func init() {
|
|||||||
}
|
}
|
||||||
}`
|
}`
|
||||||
|
|
||||||
collection := &models.Collection{}
|
collection := &core.Collection{}
|
||||||
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return daos.New(db).SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db)
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("j6w72f0kb5ivd7x")
|
collection, err := app.FindCollectionByNameOrId("j6w72f0kb5ivd7x")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return dao.DeleteCollection(collection)
|
return app.Delete(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,12 @@
|
|||||||
package migrations
|
package migrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
jsonData := `[
|
jsonData := `[
|
||||||
{
|
{
|
||||||
"id": "e864strfxo14pm4",
|
"id": "e864strfxo14pm4",
|
||||||
@@ -19,7 +15,7 @@ func init() {
|
|||||||
"name": "trails",
|
"name": "trails",
|
||||||
"type": "base",
|
"type": "base",
|
||||||
"system": false,
|
"system": false,
|
||||||
"schema": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "wquvuytd",
|
"id": "wquvuytd",
|
||||||
@@ -319,7 +315,7 @@ func init() {
|
|||||||
"name": "categories",
|
"name": "categories",
|
||||||
"type": "base",
|
"type": "base",
|
||||||
"system": false,
|
"system": false,
|
||||||
"schema": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "38tbd8u4",
|
"id": "38tbd8u4",
|
||||||
@@ -366,7 +362,7 @@ func init() {
|
|||||||
"name": "waypoints",
|
"name": "waypoints",
|
||||||
"type": "base",
|
"type": "base",
|
||||||
"system": false,
|
"system": false,
|
||||||
"schema": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "2yegzjtk",
|
"id": "2yegzjtk",
|
||||||
@@ -491,7 +487,7 @@ func init() {
|
|||||||
"name": "summit_logs",
|
"name": "summit_logs",
|
||||||
"type": "base",
|
"type": "base",
|
||||||
"system": false,
|
"system": false,
|
||||||
"schema": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "gxq1yeld",
|
"id": "gxq1yeld",
|
||||||
@@ -646,7 +642,7 @@ func init() {
|
|||||||
"name": "lists",
|
"name": "lists",
|
||||||
"type": "base",
|
"type": "base",
|
||||||
"system": false,
|
"system": false,
|
||||||
"schema": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "0goi1ipa",
|
"id": "0goi1ipa",
|
||||||
@@ -755,7 +751,7 @@ func init() {
|
|||||||
"name": "trails_filter",
|
"name": "trails_filter",
|
||||||
"type": "view",
|
"type": "view",
|
||||||
"system": false,
|
"system": false,
|
||||||
"schema": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "oyvx8oaq",
|
"id": "oyvx8oaq",
|
||||||
@@ -870,7 +866,7 @@ func init() {
|
|||||||
"name": "comments",
|
"name": "comments",
|
||||||
"type": "base",
|
"type": "base",
|
||||||
"system": false,
|
"system": false,
|
||||||
"schema": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "0udwb0kl",
|
"id": "0udwb0kl",
|
||||||
@@ -947,7 +943,7 @@ func init() {
|
|||||||
"name": "settings",
|
"name": "settings",
|
||||||
"type": "base",
|
"type": "base",
|
||||||
"system": false,
|
"system": false,
|
||||||
"schema": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "0sepzvkh",
|
"id": "0sepzvkh",
|
||||||
@@ -1099,7 +1095,7 @@ func init() {
|
|||||||
"name": "trails_bounding_box",
|
"name": "trails_bounding_box",
|
||||||
"type": "view",
|
"type": "view",
|
||||||
"system": false,
|
"system": false,
|
||||||
"schema": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "qtzda9la",
|
"id": "qtzda9la",
|
||||||
@@ -1166,7 +1162,7 @@ func init() {
|
|||||||
"name": "users_anonymous",
|
"name": "users_anonymous",
|
||||||
"type": "view",
|
"type": "view",
|
||||||
"system": false,
|
"system": false,
|
||||||
"schema": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "hkdk6yjz",
|
"id": "hkdk6yjz",
|
||||||
@@ -1245,7 +1241,7 @@ func init() {
|
|||||||
"name": "trail_share",
|
"name": "trail_share",
|
||||||
"type": "base",
|
"type": "base",
|
||||||
"system": false,
|
"system": false,
|
||||||
"schema": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "eskurfx6",
|
"id": "eskurfx6",
|
||||||
@@ -1310,7 +1306,7 @@ func init() {
|
|||||||
"name": "users",
|
"name": "users",
|
||||||
"type": "auth",
|
"type": "auth",
|
||||||
"system": false,
|
"system": false,
|
||||||
"schema": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "dlzhxcn2",
|
"id": "dlzhxcn2",
|
||||||
@@ -1387,7 +1383,7 @@ func init() {
|
|||||||
"name": "list_share",
|
"name": "list_share",
|
||||||
"type": "base",
|
"type": "base",
|
||||||
"system": false,
|
"system": false,
|
||||||
"schema": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "luqrtipy",
|
"id": "luqrtipy",
|
||||||
@@ -1452,7 +1448,7 @@ func init() {
|
|||||||
"name": "activities",
|
"name": "activities",
|
||||||
"type": "view",
|
"type": "view",
|
||||||
"system": false,
|
"system": false,
|
||||||
"schema": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "7xrdkudh",
|
"id": "7xrdkudh",
|
||||||
@@ -1615,7 +1611,7 @@ func init() {
|
|||||||
"name": "follows",
|
"name": "follows",
|
||||||
"type": "base",
|
"type": "base",
|
||||||
"system": false,
|
"system": false,
|
||||||
"schema": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "in1traur",
|
"id": "in1traur",
|
||||||
@@ -1664,7 +1660,7 @@ func init() {
|
|||||||
"name": "follow_counts",
|
"name": "follow_counts",
|
||||||
"type": "view",
|
"type": "view",
|
||||||
"system": false,
|
"system": false,
|
||||||
"schema": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "6axn8l2f",
|
"id": "6axn8l2f",
|
||||||
@@ -1702,13 +1698,8 @@ func init() {
|
|||||||
}
|
}
|
||||||
]`
|
]`
|
||||||
|
|
||||||
collections := []*models.Collection{}
|
return app.ImportCollectionsByMarshaledJSON([]byte(jsonData), true)
|
||||||
if err := json.Unmarshal([]byte(jsonData), &collections); err != nil {
|
}, func(app core.App) error {
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return daos.New(db).ImportCollections(collections, true, nil)
|
|
||||||
}, func(db dbx.Builder) error {
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,12 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
jsonData := `{
|
jsonData := `{
|
||||||
"id": "khrcci2uqknny8h",
|
"id": "khrcci2uqknny8h",
|
||||||
"created": "2024-12-20 17:33:49.887Z",
|
"created": "2024-12-20 17:33:49.887Z",
|
||||||
@@ -101,20 +99,19 @@ func init() {
|
|||||||
"options": {}
|
"options": {}
|
||||||
}`
|
}`
|
||||||
|
|
||||||
collection := &models.Collection{}
|
collection := &core.Collection{}
|
||||||
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return daos.New(db).SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("khrcci2uqknny8h")
|
collection, err := app.FindCollectionByNameOrId("khrcci2uqknny8h")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return dao.DeleteCollection(collection)
|
return app.Delete(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,23 +3,20 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("khrcci2uqknny8h")
|
collection, err := app.FindCollectionByNameOrId("khrcci2uqknny8h")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// update
|
// update
|
||||||
edit_type := &schema.SchemaField{}
|
edit_type := &core.SelectField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "b57prsbu",
|
"id": "b57prsbu",
|
||||||
@@ -42,19 +39,18 @@ func init() {
|
|||||||
}`), edit_type); err != nil {
|
}`), edit_type); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(edit_type)
|
collection.Fields.Add(edit_type)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("khrcci2uqknny8h")
|
collection, err := app.FindCollectionByNameOrId("khrcci2uqknny8h")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// update
|
// update
|
||||||
edit_type := &schema.SchemaField{}
|
edit_type := &core.SelectField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "b57prsbu",
|
"id": "b57prsbu",
|
||||||
@@ -75,8 +71,8 @@ func init() {
|
|||||||
}`), edit_type); err != nil {
|
}`), edit_type); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(edit_type)
|
collection.Fields.Add(edit_type)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,23 +3,20 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_notifications := &schema.SchemaField{}
|
new_notifications := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "sbwmk0q2",
|
"id": "sbwmk0q2",
|
||||||
@@ -34,20 +31,19 @@ func init() {
|
|||||||
}`), new_notifications); err != nil {
|
}`), new_notifications); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_notifications)
|
collection.Fields.Add(new_notifications)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("sbwmk0q2")
|
collection.Fields.RemoveById("sbwmk0q2")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,34 +1,31 @@
|
|||||||
package migrations
|
package migrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("khrcci2uqknny8h")
|
collection, err := app.FindCollectionByNameOrId("khrcci2uqknny8h")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
collection.UpdateRule = types.Pointer("@request.auth.id = recipient && @request.data.type = type && @request.data.metadata = metadata && @request.data.recipient = recipient && @request.data.author = author && @request.data.seen = true")
|
collection.UpdateRule = types.Pointer("@request.auth.id = recipient && @request.data.type = type && @request.data.metadata = metadata && @request.data.recipient = recipient && @request.data.author = author && @request.data.seen = true")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("khrcci2uqknny8h")
|
collection, err := app.FindCollectionByNameOrId("khrcci2uqknny8h")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
collection.UpdateRule = types.Pointer("@request.auth.id = recipient && @request.data.type = type && @request.data.metadata = metadata && @request.data.recipient = recipient && @request.data.author = author")
|
collection.UpdateRule = types.Pointer("@request.auth.id = recipient && @request.data.type = type && @request.data.metadata = metadata && @request.data.recipient = recipient && @request.data.author = author")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,23 +3,20 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("1kot7t9na3hi0gl")
|
collection, err := app.FindCollectionByNameOrId("1kot7t9na3hi0gl")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// update
|
// update
|
||||||
edit_list := &schema.SchemaField{}
|
edit_list := &core.RelationField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "luqrtipy",
|
"id": "luqrtipy",
|
||||||
@@ -38,19 +35,18 @@ func init() {
|
|||||||
}`), edit_list); err != nil {
|
}`), edit_list); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(edit_list)
|
collection.Fields.Add(edit_list)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("1kot7t9na3hi0gl")
|
collection, err := app.FindCollectionByNameOrId("1kot7t9na3hi0gl")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// update
|
// update
|
||||||
edit_list := &schema.SchemaField{}
|
edit_list := &core.RelationField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "luqrtipy",
|
"id": "luqrtipy",
|
||||||
@@ -69,8 +65,8 @@ func init() {
|
|||||||
}`), edit_list); err != nil {
|
}`), edit_list); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(edit_list)
|
collection.Fields.Add(edit_list)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,23 +3,20 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("khrcci2uqknny8h")
|
collection, err := app.FindCollectionByNameOrId("khrcci2uqknny8h")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// update
|
// update
|
||||||
edit_type := &schema.SchemaField{}
|
edit_type := &core.SelectField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "b57prsbu",
|
"id": "b57prsbu",
|
||||||
@@ -42,19 +39,18 @@ func init() {
|
|||||||
}`), edit_type); err != nil {
|
}`), edit_type); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(edit_type)
|
collection.Fields.Add(edit_type)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("khrcci2uqknny8h")
|
collection, err := app.FindCollectionByNameOrId("khrcci2uqknny8h")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// update
|
// update
|
||||||
edit_type := &schema.SchemaField{}
|
edit_type := &core.SelectField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "b57prsbu",
|
"id": "b57prsbu",
|
||||||
@@ -77,8 +73,8 @@ func init() {
|
|||||||
}`), edit_type); err != nil {
|
}`), edit_type); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(edit_type)
|
collection.Fields.Add(edit_type)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,67 +3,58 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("t9lphichi5xwyeu")
|
collection, err := app.FindCollectionByNameOrId("t9lphichi5xwyeu")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
options := map[string]any{}
|
collection.ViewQuery = "SELECT id,trail_id,date,name,description,gpx,author,photos,distance,duration,elevation_gain,elevation_loss,created,type \nFROM (\n SELECT summit_logs.id,trails.id as trail_id,summit_logs.date,trails.name,text as description,summit_logs.gpx,summit_logs.author,summit_logs.photos,summit_logs.distance,summit_logs.duration,summit_logs.elevation_gain,summit_logs.elevation_loss,summit_logs.created,\"summit_log\" as type \n FROM summit_logs\n LEFT JOIN trails ON summit_logs.id IN (\n SELECT value\n FROM json_each(trails.summit_logs)\n )\n UNION\n SELECT id,id as trail_id,date,name,description,gpx,author,photos,distance,duration,elevation_gain,elevation_loss,created,\"trail\" as type \n FROM trails\n)\nORDER BY date DESC"
|
||||||
if err := json.Unmarshal([]byte(`{
|
|
||||||
"query": "SELECT id,trail_id,date,name,description,gpx,author,photos,distance,duration,elevation_gain,elevation_loss,created,type \nFROM (\n SELECT summit_logs.id,trails.id as trail_id,summit_logs.date,trails.name,text as description,summit_logs.gpx,summit_logs.author,summit_logs.photos,summit_logs.distance,summit_logs.duration,summit_logs.elevation_gain,summit_logs.elevation_loss,summit_logs.created,\"summit_log\" as type \n FROM summit_logs\n LEFT JOIN trails ON summit_logs.id IN (\n SELECT value\n FROM json_each(trails.summit_logs)\n )\n UNION\n SELECT id,id as trail_id,date,name,description,gpx,author,photos,distance,duration,elevation_gain,elevation_loss,created,\"trail\" as type \n FROM trails\n)\nORDER BY date DESC"
|
|
||||||
}`), &options); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
collection.SetOptions(options)
|
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("zmvj8lcq")
|
collection.Fields.RemoveById("zmvj8lcq")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("ujwzemal")
|
collection.Fields.RemoveById("ujwzemal")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("royuu8hr")
|
collection.Fields.RemoveById("royuu8hr")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("e5myhqi1")
|
collection.Fields.RemoveById("e5myhqi1")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("twzxntjy")
|
collection.Fields.RemoveById("twzxntjy")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("mbgymehy")
|
collection.Fields.RemoveById("mbgymehy")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("jvd9zgrj")
|
collection.Fields.RemoveById("jvd9zgrj")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("v6t7ybts")
|
collection.Fields.RemoveById("v6t7ybts")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("vnddbe3a")
|
collection.Fields.RemoveById("vnddbe3a")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("mp9jqukw")
|
collection.Fields.RemoveById("mp9jqukw")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("c6zw4l4h")
|
collection.Fields.RemoveById("c6zw4l4h")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("njsy8gsh")
|
collection.Fields.RemoveById("njsy8gsh")
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_trail_id := &schema.SchemaField{}
|
new_trail_id := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "mpcwfh4x",
|
"id": "mpcwfh4x",
|
||||||
@@ -78,10 +69,10 @@ func init() {
|
|||||||
}`), new_trail_id); err != nil {
|
}`), new_trail_id); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_trail_id)
|
collection.Fields.Add(new_trail_id)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_date := &schema.SchemaField{}
|
new_date := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "xsxx8b8a",
|
"id": "xsxx8b8a",
|
||||||
@@ -96,10 +87,10 @@ func init() {
|
|||||||
}`), new_date); err != nil {
|
}`), new_date); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_date)
|
collection.Fields.Add(new_date)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_name := &schema.SchemaField{}
|
new_name := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "4ybgblqj",
|
"id": "4ybgblqj",
|
||||||
@@ -114,10 +105,10 @@ func init() {
|
|||||||
}`), new_name); err != nil {
|
}`), new_name); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_name)
|
collection.Fields.Add(new_name)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_description := &schema.SchemaField{}
|
new_description := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "f7y3unyx",
|
"id": "f7y3unyx",
|
||||||
@@ -132,10 +123,10 @@ func init() {
|
|||||||
}`), new_description); err != nil {
|
}`), new_description); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_description)
|
collection.Fields.Add(new_description)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_gpx := &schema.SchemaField{}
|
new_gpx := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "cowkmcyy",
|
"id": "cowkmcyy",
|
||||||
@@ -150,10 +141,10 @@ func init() {
|
|||||||
}`), new_gpx); err != nil {
|
}`), new_gpx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_gpx)
|
collection.Fields.Add(new_gpx)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_author := &schema.SchemaField{}
|
new_author := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "dgewwftr",
|
"id": "dgewwftr",
|
||||||
@@ -168,10 +159,10 @@ func init() {
|
|||||||
}`), new_author); err != nil {
|
}`), new_author); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_author)
|
collection.Fields.Add(new_author)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_photos := &schema.SchemaField{}
|
new_photos := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "ugtikydq",
|
"id": "ugtikydq",
|
||||||
@@ -186,10 +177,10 @@ func init() {
|
|||||||
}`), new_photos); err != nil {
|
}`), new_photos); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_photos)
|
collection.Fields.Add(new_photos)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_distance := &schema.SchemaField{}
|
new_distance := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "gal6bffx",
|
"id": "gal6bffx",
|
||||||
@@ -204,10 +195,10 @@ func init() {
|
|||||||
}`), new_distance); err != nil {
|
}`), new_distance); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_distance)
|
collection.Fields.Add(new_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_duration := &schema.SchemaField{}
|
new_duration := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "kimwtlps",
|
"id": "kimwtlps",
|
||||||
@@ -222,10 +213,10 @@ func init() {
|
|||||||
}`), new_duration); err != nil {
|
}`), new_duration); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_duration)
|
collection.Fields.Add(new_duration)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_elevation_gain := &schema.SchemaField{}
|
new_elevation_gain := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "80vmdusd",
|
"id": "80vmdusd",
|
||||||
@@ -240,10 +231,10 @@ func init() {
|
|||||||
}`), new_elevation_gain); err != nil {
|
}`), new_elevation_gain); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_elevation_gain)
|
collection.Fields.Add(new_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_elevation_loss := &schema.SchemaField{}
|
new_elevation_loss := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "mrq3rozi",
|
"id": "mrq3rozi",
|
||||||
@@ -258,10 +249,10 @@ func init() {
|
|||||||
}`), new_elevation_loss); err != nil {
|
}`), new_elevation_loss); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_elevation_loss)
|
collection.Fields.Add(new_elevation_loss)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_type := &schema.SchemaField{}
|
new_type := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "i4dy54g8",
|
"id": "i4dy54g8",
|
||||||
@@ -276,27 +267,20 @@ func init() {
|
|||||||
}`), new_type); err != nil {
|
}`), new_type); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_type)
|
collection.Fields.Add(new_type)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("t9lphichi5xwyeu")
|
collection, err := app.FindCollectionByNameOrId("t9lphichi5xwyeu")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
options := map[string]any{}
|
collection.ViewQuery = "SELECT id,trail_id,date,name,description,gpx,author,photos,distance,duration,elevation_gain,elevation_loss, type \nFROM (\n SELECT summit_logs.id,trails.id as trail_id,summit_logs.date,trails.name,text as description,summit_logs.gpx,summit_logs.author,summit_logs.photos,summit_logs.distance,summit_logs.duration,summit_logs.elevation_gain,summit_logs.elevation_loss,\"summit_log\" as type \n FROM summit_logs\n LEFT JOIN trails ON summit_logs.id IN (\n SELECT value\n FROM json_each(trails.summit_logs)\n )\n UNION\n SELECT id,id as trail_id,date,name,description,gpx,author,photos,distance,duration,elevation_gain,elevation_loss, \"trail\" as type \n FROM trails\n)\nORDER BY date DESC"
|
||||||
if err := json.Unmarshal([]byte(`{
|
|
||||||
"query": "SELECT id,trail_id,date,name,description,gpx,author,photos,distance,duration,elevation_gain,elevation_loss, type \nFROM (\n SELECT summit_logs.id,trails.id as trail_id,summit_logs.date,trails.name,text as description,summit_logs.gpx,summit_logs.author,summit_logs.photos,summit_logs.distance,summit_logs.duration,summit_logs.elevation_gain,summit_logs.elevation_loss,\"summit_log\" as type \n FROM summit_logs\n LEFT JOIN trails ON summit_logs.id IN (\n SELECT value\n FROM json_each(trails.summit_logs)\n )\n UNION\n SELECT id,id as trail_id,date,name,description,gpx,author,photos,distance,duration,elevation_gain,elevation_loss, \"trail\" as type \n FROM trails\n)\nORDER BY date DESC"
|
|
||||||
}`), &options); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
collection.SetOptions(options)
|
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_trail_id := &schema.SchemaField{}
|
del_trail_id := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "zmvj8lcq",
|
"id": "zmvj8lcq",
|
||||||
@@ -311,10 +295,10 @@ func init() {
|
|||||||
}`), del_trail_id); err != nil {
|
}`), del_trail_id); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_trail_id)
|
collection.Fields.Add(del_trail_id)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_date := &schema.SchemaField{}
|
del_date := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "ujwzemal",
|
"id": "ujwzemal",
|
||||||
@@ -329,10 +313,10 @@ func init() {
|
|||||||
}`), del_date); err != nil {
|
}`), del_date); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_date)
|
collection.Fields.Add(del_date)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_name := &schema.SchemaField{}
|
del_name := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "royuu8hr",
|
"id": "royuu8hr",
|
||||||
@@ -347,10 +331,10 @@ func init() {
|
|||||||
}`), del_name); err != nil {
|
}`), del_name); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_name)
|
collection.Fields.Add(del_name)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_description := &schema.SchemaField{}
|
del_description := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "e5myhqi1",
|
"id": "e5myhqi1",
|
||||||
@@ -365,10 +349,10 @@ func init() {
|
|||||||
}`), del_description); err != nil {
|
}`), del_description); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_description)
|
collection.Fields.Add(del_description)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_gpx := &schema.SchemaField{}
|
del_gpx := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "twzxntjy",
|
"id": "twzxntjy",
|
||||||
@@ -383,10 +367,10 @@ func init() {
|
|||||||
}`), del_gpx); err != nil {
|
}`), del_gpx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_gpx)
|
collection.Fields.Add(del_gpx)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_author := &schema.SchemaField{}
|
del_author := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "mbgymehy",
|
"id": "mbgymehy",
|
||||||
@@ -401,10 +385,10 @@ func init() {
|
|||||||
}`), del_author); err != nil {
|
}`), del_author); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_author)
|
collection.Fields.Add(del_author)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_photos := &schema.SchemaField{}
|
del_photos := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "jvd9zgrj",
|
"id": "jvd9zgrj",
|
||||||
@@ -419,10 +403,10 @@ func init() {
|
|||||||
}`), del_photos); err != nil {
|
}`), del_photos); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_photos)
|
collection.Fields.Add(del_photos)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_distance := &schema.SchemaField{}
|
del_distance := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "v6t7ybts",
|
"id": "v6t7ybts",
|
||||||
@@ -437,10 +421,10 @@ func init() {
|
|||||||
}`), del_distance); err != nil {
|
}`), del_distance); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_distance)
|
collection.Fields.Add(del_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_duration := &schema.SchemaField{}
|
del_duration := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "vnddbe3a",
|
"id": "vnddbe3a",
|
||||||
@@ -455,10 +439,10 @@ func init() {
|
|||||||
}`), del_duration); err != nil {
|
}`), del_duration); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_duration)
|
collection.Fields.Add(del_duration)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_elevation_gain := &schema.SchemaField{}
|
del_elevation_gain := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "mp9jqukw",
|
"id": "mp9jqukw",
|
||||||
@@ -473,10 +457,10 @@ func init() {
|
|||||||
}`), del_elevation_gain); err != nil {
|
}`), del_elevation_gain); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_elevation_gain)
|
collection.Fields.Add(del_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_elevation_loss := &schema.SchemaField{}
|
del_elevation_loss := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "c6zw4l4h",
|
"id": "c6zw4l4h",
|
||||||
@@ -491,10 +475,10 @@ func init() {
|
|||||||
}`), del_elevation_loss); err != nil {
|
}`), del_elevation_loss); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_elevation_loss)
|
collection.Fields.Add(del_elevation_loss)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_type := &schema.SchemaField{}
|
del_type := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "njsy8gsh",
|
"id": "njsy8gsh",
|
||||||
@@ -509,44 +493,44 @@ func init() {
|
|||||||
}`), del_type); err != nil {
|
}`), del_type); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_type)
|
collection.Fields.Add(del_type)
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("mpcwfh4x")
|
collection.Fields.RemoveById("mpcwfh4x")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("xsxx8b8a")
|
collection.Fields.RemoveById("xsxx8b8a")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("4ybgblqj")
|
collection.Fields.RemoveById("4ybgblqj")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("f7y3unyx")
|
collection.Fields.RemoveById("f7y3unyx")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("cowkmcyy")
|
collection.Fields.RemoveById("cowkmcyy")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("dgewwftr")
|
collection.Fields.RemoveById("dgewwftr")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("ugtikydq")
|
collection.Fields.RemoveById("ugtikydq")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("gal6bffx")
|
collection.Fields.RemoveById("gal6bffx")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("kimwtlps")
|
collection.Fields.RemoveById("kimwtlps")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("80vmdusd")
|
collection.Fields.RemoveById("80vmdusd")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("mrq3rozi")
|
collection.Fields.RemoveById("mrq3rozi")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("i4dy54g8")
|
collection.Fields.RemoveById("i4dy54g8")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,67 +3,58 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("t9lphichi5xwyeu")
|
collection, err := app.FindCollectionByNameOrId("t9lphichi5xwyeu")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
options := map[string]any{}
|
collection.ViewQuery = "SELECT id,trail_id,date,name,description,gpx,author,photos,distance,duration,elevation_gain,elevation_loss,created,type \nFROM (\n SELECT summit_logs.id,trails.id as trail_id,summit_logs.date,trails.name,text as description,summit_logs.gpx,summit_logs.author,summit_logs.photos,summit_logs.distance,summit_logs.duration,summit_logs.elevation_gain,summit_logs.elevation_loss,summit_logs.created,\"summit_log\" as type \n FROM summit_logs\n JOIN trails ON summit_logs.id IN (\n SELECT value\n FROM json_each(trails.summit_logs)\n )\n UNION\n SELECT id,id as trail_id,date,name,description,gpx,author,photos,distance,duration,elevation_gain,elevation_loss,created,\"trail\" as type \n FROM trails\n)\nORDER BY date DESC"
|
||||||
if err := json.Unmarshal([]byte(`{
|
|
||||||
"query": "SELECT id,trail_id,date,name,description,gpx,author,photos,distance,duration,elevation_gain,elevation_loss,created,type \nFROM (\n SELECT summit_logs.id,trails.id as trail_id,summit_logs.date,trails.name,text as description,summit_logs.gpx,summit_logs.author,summit_logs.photos,summit_logs.distance,summit_logs.duration,summit_logs.elevation_gain,summit_logs.elevation_loss,summit_logs.created,\"summit_log\" as type \n FROM summit_logs\n JOIN trails ON summit_logs.id IN (\n SELECT value\n FROM json_each(trails.summit_logs)\n )\n UNION\n SELECT id,id as trail_id,date,name,description,gpx,author,photos,distance,duration,elevation_gain,elevation_loss,created,\"trail\" as type \n FROM trails\n)\nORDER BY date DESC"
|
|
||||||
}`), &options); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
collection.SetOptions(options)
|
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("mpcwfh4x")
|
collection.Fields.RemoveById("mpcwfh4x")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("xsxx8b8a")
|
collection.Fields.RemoveById("xsxx8b8a")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("4ybgblqj")
|
collection.Fields.RemoveById("4ybgblqj")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("f7y3unyx")
|
collection.Fields.RemoveById("f7y3unyx")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("cowkmcyy")
|
collection.Fields.RemoveById("cowkmcyy")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("dgewwftr")
|
collection.Fields.RemoveById("dgewwftr")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("ugtikydq")
|
collection.Fields.RemoveById("ugtikydq")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("gal6bffx")
|
collection.Fields.RemoveById("gal6bffx")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("kimwtlps")
|
collection.Fields.RemoveById("kimwtlps")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("80vmdusd")
|
collection.Fields.RemoveById("80vmdusd")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("mrq3rozi")
|
collection.Fields.RemoveById("mrq3rozi")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("i4dy54g8")
|
collection.Fields.RemoveById("i4dy54g8")
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_trail_id := &schema.SchemaField{}
|
new_trail_id := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "nsakta5t",
|
"id": "nsakta5t",
|
||||||
@@ -78,10 +69,10 @@ func init() {
|
|||||||
}`), new_trail_id); err != nil {
|
}`), new_trail_id); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_trail_id)
|
collection.Fields.Add(new_trail_id)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_date := &schema.SchemaField{}
|
new_date := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "oahimwtf",
|
"id": "oahimwtf",
|
||||||
@@ -96,10 +87,10 @@ func init() {
|
|||||||
}`), new_date); err != nil {
|
}`), new_date); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_date)
|
collection.Fields.Add(new_date)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_name := &schema.SchemaField{}
|
new_name := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "t9nlksmj",
|
"id": "t9nlksmj",
|
||||||
@@ -114,10 +105,10 @@ func init() {
|
|||||||
}`), new_name); err != nil {
|
}`), new_name); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_name)
|
collection.Fields.Add(new_name)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_description := &schema.SchemaField{}
|
new_description := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "fzfiex8c",
|
"id": "fzfiex8c",
|
||||||
@@ -132,10 +123,10 @@ func init() {
|
|||||||
}`), new_description); err != nil {
|
}`), new_description); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_description)
|
collection.Fields.Add(new_description)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_gpx := &schema.SchemaField{}
|
new_gpx := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "1vk5125z",
|
"id": "1vk5125z",
|
||||||
@@ -150,10 +141,10 @@ func init() {
|
|||||||
}`), new_gpx); err != nil {
|
}`), new_gpx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_gpx)
|
collection.Fields.Add(new_gpx)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_author := &schema.SchemaField{}
|
new_author := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "skmgodvs",
|
"id": "skmgodvs",
|
||||||
@@ -168,10 +159,10 @@ func init() {
|
|||||||
}`), new_author); err != nil {
|
}`), new_author); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_author)
|
collection.Fields.Add(new_author)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_photos := &schema.SchemaField{}
|
new_photos := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "5rkwvgcy",
|
"id": "5rkwvgcy",
|
||||||
@@ -186,10 +177,10 @@ func init() {
|
|||||||
}`), new_photos); err != nil {
|
}`), new_photos); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_photos)
|
collection.Fields.Add(new_photos)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_distance := &schema.SchemaField{}
|
new_distance := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "xsuyuifg",
|
"id": "xsuyuifg",
|
||||||
@@ -204,10 +195,10 @@ func init() {
|
|||||||
}`), new_distance); err != nil {
|
}`), new_distance); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_distance)
|
collection.Fields.Add(new_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_duration := &schema.SchemaField{}
|
new_duration := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "0hsfxjcm",
|
"id": "0hsfxjcm",
|
||||||
@@ -222,10 +213,10 @@ func init() {
|
|||||||
}`), new_duration); err != nil {
|
}`), new_duration); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_duration)
|
collection.Fields.Add(new_duration)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_elevation_gain := &schema.SchemaField{}
|
new_elevation_gain := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "izyphasx",
|
"id": "izyphasx",
|
||||||
@@ -240,10 +231,10 @@ func init() {
|
|||||||
}`), new_elevation_gain); err != nil {
|
}`), new_elevation_gain); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_elevation_gain)
|
collection.Fields.Add(new_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_elevation_loss := &schema.SchemaField{}
|
new_elevation_loss := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "bffz6a6t",
|
"id": "bffz6a6t",
|
||||||
@@ -258,10 +249,10 @@ func init() {
|
|||||||
}`), new_elevation_loss); err != nil {
|
}`), new_elevation_loss); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_elevation_loss)
|
collection.Fields.Add(new_elevation_loss)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_type := &schema.SchemaField{}
|
new_type := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "2xlfylnh",
|
"id": "2xlfylnh",
|
||||||
@@ -276,27 +267,20 @@ func init() {
|
|||||||
}`), new_type); err != nil {
|
}`), new_type); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_type)
|
collection.Fields.Add(new_type)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("t9lphichi5xwyeu")
|
collection, err := app.FindCollectionByNameOrId("t9lphichi5xwyeu")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
options := map[string]any{}
|
collection.ViewQuery = "SELECT id,trail_id,date,name,description,gpx,author,photos,distance,duration,elevation_gain,elevation_loss,created,type \nFROM (\n SELECT summit_logs.id,trails.id as trail_id,summit_logs.date,trails.name,text as description,summit_logs.gpx,summit_logs.author,summit_logs.photos,summit_logs.distance,summit_logs.duration,summit_logs.elevation_gain,summit_logs.elevation_loss,summit_logs.created,\"summit_log\" as type \n FROM summit_logs\n LEFT JOIN trails ON summit_logs.id IN (\n SELECT value\n FROM json_each(trails.summit_logs)\n )\n UNION\n SELECT id,id as trail_id,date,name,description,gpx,author,photos,distance,duration,elevation_gain,elevation_loss,created,\"trail\" as type \n FROM trails\n)\nORDER BY date DESC"
|
||||||
if err := json.Unmarshal([]byte(`{
|
|
||||||
"query": "SELECT id,trail_id,date,name,description,gpx,author,photos,distance,duration,elevation_gain,elevation_loss,created,type \nFROM (\n SELECT summit_logs.id,trails.id as trail_id,summit_logs.date,trails.name,text as description,summit_logs.gpx,summit_logs.author,summit_logs.photos,summit_logs.distance,summit_logs.duration,summit_logs.elevation_gain,summit_logs.elevation_loss,summit_logs.created,\"summit_log\" as type \n FROM summit_logs\n LEFT JOIN trails ON summit_logs.id IN (\n SELECT value\n FROM json_each(trails.summit_logs)\n )\n UNION\n SELECT id,id as trail_id,date,name,description,gpx,author,photos,distance,duration,elevation_gain,elevation_loss,created,\"trail\" as type \n FROM trails\n)\nORDER BY date DESC"
|
|
||||||
}`), &options); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
collection.SetOptions(options)
|
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_trail_id := &schema.SchemaField{}
|
del_trail_id := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "mpcwfh4x",
|
"id": "mpcwfh4x",
|
||||||
@@ -311,10 +295,10 @@ func init() {
|
|||||||
}`), del_trail_id); err != nil {
|
}`), del_trail_id); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_trail_id)
|
collection.Fields.Add(del_trail_id)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_date := &schema.SchemaField{}
|
del_date := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "xsxx8b8a",
|
"id": "xsxx8b8a",
|
||||||
@@ -329,10 +313,10 @@ func init() {
|
|||||||
}`), del_date); err != nil {
|
}`), del_date); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_date)
|
collection.Fields.Add(del_date)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_name := &schema.SchemaField{}
|
del_name := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "4ybgblqj",
|
"id": "4ybgblqj",
|
||||||
@@ -347,10 +331,10 @@ func init() {
|
|||||||
}`), del_name); err != nil {
|
}`), del_name); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_name)
|
collection.Fields.Add(del_name)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_description := &schema.SchemaField{}
|
del_description := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "f7y3unyx",
|
"id": "f7y3unyx",
|
||||||
@@ -365,10 +349,10 @@ func init() {
|
|||||||
}`), del_description); err != nil {
|
}`), del_description); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_description)
|
collection.Fields.Add(del_description)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_gpx := &schema.SchemaField{}
|
del_gpx := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "cowkmcyy",
|
"id": "cowkmcyy",
|
||||||
@@ -383,10 +367,10 @@ func init() {
|
|||||||
}`), del_gpx); err != nil {
|
}`), del_gpx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_gpx)
|
collection.Fields.Add(del_gpx)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_author := &schema.SchemaField{}
|
del_author := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "dgewwftr",
|
"id": "dgewwftr",
|
||||||
@@ -401,10 +385,10 @@ func init() {
|
|||||||
}`), del_author); err != nil {
|
}`), del_author); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_author)
|
collection.Fields.Add(del_author)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_photos := &schema.SchemaField{}
|
del_photos := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "ugtikydq",
|
"id": "ugtikydq",
|
||||||
@@ -419,10 +403,10 @@ func init() {
|
|||||||
}`), del_photos); err != nil {
|
}`), del_photos); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_photos)
|
collection.Fields.Add(del_photos)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_distance := &schema.SchemaField{}
|
del_distance := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "gal6bffx",
|
"id": "gal6bffx",
|
||||||
@@ -437,10 +421,10 @@ func init() {
|
|||||||
}`), del_distance); err != nil {
|
}`), del_distance); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_distance)
|
collection.Fields.Add(del_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_duration := &schema.SchemaField{}
|
del_duration := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "kimwtlps",
|
"id": "kimwtlps",
|
||||||
@@ -455,10 +439,10 @@ func init() {
|
|||||||
}`), del_duration); err != nil {
|
}`), del_duration); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_duration)
|
collection.Fields.Add(del_duration)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_elevation_gain := &schema.SchemaField{}
|
del_elevation_gain := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "80vmdusd",
|
"id": "80vmdusd",
|
||||||
@@ -473,10 +457,10 @@ func init() {
|
|||||||
}`), del_elevation_gain); err != nil {
|
}`), del_elevation_gain); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_elevation_gain)
|
collection.Fields.Add(del_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_elevation_loss := &schema.SchemaField{}
|
del_elevation_loss := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "mrq3rozi",
|
"id": "mrq3rozi",
|
||||||
@@ -491,10 +475,10 @@ func init() {
|
|||||||
}`), del_elevation_loss); err != nil {
|
}`), del_elevation_loss); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_elevation_loss)
|
collection.Fields.Add(del_elevation_loss)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_type := &schema.SchemaField{}
|
del_type := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "i4dy54g8",
|
"id": "i4dy54g8",
|
||||||
@@ -509,44 +493,44 @@ func init() {
|
|||||||
}`), del_type); err != nil {
|
}`), del_type); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_type)
|
collection.Fields.Add(del_type)
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("nsakta5t")
|
collection.Fields.RemoveById("nsakta5t")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("oahimwtf")
|
collection.Fields.RemoveById("oahimwtf")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("t9nlksmj")
|
collection.Fields.RemoveById("t9nlksmj")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("fzfiex8c")
|
collection.Fields.RemoveById("fzfiex8c")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("1vk5125z")
|
collection.Fields.RemoveById("1vk5125z")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("skmgodvs")
|
collection.Fields.RemoveById("skmgodvs")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("5rkwvgcy")
|
collection.Fields.RemoveById("5rkwvgcy")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("xsuyuifg")
|
collection.Fields.RemoveById("xsuyuifg")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("0hsfxjcm")
|
collection.Fields.RemoveById("0hsfxjcm")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("izyphasx")
|
collection.Fields.RemoveById("izyphasx")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("bffz6a6t")
|
collection.Fields.RemoveById("bffz6a6t")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("2xlfylnh")
|
collection.Fields.RemoveById("2xlfylnh")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,34 +1,31 @@
|
|||||||
package migrations
|
package migrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("khrcci2uqknny8h")
|
collection, err := app.FindCollectionByNameOrId("khrcci2uqknny8h")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
collection.UpdateRule = types.Pointer("@request.auth.id = recipient && (@request.data.type = null||@request.data.type = type) && (@request.data.metadata = null||@request.data.metadata = metadata) && (@request.data.recipient = null||@request.data.recipient = recipient) && (@request.data.author = null||@request.data.author = author) && @request.data.seen = true")
|
collection.UpdateRule = types.Pointer("@request.auth.id = recipient && (@request.data.type = null||@request.data.type = type) && (@request.data.metadata = null||@request.data.metadata = metadata) && (@request.data.recipient = null||@request.data.recipient = recipient) && (@request.data.author = null||@request.data.author = author) && @request.data.seen = true")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("khrcci2uqknny8h")
|
collection, err := app.FindCollectionByNameOrId("khrcci2uqknny8h")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
collection.UpdateRule = types.Pointer("@request.auth.id = recipient && @request.data.type = type && @request.data.metadata = metadata && @request.data.recipient = recipient && @request.data.author = author && @request.data.seen = true")
|
collection.UpdateRule = types.Pointer("@request.auth.id = recipient && @request.data.type = type && @request.data.metadata = metadata && @request.data.recipient = recipient && @request.data.author = author && @request.data.seen = true")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,18 +3,15 @@ package migrations
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
"github.com/pocketbase/pocketbase/models/schema"
|
|
||||||
"github.com/pocketbase/pocketbase/tools/types"
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
m.Register(func(db dbx.Builder) error {
|
m.Register(func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("t9lphichi5xwyeu")
|
collection, err := app.FindCollectionByNameOrId("t9lphichi5xwyeu")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -24,43 +21,43 @@ func init() {
|
|||||||
collection.ViewRule = types.Pointer("(\n @request.auth.id = author || \n (@collection.users_anonymous.id ?= author && @collection.users_anonymous.private ?= false)\n)\n&&\n(\n @collection.trails.id ?= trail_id && \n (\n @collection.trails.author = @request.auth.id ||\n @collection.trails.public = true || \n (@request.auth.id != \"\" && @collection.trails.trail_share_via_trail.user ?= @request.auth.id)\n )\n)")
|
collection.ViewRule = types.Pointer("(\n @request.auth.id = author || \n (@collection.users_anonymous.id ?= author && @collection.users_anonymous.private ?= false)\n)\n&&\n(\n @collection.trails.id ?= trail_id && \n (\n @collection.trails.author = @request.auth.id ||\n @collection.trails.public = true || \n (@request.auth.id != \"\" && @collection.trails.trail_share_via_trail.user ?= @request.auth.id)\n )\n)")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("nsakta5t")
|
collection.Fields.RemoveById("nsakta5t")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("oahimwtf")
|
collection.Fields.RemoveById("oahimwtf")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("t9nlksmj")
|
collection.Fields.RemoveById("t9nlksmj")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("fzfiex8c")
|
collection.Fields.RemoveById("fzfiex8c")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("1vk5125z")
|
collection.Fields.RemoveById("1vk5125z")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("skmgodvs")
|
collection.Fields.RemoveById("skmgodvs")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("5rkwvgcy")
|
collection.Fields.RemoveById("5rkwvgcy")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("xsuyuifg")
|
collection.Fields.RemoveById("xsuyuifg")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("0hsfxjcm")
|
collection.Fields.RemoveById("0hsfxjcm")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("izyphasx")
|
collection.Fields.RemoveById("izyphasx")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("bffz6a6t")
|
collection.Fields.RemoveById("bffz6a6t")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("2xlfylnh")
|
collection.Fields.RemoveById("2xlfylnh")
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_trail_id := &schema.SchemaField{}
|
new_trail_id := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "1gmbao3t",
|
"id": "1gmbao3t",
|
||||||
@@ -75,10 +72,10 @@ func init() {
|
|||||||
}`), new_trail_id); err != nil {
|
}`), new_trail_id); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_trail_id)
|
collection.Fields.Add(new_trail_id)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_date := &schema.SchemaField{}
|
new_date := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "pvlr9fv1",
|
"id": "pvlr9fv1",
|
||||||
@@ -93,10 +90,10 @@ func init() {
|
|||||||
}`), new_date); err != nil {
|
}`), new_date); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_date)
|
collection.Fields.Add(new_date)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_name := &schema.SchemaField{}
|
new_name := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "ueqomhey",
|
"id": "ueqomhey",
|
||||||
@@ -111,10 +108,10 @@ func init() {
|
|||||||
}`), new_name); err != nil {
|
}`), new_name); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_name)
|
collection.Fields.Add(new_name)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_description := &schema.SchemaField{}
|
new_description := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "chjcbrid",
|
"id": "chjcbrid",
|
||||||
@@ -129,10 +126,10 @@ func init() {
|
|||||||
}`), new_description); err != nil {
|
}`), new_description); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_description)
|
collection.Fields.Add(new_description)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_gpx := &schema.SchemaField{}
|
new_gpx := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "2wwngiu1",
|
"id": "2wwngiu1",
|
||||||
@@ -147,10 +144,10 @@ func init() {
|
|||||||
}`), new_gpx); err != nil {
|
}`), new_gpx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_gpx)
|
collection.Fields.Add(new_gpx)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_author := &schema.SchemaField{}
|
new_author := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "vfbs4wij",
|
"id": "vfbs4wij",
|
||||||
@@ -165,10 +162,10 @@ func init() {
|
|||||||
}`), new_author); err != nil {
|
}`), new_author); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_author)
|
collection.Fields.Add(new_author)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_photos := &schema.SchemaField{}
|
new_photos := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "kpitkmnj",
|
"id": "kpitkmnj",
|
||||||
@@ -183,10 +180,10 @@ func init() {
|
|||||||
}`), new_photos); err != nil {
|
}`), new_photos); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_photos)
|
collection.Fields.Add(new_photos)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_distance := &schema.SchemaField{}
|
new_distance := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "90almjd5",
|
"id": "90almjd5",
|
||||||
@@ -201,10 +198,10 @@ func init() {
|
|||||||
}`), new_distance); err != nil {
|
}`), new_distance); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_distance)
|
collection.Fields.Add(new_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_duration := &schema.SchemaField{}
|
new_duration := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "49io1roa",
|
"id": "49io1roa",
|
||||||
@@ -219,10 +216,10 @@ func init() {
|
|||||||
}`), new_duration); err != nil {
|
}`), new_duration); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_duration)
|
collection.Fields.Add(new_duration)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_elevation_gain := &schema.SchemaField{}
|
new_elevation_gain := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "kngt1gs1",
|
"id": "kngt1gs1",
|
||||||
@@ -237,10 +234,10 @@ func init() {
|
|||||||
}`), new_elevation_gain); err != nil {
|
}`), new_elevation_gain); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_elevation_gain)
|
collection.Fields.Add(new_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_elevation_loss := &schema.SchemaField{}
|
new_elevation_loss := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "faei1oos",
|
"id": "faei1oos",
|
||||||
@@ -255,10 +252,10 @@ func init() {
|
|||||||
}`), new_elevation_loss); err != nil {
|
}`), new_elevation_loss); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_elevation_loss)
|
collection.Fields.Add(new_elevation_loss)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
new_type := &schema.SchemaField{}
|
new_type := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "fyeket06",
|
"id": "fyeket06",
|
||||||
@@ -273,13 +270,12 @@ func init() {
|
|||||||
}`), new_type); err != nil {
|
}`), new_type); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(new_type)
|
collection.Fields.Add(new_type)
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
}, func(db dbx.Builder) error {
|
}, func(app core.App) error {
|
||||||
dao := daos.New(db);
|
|
||||||
|
|
||||||
collection, err := dao.FindCollectionByNameOrId("t9lphichi5xwyeu")
|
collection, err := app.FindCollectionByNameOrId("t9lphichi5xwyeu")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -289,7 +285,7 @@ func init() {
|
|||||||
collection.ViewRule = types.Pointer("@request.auth.id = author || (@collection.users_anonymous.id ?= author && @collection.users_anonymous.private ?= false)")
|
collection.ViewRule = types.Pointer("@request.auth.id = author || (@collection.users_anonymous.id ?= author && @collection.users_anonymous.private ?= false)")
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_trail_id := &schema.SchemaField{}
|
del_trail_id := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "nsakta5t",
|
"id": "nsakta5t",
|
||||||
@@ -304,10 +300,10 @@ func init() {
|
|||||||
}`), del_trail_id); err != nil {
|
}`), del_trail_id); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_trail_id)
|
collection.Fields.Add(del_trail_id)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_date := &schema.SchemaField{}
|
del_date := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "oahimwtf",
|
"id": "oahimwtf",
|
||||||
@@ -322,10 +318,10 @@ func init() {
|
|||||||
}`), del_date); err != nil {
|
}`), del_date); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_date)
|
collection.Fields.Add(del_date)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_name := &schema.SchemaField{}
|
del_name := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "t9nlksmj",
|
"id": "t9nlksmj",
|
||||||
@@ -340,10 +336,10 @@ func init() {
|
|||||||
}`), del_name); err != nil {
|
}`), del_name); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_name)
|
collection.Fields.Add(del_name)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_description := &schema.SchemaField{}
|
del_description := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "fzfiex8c",
|
"id": "fzfiex8c",
|
||||||
@@ -358,10 +354,10 @@ func init() {
|
|||||||
}`), del_description); err != nil {
|
}`), del_description); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_description)
|
collection.Fields.Add(del_description)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_gpx := &schema.SchemaField{}
|
del_gpx := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "1vk5125z",
|
"id": "1vk5125z",
|
||||||
@@ -376,10 +372,10 @@ func init() {
|
|||||||
}`), del_gpx); err != nil {
|
}`), del_gpx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_gpx)
|
collection.Fields.Add(del_gpx)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_author := &schema.SchemaField{}
|
del_author := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "skmgodvs",
|
"id": "skmgodvs",
|
||||||
@@ -394,10 +390,10 @@ func init() {
|
|||||||
}`), del_author); err != nil {
|
}`), del_author); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_author)
|
collection.Fields.Add(del_author)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_photos := &schema.SchemaField{}
|
del_photos := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "5rkwvgcy",
|
"id": "5rkwvgcy",
|
||||||
@@ -412,10 +408,10 @@ func init() {
|
|||||||
}`), del_photos); err != nil {
|
}`), del_photos); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_photos)
|
collection.Fields.Add(del_photos)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_distance := &schema.SchemaField{}
|
del_distance := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "xsuyuifg",
|
"id": "xsuyuifg",
|
||||||
@@ -430,10 +426,10 @@ func init() {
|
|||||||
}`), del_distance); err != nil {
|
}`), del_distance); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_distance)
|
collection.Fields.Add(del_distance)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_duration := &schema.SchemaField{}
|
del_duration := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "0hsfxjcm",
|
"id": "0hsfxjcm",
|
||||||
@@ -448,10 +444,10 @@ func init() {
|
|||||||
}`), del_duration); err != nil {
|
}`), del_duration); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_duration)
|
collection.Fields.Add(del_duration)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_elevation_gain := &schema.SchemaField{}
|
del_elevation_gain := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "izyphasx",
|
"id": "izyphasx",
|
||||||
@@ -466,10 +462,10 @@ func init() {
|
|||||||
}`), del_elevation_gain); err != nil {
|
}`), del_elevation_gain); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_elevation_gain)
|
collection.Fields.Add(del_elevation_gain)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_elevation_loss := &schema.SchemaField{}
|
del_elevation_loss := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "bffz6a6t",
|
"id": "bffz6a6t",
|
||||||
@@ -484,10 +480,10 @@ func init() {
|
|||||||
}`), del_elevation_loss); err != nil {
|
}`), del_elevation_loss); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_elevation_loss)
|
collection.Fields.Add(del_elevation_loss)
|
||||||
|
|
||||||
// add
|
// add
|
||||||
del_type := &schema.SchemaField{}
|
del_type := &core.JSONField{}
|
||||||
if err := json.Unmarshal([]byte(`{
|
if err := json.Unmarshal([]byte(`{
|
||||||
"system": false,
|
"system": false,
|
||||||
"id": "2xlfylnh",
|
"id": "2xlfylnh",
|
||||||
@@ -502,44 +498,44 @@ func init() {
|
|||||||
}`), del_type); err != nil {
|
}`), del_type); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
collection.Schema.AddField(del_type)
|
collection.Fields.Add(del_type)
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("1gmbao3t")
|
collection.Fields.RemoveById("1gmbao3t")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("pvlr9fv1")
|
collection.Fields.RemoveById("pvlr9fv1")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("ueqomhey")
|
collection.Fields.RemoveById("ueqomhey")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("chjcbrid")
|
collection.Fields.RemoveById("chjcbrid")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("2wwngiu1")
|
collection.Fields.RemoveById("2wwngiu1")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("vfbs4wij")
|
collection.Fields.RemoveById("vfbs4wij")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("kpitkmnj")
|
collection.Fields.RemoveById("kpitkmnj")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("90almjd5")
|
collection.Fields.RemoveById("90almjd5")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("49io1roa")
|
collection.Fields.RemoveById("49io1roa")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("kngt1gs1")
|
collection.Fields.RemoveById("kngt1gs1")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("faei1oos")
|
collection.Fields.RemoveById("faei1oos")
|
||||||
|
|
||||||
// remove
|
// remove
|
||||||
collection.Schema.RemoveField("fyeket06")
|
collection.Fields.RemoveById("fyeket06")
|
||||||
|
|
||||||
return dao.SaveCollection(collection)
|
return app.Save(collection)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user