updates migrations

This commit is contained in:
Christian Beutel
2025-03-17 00:03:56 +01:00
parent c765e6391d
commit eca79758ec
130 changed files with 2107 additions and 2758 deletions

View File

@@ -22,7 +22,7 @@ import (
"pocketbase/integrations/komoot"
"pocketbase/integrations/strava"
// _ "pocketbase/migrations"
_ "pocketbase/migrations"
"pocketbase/util"
)
@@ -30,7 +30,7 @@ func main() {
app := pocketbase.New()
client := initializeMeiliSearch()
// registerMigrations(app)
registerMigrations(app)
setupEventHandlers(app, client)
if err := app.Start(); err != nil {
@@ -489,7 +489,9 @@ func onBeforeServeHandler(app *pocketbase.PocketBase, client meilisearch.Service
return func(e *core.ServeEvent) error {
registerRoutes(e, app, client)
registerCronJobs(app)
return bootstrapData(app, client)
bootstrapData(app, client)
return e.Next()
}
}

View File

@@ -28,7 +28,7 @@ func init() {
"name": "users",
"type": "auth",
"system": false,
"schema": [
"fields": [
{
"system": false,
"id": "dlzhxcn2",
@@ -73,13 +73,11 @@ func init() {
"required": false,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 1,
"values": [
"metric",
"imperial"
]
}
},
{
"system": false,
@@ -89,13 +87,11 @@ func init() {
"required": false,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 1,
"values": [
"en",
"de"
]
}
},
{
"system": false,
@@ -105,10 +101,8 @@ func init() {
"required": false,
"presentable": false,
"unique": false,
"options": {
"maxSize": 2000000
}
}
],
"indexes": [],
"listRule": "id = @request.auth.id",
@@ -135,7 +129,7 @@ func init() {
"name": "trails",
"type": "base",
"system": false,
"schema": [
"fields": [
{
"system": false,
"id": "wquvuytd",
@@ -172,11 +166,9 @@ func init() {
"required": false,
"presentable": false,
"unique": false,
"options": {
"min": null,
"max": null,
"pattern": ""
}
},
{
"system": false,
@@ -196,11 +188,9 @@ func init() {
"required": false,
"presentable": false,
"unique": false,
"options": {
"min": 0,
"max": null,
"noDecimal": false
}
},
{
"system": false,
@@ -210,11 +200,9 @@ func init() {
"required": false,
"presentable": false,
"unique": false,
"options": {
"min": null,
"max": null,
"noDecimal": false
}
"onlyInt": true
},
{
"system": false,
@@ -224,11 +212,9 @@ func init() {
"required": false,
"presentable": false,
"unique": false,
"options": {
"min": 0,
"max": null,
"noDecimal": false
}
"onlyInt": true
},
{
"system": false,
@@ -390,7 +376,7 @@ func init() {
"name": "categories",
"type": "base",
"system": false,
"schema": [
"fields": [
{
"system": false,
"id": "38tbd8u4",
@@ -437,7 +423,7 @@ func init() {
"name": "waypoints",
"type": "base",
"system": false,
"schema": [
"fields": [
{
"system": false,
"id": "2yegzjtk",
@@ -524,7 +510,7 @@ func init() {
"name": "summit_logs",
"type": "base",
"system": false,
"schema": [
"fields": [
{
"system": false,
"id": "gxq1yeld",
@@ -568,7 +554,7 @@ func init() {
"name": "lists",
"type": "base",
"system": false,
"schema": [
"fields": [
{
"system": false,
"id": "0goi1ipa",

View File

@@ -3,23 +3,20 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
if err != nil {
return err
}
// update
edit_photo := &schema.SchemaField{}
edit_photo := &core.FileField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "tfhs3juh",
@@ -42,19 +39,18 @@ func init() {
"protected": false
}
}`), edit_photo)
collection.Schema.AddField(edit_photo)
collection.Fields.Add(edit_photo)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
if err != nil {
return err
}
// update
edit_photo := &schema.SchemaField{}
edit_photo := &core.FileField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "tfhs3juh",
@@ -77,8 +73,8 @@ func init() {
"protected": false
}
}`), edit_photo)
collection.Schema.AddField(edit_photo)
collection.Fields.Add(edit_photo)
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,23 +3,20 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
if err != nil {
return err
}
// add
new_author := &schema.SchemaField{}
new_author := &core.RelationField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "8qbxrsd8",
@@ -36,20 +33,19 @@ func init() {
"displayFields": null
}
}`), new_author)
collection.Schema.AddField(new_author)
collection.Fields.Add(new_author)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
if err != nil {
return err
}
// remove
collection.Schema.RemoveField("8qbxrsd8")
collection.Fields.RemoveById("8qbxrsd8")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -1,17 +1,15 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
if err != nil {
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)")
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
if err != nil {
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)")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -1,34 +1,31 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
if err != nil {
return err
}
collection.UpdateRule = types.Pointer("")
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
if err != nil {
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)")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -1,17 +1,15 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
if err != nil {
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)")
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
if err != nil {
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)")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -1,17 +1,15 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
if err != nil {
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)")
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
if err != nil {
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)")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -1,17 +1,15 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
if err != nil {
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)")
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
if err != nil {
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)")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,23 +3,20 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
if err != nil {
return err
}
// update
edit_photos := &schema.SchemaField{}
edit_photos := &core.FileField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "tfhs3juh",
@@ -42,19 +39,18 @@ func init() {
"protected": false
}
}`), edit_photos)
collection.Schema.AddField(edit_photos)
collection.Fields.Add(edit_photos)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
if err != nil {
return err
}
// update
edit_photos := &schema.SchemaField{}
edit_photos := &core.FileField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "tfhs3juh",
@@ -77,8 +73,8 @@ func init() {
"protected": false
}
}`), edit_photos)
collection.Schema.AddField(edit_photos)
collection.Fields.Add(edit_photos)
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -1,34 +1,31 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
if err != nil {
return err
}
collection.UpdateRule = types.Pointer("")
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
if err != nil {
return err
}
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)
})
}

View File

@@ -1,34 +1,31 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
if err != nil {
return err
}
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)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
if err != nil {
return err
}
collection.UpdateRule = types.Pointer("")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -1,34 +1,31 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
if err != nil {
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)")
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
if err != nil {
return err
}
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)
})
}

View File

@@ -1,34 +1,31 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
if err != nil {
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)")
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
if err != nil {
return err
}
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)
})
}

View File

@@ -3,23 +3,20 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
if err != nil {
return err
}
// update
edit_language := &schema.SchemaField{}
edit_language := &core.SelectField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "t1wlsqyp",
@@ -39,19 +36,18 @@ func init() {
]
}
}`), edit_language)
collection.Schema.AddField(edit_language)
collection.Fields.Add(edit_language)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
if err != nil {
return err
}
// update
edit_language := &schema.SchemaField{}
edit_language := &core.SelectField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "t1wlsqyp",
@@ -68,8 +64,8 @@ func init() {
]
}
}`), edit_language)
collection.Schema.AddField(edit_language)
collection.Fields.Add(edit_language)
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,23 +3,20 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
if err != nil {
return err
}
// update
edit_language := &schema.SchemaField{}
edit_language := &core.SelectField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "t1wlsqyp",
@@ -40,19 +37,18 @@ func init() {
]
}
}`), edit_language)
collection.Schema.AddField(edit_language)
collection.Fields.Add(edit_language)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
if err != nil {
return err
}
// update
edit_language := &schema.SchemaField{}
edit_language := &core.SelectField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "t1wlsqyp",
@@ -72,8 +68,8 @@ func init() {
]
}
}`), edit_language)
collection.Schema.AddField(edit_language)
collection.Fields.Add(edit_language)
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,23 +3,20 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
if err != nil {
return err
}
// update
edit_language := &schema.SchemaField{}
edit_language := &core.SelectField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "t1wlsqyp",
@@ -41,19 +38,18 @@ func init() {
]
}
}`), edit_language)
collection.Schema.AddField(edit_language)
collection.Fields.Add(edit_language)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
if err != nil {
return err
}
// update
edit_language := &schema.SchemaField{}
edit_language := &core.SelectField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "t1wlsqyp",
@@ -74,8 +70,8 @@ func init() {
]
}
}`), edit_language)
collection.Schema.AddField(edit_language)
collection.Fields.Add(edit_language)
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,14 +3,12 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models"
)
func init() {
m.Register(func(db dbx.Builder) error {
m.Register(func(app core.App) error {
jsonData := `{
"id": "4wbv9tz5zjdrjh1",
"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 {
return err
}
return daos.New(db).SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
if err != nil {
return err
}
return dao.DeleteCollection(collection)
return app.Delete(collection)
})
}

View File

@@ -3,32 +3,25 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
if err != nil {
return err
}
options := map[string]any{}
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)
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;"
// remove
collection.Schema.RemoveField("ovledory")
collection.Fields.RemoveById("ovledory")
// add
new_max_distance := &schema.SchemaField{}
new_max_distance := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "3neuurse",
@@ -41,10 +34,10 @@ func init() {
"maxSize": 1
}
}`), new_max_distance)
collection.Schema.AddField(new_max_distance)
collection.Fields.Add(new_max_distance)
// add
new_max_elevation_gain := &schema.SchemaField{}
new_max_elevation_gain := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "oynpksx3",
@@ -57,10 +50,10 @@ func init() {
"maxSize": 1
}
}`), new_max_elevation_gain)
collection.Schema.AddField(new_max_elevation_gain)
collection.Fields.Add(new_max_elevation_gain)
// add
new_max_duration := &schema.SchemaField{}
new_max_duration := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "tkoppkjw",
@@ -73,10 +66,10 @@ func init() {
"maxSize": 1
}
}`), new_max_duration)
collection.Schema.AddField(new_max_duration)
collection.Fields.Add(new_max_duration)
// add
new_min_distance := &schema.SchemaField{}
new_min_distance := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "uxc0eimu",
@@ -89,10 +82,10 @@ func init() {
"maxSize": 1
}
}`), new_min_distance)
collection.Schema.AddField(new_min_distance)
collection.Fields.Add(new_min_distance)
// add
new_min_elevation_gain := &schema.SchemaField{}
new_min_elevation_gain := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "qcktbht6",
@@ -105,10 +98,10 @@ func init() {
"maxSize": 1
}
}`), new_min_elevation_gain)
collection.Schema.AddField(new_min_elevation_gain)
collection.Fields.Add(new_min_elevation_gain)
// add
new_min_duration := &schema.SchemaField{}
new_min_duration := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "qpkhyujt",
@@ -121,25 +114,20 @@ func init() {
"maxSize": 1
}
}`), new_min_duration)
collection.Schema.AddField(new_min_duration)
collection.Fields.Add(new_min_duration)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
if err != nil {
return err
}
options := map[string]any{}
json.Unmarshal([]byte(`{
"query": "SELECT (ROW_NUMBER() OVER()) as id, MAX(trails.distance) AS max_distance FROM trails;"
}`), &options)
collection.SetOptions(options)
collection.ViewQuery = "SELECT (ROW_NUMBER() OVER()) as id, MAX(trails.distance) AS max_distance FROM trails;"
// add
del_max_distance := &schema.SchemaField{}
del_max_distance := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "ovledory",
@@ -152,26 +140,26 @@ func init() {
"maxSize": 1
}
}`), del_max_distance)
collection.Schema.AddField(del_max_distance)
collection.Fields.Add(del_max_distance)
// remove
collection.Schema.RemoveField("3neuurse")
collection.Fields.RemoveById("3neuurse")
// remove
collection.Schema.RemoveField("oynpksx3")
collection.Fields.RemoveById("oynpksx3")
// remove
collection.Schema.RemoveField("tkoppkjw")
collection.Fields.RemoveById("tkoppkjw")
// remove
collection.Schema.RemoveField("uxc0eimu")
collection.Fields.RemoveById("uxc0eimu")
// remove
collection.Schema.RemoveField("qcktbht6")
collection.Fields.RemoveById("qcktbht6")
// remove
collection.Schema.RemoveField("qpkhyujt")
collection.Fields.RemoveById("qpkhyujt")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,18 +3,15 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
if err != nil {
return err
}
@@ -22,25 +19,25 @@ func init() {
collection.ListRule = types.Pointer("@request.auth.id != \"\"")
// remove
collection.Schema.RemoveField("3neuurse")
collection.Fields.RemoveById("3neuurse")
// remove
collection.Schema.RemoveField("oynpksx3")
collection.Fields.RemoveById("oynpksx3")
// remove
collection.Schema.RemoveField("tkoppkjw")
collection.Fields.RemoveById("tkoppkjw")
// remove
collection.Schema.RemoveField("uxc0eimu")
collection.Fields.RemoveById("uxc0eimu")
// remove
collection.Schema.RemoveField("qcktbht6")
collection.Fields.RemoveById("qcktbht6")
// remove
collection.Schema.RemoveField("qpkhyujt")
collection.Fields.RemoveById("qpkhyujt")
// add
new_max_distance := &schema.SchemaField{}
new_max_distance := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "54a1hvuq",
@@ -53,10 +50,10 @@ func init() {
"maxSize": 1
}
}`), new_max_distance)
collection.Schema.AddField(new_max_distance)
collection.Fields.Add(new_max_distance)
// add
new_max_elevation_gain := &schema.SchemaField{}
new_max_elevation_gain := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "stcnunkf",
@@ -69,10 +66,10 @@ func init() {
"maxSize": 1
}
}`), new_max_elevation_gain)
collection.Schema.AddField(new_max_elevation_gain)
collection.Fields.Add(new_max_elevation_gain)
// add
new_max_duration := &schema.SchemaField{}
new_max_duration := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "bholagx7",
@@ -85,10 +82,10 @@ func init() {
"maxSize": 1
}
}`), new_max_duration)
collection.Schema.AddField(new_max_duration)
collection.Fields.Add(new_max_duration)
// add
new_min_distance := &schema.SchemaField{}
new_min_distance := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "qjrtggwi",
@@ -101,10 +98,10 @@ func init() {
"maxSize": 1
}
}`), new_min_distance)
collection.Schema.AddField(new_min_distance)
collection.Fields.Add(new_min_distance)
// add
new_min_elevation_gain := &schema.SchemaField{}
new_min_elevation_gain := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "wtlhqwd2",
@@ -117,10 +114,10 @@ func init() {
"maxSize": 1
}
}`), new_min_elevation_gain)
collection.Schema.AddField(new_min_elevation_gain)
collection.Fields.Add(new_min_elevation_gain)
// add
new_min_duration := &schema.SchemaField{}
new_min_duration := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "sputfuyq",
@@ -133,13 +130,12 @@ func init() {
"maxSize": 1
}
}`), new_min_duration)
collection.Schema.AddField(new_min_duration)
collection.Fields.Add(new_min_duration)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
if err != nil {
return err
}
@@ -147,7 +143,7 @@ func init() {
collection.ListRule = nil
// add
del_max_distance := &schema.SchemaField{}
del_max_distance := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "3neuurse",
@@ -160,10 +156,10 @@ func init() {
"maxSize": 1
}
}`), del_max_distance)
collection.Schema.AddField(del_max_distance)
collection.Fields.Add(del_max_distance)
// add
del_max_elevation_gain := &schema.SchemaField{}
del_max_elevation_gain := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "oynpksx3",
@@ -176,10 +172,10 @@ func init() {
"maxSize": 1
}
}`), del_max_elevation_gain)
collection.Schema.AddField(del_max_elevation_gain)
collection.Fields.Add(del_max_elevation_gain)
// add
del_max_duration := &schema.SchemaField{}
del_max_duration := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "tkoppkjw",
@@ -192,10 +188,10 @@ func init() {
"maxSize": 1
}
}`), del_max_duration)
collection.Schema.AddField(del_max_duration)
collection.Fields.Add(del_max_duration)
// add
del_min_distance := &schema.SchemaField{}
del_min_distance := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "uxc0eimu",
@@ -208,10 +204,10 @@ func init() {
"maxSize": 1
}
}`), del_min_distance)
collection.Schema.AddField(del_min_distance)
collection.Fields.Add(del_min_distance)
// add
del_min_elevation_gain := &schema.SchemaField{}
del_min_elevation_gain := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "qcktbht6",
@@ -224,10 +220,10 @@ func init() {
"maxSize": 1
}
}`), del_min_elevation_gain)
collection.Schema.AddField(del_min_elevation_gain)
collection.Fields.Add(del_min_elevation_gain)
// add
del_min_duration := &schema.SchemaField{}
del_min_duration := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "qpkhyujt",
@@ -240,26 +236,26 @@ func init() {
"maxSize": 1
}
}`), del_min_duration)
collection.Schema.AddField(del_min_duration)
collection.Fields.Add(del_min_duration)
// remove
collection.Schema.RemoveField("54a1hvuq")
collection.Fields.RemoveById("54a1hvuq")
// remove
collection.Schema.RemoveField("stcnunkf")
collection.Fields.RemoveById("stcnunkf")
// remove
collection.Schema.RemoveField("bholagx7")
collection.Fields.RemoveById("bholagx7")
// remove
collection.Schema.RemoveField("qjrtggwi")
collection.Fields.RemoveById("qjrtggwi")
// remove
collection.Schema.RemoveField("wtlhqwd2")
collection.Fields.RemoveById("wtlhqwd2")
// remove
collection.Schema.RemoveField("sputfuyq")
collection.Fields.RemoveById("sputfuyq")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,47 +3,40 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
if err != nil {
return err
}
options := map[string]any{}
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)
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;"
// remove
collection.Schema.RemoveField("54a1hvuq")
collection.Fields.RemoveById("54a1hvuq")
// remove
collection.Schema.RemoveField("stcnunkf")
collection.Fields.RemoveById("stcnunkf")
// remove
collection.Schema.RemoveField("bholagx7")
collection.Fields.RemoveById("bholagx7")
// remove
collection.Schema.RemoveField("qjrtggwi")
collection.Fields.RemoveById("qjrtggwi")
// remove
collection.Schema.RemoveField("wtlhqwd2")
collection.Fields.RemoveById("wtlhqwd2")
// remove
collection.Schema.RemoveField("sputfuyq")
collection.Fields.RemoveById("sputfuyq")
// add
new_max_distance := &schema.SchemaField{}
new_max_distance := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "5udo4avx",
@@ -56,10 +49,10 @@ func init() {
"maxSize": 1
}
}`), new_max_distance)
collection.Schema.AddField(new_max_distance)
collection.Fields.Add(new_max_distance)
// add
new_max_elevation_gain := &schema.SchemaField{}
new_max_elevation_gain := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "omuxiatj",
@@ -72,10 +65,10 @@ func init() {
"maxSize": 1
}
}`), new_max_elevation_gain)
collection.Schema.AddField(new_max_elevation_gain)
collection.Fields.Add(new_max_elevation_gain)
// add
new_max_duration := &schema.SchemaField{}
new_max_duration := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "yq4snqnf",
@@ -88,10 +81,10 @@ func init() {
"maxSize": 1
}
}`), new_max_duration)
collection.Schema.AddField(new_max_duration)
collection.Fields.Add(new_max_duration)
// add
new_min_distance := &schema.SchemaField{}
new_min_distance := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "q8d41loj",
@@ -104,10 +97,10 @@ func init() {
"maxSize": 1
}
}`), new_min_distance)
collection.Schema.AddField(new_min_distance)
collection.Fields.Add(new_min_distance)
// add
new_min_elevation_gain := &schema.SchemaField{}
new_min_elevation_gain := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "xsetw0o6",
@@ -120,10 +113,10 @@ func init() {
"maxSize": 1
}
}`), new_min_elevation_gain)
collection.Schema.AddField(new_min_elevation_gain)
collection.Fields.Add(new_min_elevation_gain)
// add
new_min_duration := &schema.SchemaField{}
new_min_duration := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "n4pq80mu",
@@ -136,25 +129,20 @@ func init() {
"maxSize": 1
}
}`), new_min_duration)
collection.Schema.AddField(new_min_duration)
collection.Fields.Add(new_min_duration)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
if err != nil {
return err
}
options := map[string]any{}
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)
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;"
// add
del_max_distance := &schema.SchemaField{}
del_max_distance := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "54a1hvuq",
@@ -167,10 +155,10 @@ func init() {
"maxSize": 1
}
}`), del_max_distance)
collection.Schema.AddField(del_max_distance)
collection.Fields.Add(del_max_distance)
// add
del_max_elevation_gain := &schema.SchemaField{}
del_max_elevation_gain := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "stcnunkf",
@@ -183,10 +171,10 @@ func init() {
"maxSize": 1
}
}`), del_max_elevation_gain)
collection.Schema.AddField(del_max_elevation_gain)
collection.Fields.Add(del_max_elevation_gain)
// add
del_max_duration := &schema.SchemaField{}
del_max_duration := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "bholagx7",
@@ -199,10 +187,10 @@ func init() {
"maxSize": 1
}
}`), del_max_duration)
collection.Schema.AddField(del_max_duration)
collection.Fields.Add(del_max_duration)
// add
del_min_distance := &schema.SchemaField{}
del_min_distance := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "qjrtggwi",
@@ -215,10 +203,10 @@ func init() {
"maxSize": 1
}
}`), del_min_distance)
collection.Schema.AddField(del_min_distance)
collection.Fields.Add(del_min_distance)
// add
del_min_elevation_gain := &schema.SchemaField{}
del_min_elevation_gain := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "wtlhqwd2",
@@ -231,10 +219,10 @@ func init() {
"maxSize": 1
}
}`), del_min_elevation_gain)
collection.Schema.AddField(del_min_elevation_gain)
collection.Fields.Add(del_min_elevation_gain)
// add
del_min_duration := &schema.SchemaField{}
del_min_duration := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "sputfuyq",
@@ -247,26 +235,26 @@ func init() {
"maxSize": 1
}
}`), del_min_duration)
collection.Schema.AddField(del_min_duration)
collection.Fields.Add(del_min_duration)
// remove
collection.Schema.RemoveField("5udo4avx")
collection.Fields.RemoveById("5udo4avx")
// remove
collection.Schema.RemoveField("omuxiatj")
collection.Fields.RemoveById("omuxiatj")
// remove
collection.Schema.RemoveField("yq4snqnf")
collection.Fields.RemoveById("yq4snqnf")
// remove
collection.Schema.RemoveField("q8d41loj")
collection.Fields.RemoveById("q8d41loj")
// remove
collection.Schema.RemoveField("xsetw0o6")
collection.Fields.RemoveById("xsetw0o6")
// remove
collection.Schema.RemoveField("n4pq80mu")
collection.Fields.RemoveById("n4pq80mu")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,18 +3,15 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
if err != nil {
return err
}
@@ -24,25 +21,25 @@ func init() {
collection.ViewRule = types.Pointer("@request.auth.id = id")
// remove
collection.Schema.RemoveField("5udo4avx")
collection.Fields.RemoveById("5udo4avx")
// remove
collection.Schema.RemoveField("omuxiatj")
collection.Fields.RemoveById("omuxiatj")
// remove
collection.Schema.RemoveField("yq4snqnf")
collection.Fields.RemoveById("yq4snqnf")
// remove
collection.Schema.RemoveField("q8d41loj")
collection.Fields.RemoveById("q8d41loj")
// remove
collection.Schema.RemoveField("xsetw0o6")
collection.Fields.RemoveById("xsetw0o6")
// remove
collection.Schema.RemoveField("n4pq80mu")
collection.Fields.RemoveById("n4pq80mu")
// add
new_max_distance := &schema.SchemaField{}
new_max_distance := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "nqiuah7b",
@@ -55,10 +52,10 @@ func init() {
"maxSize": 1
}
}`), new_max_distance)
collection.Schema.AddField(new_max_distance)
collection.Fields.Add(new_max_distance)
// add
new_max_elevation_gain := &schema.SchemaField{}
new_max_elevation_gain := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "rpzvilry",
@@ -71,10 +68,10 @@ func init() {
"maxSize": 1
}
}`), new_max_elevation_gain)
collection.Schema.AddField(new_max_elevation_gain)
collection.Fields.Add(new_max_elevation_gain)
// add
new_max_duration := &schema.SchemaField{}
new_max_duration := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "pfppgcfx",
@@ -87,10 +84,10 @@ func init() {
"maxSize": 1
}
}`), new_max_duration)
collection.Schema.AddField(new_max_duration)
collection.Fields.Add(new_max_duration)
// add
new_min_distance := &schema.SchemaField{}
new_min_distance := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "jrqp7c8d",
@@ -103,10 +100,10 @@ func init() {
"maxSize": 1
}
}`), new_min_distance)
collection.Schema.AddField(new_min_distance)
collection.Fields.Add(new_min_distance)
// add
new_min_elevation_gain := &schema.SchemaField{}
new_min_elevation_gain := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "xjcpg4su",
@@ -119,10 +116,10 @@ func init() {
"maxSize": 1
}
}`), new_min_elevation_gain)
collection.Schema.AddField(new_min_elevation_gain)
collection.Fields.Add(new_min_elevation_gain)
// add
new_min_duration := &schema.SchemaField{}
new_min_duration := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "cuj9awlq",
@@ -135,13 +132,12 @@ func init() {
"maxSize": 1
}
}`), new_min_duration)
collection.Schema.AddField(new_min_duration)
collection.Fields.Add(new_min_duration)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
if err != nil {
return err
}
@@ -151,7 +147,7 @@ func init() {
collection.ViewRule = nil
// add
del_max_distance := &schema.SchemaField{}
del_max_distance := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "5udo4avx",
@@ -164,10 +160,10 @@ func init() {
"maxSize": 1
}
}`), del_max_distance)
collection.Schema.AddField(del_max_distance)
collection.Fields.Add(del_max_distance)
// add
del_max_elevation_gain := &schema.SchemaField{}
del_max_elevation_gain := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "omuxiatj",
@@ -180,10 +176,10 @@ func init() {
"maxSize": 1
}
}`), del_max_elevation_gain)
collection.Schema.AddField(del_max_elevation_gain)
collection.Fields.Add(del_max_elevation_gain)
// add
del_max_duration := &schema.SchemaField{}
del_max_duration := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "yq4snqnf",
@@ -196,10 +192,10 @@ func init() {
"maxSize": 1
}
}`), del_max_duration)
collection.Schema.AddField(del_max_duration)
collection.Fields.Add(del_max_duration)
// add
del_min_distance := &schema.SchemaField{}
del_min_distance := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "q8d41loj",
@@ -212,10 +208,10 @@ func init() {
"maxSize": 1
}
}`), del_min_distance)
collection.Schema.AddField(del_min_distance)
collection.Fields.Add(del_min_distance)
// add
del_min_elevation_gain := &schema.SchemaField{}
del_min_elevation_gain := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "xsetw0o6",
@@ -228,10 +224,10 @@ func init() {
"maxSize": 1
}
}`), del_min_elevation_gain)
collection.Schema.AddField(del_min_elevation_gain)
collection.Fields.Add(del_min_elevation_gain)
// add
del_min_duration := &schema.SchemaField{}
del_min_duration := &core.JSONField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "n4pq80mu",
@@ -244,26 +240,26 @@ func init() {
"maxSize": 1
}
}`), del_min_duration)
collection.Schema.AddField(del_min_duration)
collection.Fields.Add(del_min_duration)
// remove
collection.Schema.RemoveField("nqiuah7b")
collection.Fields.RemoveById("nqiuah7b")
// remove
collection.Schema.RemoveField("rpzvilry")
collection.Fields.RemoveById("rpzvilry")
// remove
collection.Schema.RemoveField("pfppgcfx")
collection.Fields.RemoveById("pfppgcfx")
// remove
collection.Schema.RemoveField("jrqp7c8d")
collection.Fields.RemoveById("jrqp7c8d")
// remove
collection.Schema.RemoveField("xjcpg4su")
collection.Fields.RemoveById("xjcpg4su")
// remove
collection.Schema.RemoveField("cuj9awlq")
collection.Fields.RemoveById("cuj9awlq")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,23 +3,20 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
if err != nil {
return err
}
// update
edit_language := &schema.SchemaField{}
edit_language := &core.SelectField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "t1wlsqyp",
@@ -42,19 +39,18 @@ func init() {
]
}
}`), edit_language)
collection.Schema.AddField(edit_language)
collection.Fields.Add(edit_language)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
if err != nil {
return err
}
// update
edit_language := &schema.SchemaField{}
edit_language := &core.SelectField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "t1wlsqyp",
@@ -76,8 +72,8 @@ func init() {
]
}
}`), edit_language)
collection.Schema.AddField(edit_language)
collection.Fields.Add(edit_language)
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,14 +3,12 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models"
)
func init() {
m.Register(func(db dbx.Builder) error {
m.Register(func(app core.App) error {
jsonData := `{
"id": "lf06qip3f4d11yk",
"created": "2024-04-03 18:44:47.201Z",
@@ -73,20 +71,19 @@ func init() {
"options": {}
}`
collection := &models.Collection{}
collection := &core.Collection{}
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
return err
}
return daos.New(db).SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("lf06qip3f4d11yk")
collection, err := app.FindCollectionByNameOrId("lf06qip3f4d11yk")
if err != nil {
return err
}
return dao.DeleteCollection(collection)
return app.Delete(collection)
})
}

View File

@@ -3,23 +3,20 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
if err != nil {
return err
}
// add
new_comments := &schema.SchemaField{}
new_comments := &core.RelationField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "phhhroww",
@@ -36,20 +33,19 @@ func init() {
"displayFields": null
}
}`), new_comments)
collection.Schema.AddField(new_comments)
collection.Fields.Add(new_comments)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
if err != nil {
return err
}
// remove
collection.Schema.RemoveField("phhhroww")
collection.Fields.RemoveById("phhhroww")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,23 +3,20 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("lf06qip3f4d11yk")
collection, err := app.FindCollectionByNameOrId("lf06qip3f4d11yk")
if err != nil {
return err
}
// add
new_trail := &schema.SchemaField{}
new_trail := &core.RelationField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "snrlpxar",
@@ -36,20 +33,19 @@ func init() {
"displayFields": null
}
}`), new_trail)
collection.Schema.AddField(new_trail)
collection.Fields.Add(new_trail)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("lf06qip3f4d11yk")
collection, err := app.FindCollectionByNameOrId("lf06qip3f4d11yk")
if err != nil {
return err
}
// remove
collection.Schema.RemoveField("snrlpxar")
collection.Fields.RemoveById("snrlpxar")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,35 +3,31 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
if err != nil {
return err
}
// remove
collection.Schema.RemoveField("phhhroww")
collection.Fields.RemoveById("phhhroww")
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
if err != nil {
return err
}
// add
del_comments := &schema.SchemaField{}
del_comments := &core.RelationField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "phhhroww",
@@ -48,8 +44,8 @@ func init() {
"displayFields": null
}
}`), del_comments)
collection.Schema.AddField(del_comments)
collection.Fields.Add(del_comments)
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,49 +3,40 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
if err != nil {
return err
}
options := map[string]any{}
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)
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;"
// remove
collection.Schema.RemoveField("nqiuah7b")
collection.Fields.RemoveById("nqiuah7b")
// remove
collection.Schema.RemoveField("rpzvilry")
collection.Fields.RemoveById("rpzvilry")
// remove
collection.Schema.RemoveField("pfppgcfx")
collection.Fields.RemoveById("pfppgcfx")
// remove
collection.Schema.RemoveField("jrqp7c8d")
collection.Fields.RemoveById("jrqp7c8d")
// remove
collection.Schema.RemoveField("xjcpg4su")
collection.Fields.RemoveById("xjcpg4su")
// remove
collection.Schema.RemoveField("cuj9awlq")
collection.Fields.RemoveById("cuj9awlq")
// add
new_max_distance := &schema.SchemaField{}
new_max_distance := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "265lcwyn",
@@ -60,10 +51,10 @@ func init() {
}`), new_max_distance); err != nil {
return err
}
collection.Schema.AddField(new_max_distance)
collection.Fields.Add(new_max_distance)
// add
new_max_elevation_gain := &schema.SchemaField{}
new_max_elevation_gain := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "8udbn3hb",
@@ -78,10 +69,10 @@ func init() {
}`), new_max_elevation_gain); err != nil {
return err
}
collection.Schema.AddField(new_max_elevation_gain)
collection.Fields.Add(new_max_elevation_gain)
// add
new_max_duration := &schema.SchemaField{}
new_max_duration := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "0mw2f9gg",
@@ -96,10 +87,10 @@ func init() {
}`), new_max_duration); err != nil {
return err
}
collection.Schema.AddField(new_max_duration)
collection.Fields.Add(new_max_duration)
// add
new_min_distance := &schema.SchemaField{}
new_min_distance := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "qumwuc7g",
@@ -114,10 +105,10 @@ func init() {
}`), new_min_distance); err != nil {
return err
}
collection.Schema.AddField(new_min_distance)
collection.Fields.Add(new_min_distance)
// add
new_min_elevation_gain := &schema.SchemaField{}
new_min_elevation_gain := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "sins29kl",
@@ -132,10 +123,10 @@ func init() {
}`), new_min_elevation_gain); err != nil {
return err
}
collection.Schema.AddField(new_min_elevation_gain)
collection.Fields.Add(new_min_elevation_gain)
// add
new_min_duration := &schema.SchemaField{}
new_min_duration := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "dgfnqloa",
@@ -150,27 +141,20 @@ func init() {
}`), new_min_duration); err != nil {
return err
}
collection.Schema.AddField(new_min_duration)
collection.Fields.Add(new_min_duration)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
if err != nil {
return err
}
options := map[string]any{}
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)
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;"
// add
del_max_distance := &schema.SchemaField{}
del_max_distance := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "nqiuah7b",
@@ -185,10 +169,10 @@ func init() {
}`), del_max_distance); err != nil {
return err
}
collection.Schema.AddField(del_max_distance)
collection.Fields.Add(del_max_distance)
// add
del_max_elevation_gain := &schema.SchemaField{}
del_max_elevation_gain := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "rpzvilry",
@@ -203,10 +187,10 @@ func init() {
}`), del_max_elevation_gain); err != nil {
return err
}
collection.Schema.AddField(del_max_elevation_gain)
collection.Fields.Add(del_max_elevation_gain)
// add
del_max_duration := &schema.SchemaField{}
del_max_duration := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "pfppgcfx",
@@ -221,10 +205,10 @@ func init() {
}`), del_max_duration); err != nil {
return err
}
collection.Schema.AddField(del_max_duration)
collection.Fields.Add(del_max_duration)
// add
del_min_distance := &schema.SchemaField{}
del_min_distance := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "jrqp7c8d",
@@ -239,10 +223,10 @@ func init() {
}`), del_min_distance); err != nil {
return err
}
collection.Schema.AddField(del_min_distance)
collection.Fields.Add(del_min_distance)
// add
del_min_elevation_gain := &schema.SchemaField{}
del_min_elevation_gain := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "xjcpg4su",
@@ -257,10 +241,10 @@ func init() {
}`), del_min_elevation_gain); err != nil {
return err
}
collection.Schema.AddField(del_min_elevation_gain)
collection.Fields.Add(del_min_elevation_gain)
// add
del_min_duration := &schema.SchemaField{}
del_min_duration := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "cuj9awlq",
@@ -275,26 +259,26 @@ func init() {
}`), del_min_duration); err != nil {
return err
}
collection.Schema.AddField(del_min_duration)
collection.Fields.Add(del_min_duration)
// remove
collection.Schema.RemoveField("265lcwyn")
collection.Fields.RemoveById("265lcwyn")
// remove
collection.Schema.RemoveField("8udbn3hb")
collection.Fields.RemoveById("8udbn3hb")
// remove
collection.Schema.RemoveField("0mw2f9gg")
collection.Fields.RemoveById("0mw2f9gg")
// remove
collection.Schema.RemoveField("qumwuc7g")
collection.Fields.RemoveById("qumwuc7g")
// remove
collection.Schema.RemoveField("sins29kl")
collection.Fields.RemoveById("sins29kl")
// remove
collection.Schema.RemoveField("dgfnqloa")
collection.Fields.RemoveById("dgfnqloa")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,49 +3,40 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
if err != nil {
return err
}
options := map[string]any{}
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)
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;"
// remove
collection.Schema.RemoveField("265lcwyn")
collection.Fields.RemoveById("265lcwyn")
// remove
collection.Schema.RemoveField("8udbn3hb")
collection.Fields.RemoveById("8udbn3hb")
// remove
collection.Schema.RemoveField("0mw2f9gg")
collection.Fields.RemoveById("0mw2f9gg")
// remove
collection.Schema.RemoveField("qumwuc7g")
collection.Fields.RemoveById("qumwuc7g")
// remove
collection.Schema.RemoveField("sins29kl")
collection.Fields.RemoveById("sins29kl")
// remove
collection.Schema.RemoveField("dgfnqloa")
collection.Fields.RemoveById("dgfnqloa")
// add
new_max_distance := &schema.SchemaField{}
new_max_distance := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "jahzab8l",
@@ -60,10 +51,10 @@ func init() {
}`), new_max_distance); err != nil {
return err
}
collection.Schema.AddField(new_max_distance)
collection.Fields.Add(new_max_distance)
// add
new_max_elevation_gain := &schema.SchemaField{}
new_max_elevation_gain := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "hz8wiojq",
@@ -78,10 +69,10 @@ func init() {
}`), new_max_elevation_gain); err != nil {
return err
}
collection.Schema.AddField(new_max_elevation_gain)
collection.Fields.Add(new_max_elevation_gain)
// add
new_max_duration := &schema.SchemaField{}
new_max_duration := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "mhdukuxo",
@@ -96,10 +87,10 @@ func init() {
}`), new_max_duration); err != nil {
return err
}
collection.Schema.AddField(new_max_duration)
collection.Fields.Add(new_max_duration)
// add
new_min_distance := &schema.SchemaField{}
new_min_distance := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "yl7yh4fi",
@@ -114,10 +105,10 @@ func init() {
}`), new_min_distance); err != nil {
return err
}
collection.Schema.AddField(new_min_distance)
collection.Fields.Add(new_min_distance)
// add
new_min_elevation_gain := &schema.SchemaField{}
new_min_elevation_gain := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "mmdluwag",
@@ -132,10 +123,10 @@ func init() {
}`), new_min_elevation_gain); err != nil {
return err
}
collection.Schema.AddField(new_min_elevation_gain)
collection.Fields.Add(new_min_elevation_gain)
// add
new_min_duration := &schema.SchemaField{}
new_min_duration := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "rruyzzld",
@@ -150,13 +141,12 @@ func init() {
}`), new_min_duration); err != nil {
return err
}
collection.Schema.AddField(new_min_duration)
collection.Fields.Add(new_min_duration)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
if err != nil {
return err
}
@@ -167,10 +157,10 @@ func init() {
}`), &options); err != nil {
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
del_max_distance := &schema.SchemaField{}
del_max_distance := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "265lcwyn",
@@ -185,10 +175,10 @@ func init() {
}`), del_max_distance); err != nil {
return err
}
collection.Schema.AddField(del_max_distance)
collection.Fields.Add(del_max_distance)
// add
del_max_elevation_gain := &schema.SchemaField{}
del_max_elevation_gain := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "8udbn3hb",
@@ -203,10 +193,10 @@ func init() {
}`), del_max_elevation_gain); err != nil {
return err
}
collection.Schema.AddField(del_max_elevation_gain)
collection.Fields.Add(del_max_elevation_gain)
// add
del_max_duration := &schema.SchemaField{}
del_max_duration := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "0mw2f9gg",
@@ -221,10 +211,10 @@ func init() {
}`), del_max_duration); err != nil {
return err
}
collection.Schema.AddField(del_max_duration)
collection.Fields.Add(del_max_duration)
// add
del_min_distance := &schema.SchemaField{}
del_min_distance := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "qumwuc7g",
@@ -239,10 +229,10 @@ func init() {
}`), del_min_distance); err != nil {
return err
}
collection.Schema.AddField(del_min_distance)
collection.Fields.Add(del_min_distance)
// add
del_min_elevation_gain := &schema.SchemaField{}
del_min_elevation_gain := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "sins29kl",
@@ -257,10 +247,10 @@ func init() {
}`), del_min_elevation_gain); err != nil {
return err
}
collection.Schema.AddField(del_min_elevation_gain)
collection.Fields.Add(del_min_elevation_gain)
// add
del_min_duration := &schema.SchemaField{}
del_min_duration := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "dgfnqloa",
@@ -275,26 +265,26 @@ func init() {
}`), del_min_duration); err != nil {
return err
}
collection.Schema.AddField(del_min_duration)
collection.Fields.Add(del_min_duration)
// remove
collection.Schema.RemoveField("jahzab8l")
collection.Fields.RemoveById("jahzab8l")
// remove
collection.Schema.RemoveField("hz8wiojq")
collection.Fields.RemoveById("hz8wiojq")
// remove
collection.Schema.RemoveField("mhdukuxo")
collection.Fields.RemoveById("mhdukuxo")
// remove
collection.Schema.RemoveField("yl7yh4fi")
collection.Fields.RemoveById("yl7yh4fi")
// remove
collection.Schema.RemoveField("mmdluwag")
collection.Fields.RemoveById("mmdluwag")
// remove
collection.Schema.RemoveField("rruyzzld")
collection.Fields.RemoveById("rruyzzld")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,49 +3,40 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
if err != nil {
return err
}
options := map[string]any{}
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)
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;"
// remove
collection.Schema.RemoveField("jahzab8l")
collection.Fields.RemoveById("jahzab8l")
// remove
collection.Schema.RemoveField("hz8wiojq")
collection.Fields.RemoveById("hz8wiojq")
// remove
collection.Schema.RemoveField("mhdukuxo")
collection.Fields.RemoveById("mhdukuxo")
// remove
collection.Schema.RemoveField("yl7yh4fi")
collection.Fields.RemoveById("yl7yh4fi")
// remove
collection.Schema.RemoveField("mmdluwag")
collection.Fields.RemoveById("mmdluwag")
// remove
collection.Schema.RemoveField("rruyzzld")
collection.Fields.RemoveById("rruyzzld")
// add
new_max_distance := &schema.SchemaField{}
new_max_distance := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "n42yecz5",
@@ -60,10 +51,10 @@ func init() {
}`), new_max_distance); err != nil {
return err
}
collection.Schema.AddField(new_max_distance)
collection.Fields.Add(new_max_distance)
// add
new_max_elevation_gain := &schema.SchemaField{}
new_max_elevation_gain := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "de8wl3e5",
@@ -78,10 +69,10 @@ func init() {
}`), new_max_elevation_gain); err != nil {
return err
}
collection.Schema.AddField(new_max_elevation_gain)
collection.Fields.Add(new_max_elevation_gain)
// add
new_max_duration := &schema.SchemaField{}
new_max_duration := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "lqhk4k6e",
@@ -96,10 +87,10 @@ func init() {
}`), new_max_duration); err != nil {
return err
}
collection.Schema.AddField(new_max_duration)
collection.Fields.Add(new_max_duration)
// add
new_min_distance := &schema.SchemaField{}
new_min_distance := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "ug5lh6ku",
@@ -114,10 +105,10 @@ func init() {
}`), new_min_distance); err != nil {
return err
}
collection.Schema.AddField(new_min_distance)
collection.Fields.Add(new_min_distance)
// add
new_min_elevation_gain := &schema.SchemaField{}
new_min_elevation_gain := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "lkrr7zr4",
@@ -132,10 +123,10 @@ func init() {
}`), new_min_elevation_gain); err != nil {
return err
}
collection.Schema.AddField(new_min_elevation_gain)
collection.Fields.Add(new_min_elevation_gain)
// add
new_min_duration := &schema.SchemaField{}
new_min_duration := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "sxhh02md",
@@ -150,27 +141,25 @@ func init() {
}`), new_min_duration); err != nil {
return err
}
collection.Schema.AddField(new_min_duration)
collection.Fields.Add(new_min_duration)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
if err != nil {
return err
}
options := map[string]any{}
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)
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
del_max_distance := &schema.SchemaField{}
del_max_distance := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "jahzab8l",
@@ -185,10 +174,10 @@ func init() {
}`), del_max_distance); err != nil {
return err
}
collection.Schema.AddField(del_max_distance)
collection.Fields.Add(del_max_distance)
// add
del_max_elevation_gain := &schema.SchemaField{}
del_max_elevation_gain := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "hz8wiojq",
@@ -203,10 +192,10 @@ func init() {
}`), del_max_elevation_gain); err != nil {
return err
}
collection.Schema.AddField(del_max_elevation_gain)
collection.Fields.Add(del_max_elevation_gain)
// add
del_max_duration := &schema.SchemaField{}
del_max_duration := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "mhdukuxo",
@@ -221,10 +210,10 @@ func init() {
}`), del_max_duration); err != nil {
return err
}
collection.Schema.AddField(del_max_duration)
collection.Fields.Add(del_max_duration)
// add
del_min_distance := &schema.SchemaField{}
del_min_distance := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "yl7yh4fi",
@@ -239,10 +228,10 @@ func init() {
}`), del_min_distance); err != nil {
return err
}
collection.Schema.AddField(del_min_distance)
collection.Fields.Add(del_min_distance)
// add
del_min_elevation_gain := &schema.SchemaField{}
del_min_elevation_gain := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "mmdluwag",
@@ -257,10 +246,10 @@ func init() {
}`), del_min_elevation_gain); err != nil {
return err
}
collection.Schema.AddField(del_min_elevation_gain)
collection.Fields.Add(del_min_elevation_gain)
// add
del_min_duration := &schema.SchemaField{}
del_min_duration := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "rruyzzld",
@@ -275,26 +264,26 @@ func init() {
}`), del_min_duration); err != nil {
return err
}
collection.Schema.AddField(del_min_duration)
collection.Fields.Add(del_min_duration)
// remove
collection.Schema.RemoveField("n42yecz5")
collection.Fields.RemoveById("n42yecz5")
// remove
collection.Schema.RemoveField("de8wl3e5")
collection.Fields.RemoveById("de8wl3e5")
// remove
collection.Schema.RemoveField("lqhk4k6e")
collection.Fields.RemoveById("lqhk4k6e")
// remove
collection.Schema.RemoveField("ug5lh6ku")
collection.Fields.RemoveById("ug5lh6ku")
// remove
collection.Schema.RemoveField("lkrr7zr4")
collection.Fields.RemoveById("lkrr7zr4")
// remove
collection.Schema.RemoveField("sxhh02md")
collection.Fields.RemoveById("sxhh02md")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -1,34 +1,31 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
if err != nil {
return err
}
collection.ListRule = types.Pointer("@request.auth.id != \"\"")
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
if err != nil {
return err
}
collection.ListRule = types.Pointer("id = @request.auth.id")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -1,34 +1,31 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
if err != nil {
return err
}
collection.ViewRule = types.Pointer("@request.auth.id != \"\"")
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
if err != nil {
return err
}
collection.ViewRule = types.Pointer("id = @request.auth.id")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,23 +3,20 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
if err != nil {
return err
}
// add
new_date := &schema.SchemaField{}
new_date := &core.DateField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "hovyvbtt",
@@ -35,20 +32,19 @@ func init() {
}`), new_date); err != nil {
return err
}
collection.Schema.AddField(new_date)
collection.Fields.Add(new_date)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
if err != nil {
return err
}
// remove
collection.Schema.RemoveField("hovyvbtt")
collection.Fields.RemoveById("hovyvbtt")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -1,17 +1,15 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
if err != nil {
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)")
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
if err != nil {
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")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -1,17 +1,15 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
if err != nil {
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)")
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
if err != nil {
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)")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,14 +3,12 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models"
)
func init() {
m.Register(func(db dbx.Builder) error {
m.Register(func(app core.App) error {
jsonData := `{
"id": "uavt73rsqcn1n13",
"created": "2024-04-13 13:54:26.023Z",
@@ -111,20 +109,19 @@ func init() {
"options": {}
}`
collection := &models.Collection{}
collection := &core.Collection{}
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
return err
}
return daos.New(db).SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db)
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("uavt73rsqcn1n13")
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
if err != nil {
return err
}
return dao.DeleteCollection(collection)
return app.Delete(collection)
})
}

View File

@@ -3,48 +3,44 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db)
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
if err != nil {
return err
}
// remove
collection.Schema.RemoveField("wjofulpg")
collection.Fields.RemoveById("wjofulpg")
// remove
collection.Schema.RemoveField("t1wlsqyp")
collection.Fields.RemoveById("t1wlsqyp")
// remove
collection.Schema.RemoveField("fhxhln9g")
collection.Fields.RemoveById("fhxhln9g")
// 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 {
return err
}
settingsCollection, err := dao.FindCollectionByNameOrId("settings")
settingsCollection, err := app.FindCollectionByNameOrId("settings")
if err != nil {
return err
}
for _, user := range users {
settings := models.NewRecord(settingsCollection)
settings := core.NewRecord(settingsCollection)
language := user.Get("language")
unit := user.Get("unit")
location := user.Get("location")
@@ -53,22 +49,21 @@ func init() {
settings.Set("location", location)
settings.Set("user", user.Id)
settings.Set("mapFocus", "location")
if err := dao.SaveRecord(settings); err != nil {
if err := app.Save(settings); err != nil {
return err
}
}
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db)
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
if err != nil {
return err
}
// add
del_unit := &schema.SchemaField{}
del_unit := &core.SelectField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "wjofulpg",
@@ -87,10 +82,10 @@ func init() {
}`), del_unit); err != nil {
return err
}
collection.Schema.AddField(del_unit)
collection.Fields.Add(del_unit)
// add
del_language := &schema.SchemaField{}
del_language := &core.SelectField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "t1wlsqyp",
@@ -115,10 +110,10 @@ func init() {
}`), del_language); err != nil {
return err
}
collection.Schema.AddField(del_language)
collection.Fields.Add(del_language)
// add
del_mapView := &schema.SchemaField{}
del_mapView := &core.SelectField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "fhxhln9g",
@@ -137,10 +132,10 @@ func init() {
}`), del_mapView); err != nil {
return err
}
collection.Schema.AddField(del_mapView)
collection.Fields.Add(del_mapView)
// add
del_location := &schema.SchemaField{}
del_location := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "wosrk4ue",
@@ -155,8 +150,8 @@ func init() {
}`), del_location); err != nil {
return err
}
collection.Schema.AddField(del_location)
collection.Fields.Add(del_location)
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -1,17 +1,15 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("uavt73rsqcn1n13")
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
if err != nil {
return err
}
@@ -24,11 +22,10 @@ func init() {
collection.UpdateRule = types.Pointer("user = @request.auth.id")
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("uavt73rsqcn1n13")
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
if err != nil {
return err
}
@@ -41,6 +38,6 @@ func init() {
collection.UpdateRule = nil
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,14 +3,12 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models"
)
func init() {
m.Register(func(db dbx.Builder) error {
m.Register(func(app core.App) error {
jsonData := `{
"id": "urytyc428mwlbqq",
"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 {
return err
}
return daos.New(db).SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db)
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("urytyc428mwlbqq")
collection, err := app.FindCollectionByNameOrId("urytyc428mwlbqq")
if err != nil {
return err
}
return dao.DeleteCollection(collection)
return app.Delete(collection)
})
}

View File

@@ -3,18 +3,15 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("urytyc428mwlbqq")
collection, err := app.FindCollectionByNameOrId("urytyc428mwlbqq")
if err != nil {
return err
}
@@ -22,19 +19,19 @@ func init() {
collection.ViewRule = types.Pointer("@request.auth.id = id")
// remove
collection.Schema.RemoveField("iyhsoisl")
collection.Fields.RemoveById("iyhsoisl")
// remove
collection.Schema.RemoveField("kx2qfztr")
collection.Fields.RemoveById("kx2qfztr")
// remove
collection.Schema.RemoveField("z4qsnjeb")
collection.Fields.RemoveById("z4qsnjeb")
// remove
collection.Schema.RemoveField("p66xomdb")
collection.Fields.RemoveById("p66xomdb")
// add
new_max_lat := &schema.SchemaField{}
new_max_lat := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "osfey1yx",
@@ -49,10 +46,10 @@ func init() {
}`), new_max_lat); err != nil {
return err
}
collection.Schema.AddField(new_max_lat)
collection.Fields.Add(new_max_lat)
// add
new_max_lon := &schema.SchemaField{}
new_max_lon := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "eohslzky",
@@ -67,10 +64,10 @@ func init() {
}`), new_max_lon); err != nil {
return err
}
collection.Schema.AddField(new_max_lon)
collection.Fields.Add(new_max_lon)
// add
new_min_lat := &schema.SchemaField{}
new_min_lat := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "kigvankd",
@@ -85,10 +82,10 @@ func init() {
}`), new_min_lat); err != nil {
return err
}
collection.Schema.AddField(new_min_lat)
collection.Fields.Add(new_min_lat)
// add
new_min_lon := &schema.SchemaField{}
new_min_lon := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "ifnks9mg",
@@ -103,13 +100,12 @@ func init() {
}`), new_min_lon); err != nil {
return err
}
collection.Schema.AddField(new_min_lon)
collection.Fields.Add(new_min_lon)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("urytyc428mwlbqq")
collection, err := app.FindCollectionByNameOrId("urytyc428mwlbqq")
if err != nil {
return err
}
@@ -117,7 +113,7 @@ func init() {
collection.ViewRule = nil
// add
del_max_lat := &schema.SchemaField{}
del_max_lat := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "iyhsoisl",
@@ -132,10 +128,10 @@ func init() {
}`), del_max_lat); err != nil {
return err
}
collection.Schema.AddField(del_max_lat)
collection.Fields.Add(del_max_lat)
// add
del_max_lon := &schema.SchemaField{}
del_max_lon := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "kx2qfztr",
@@ -150,10 +146,10 @@ func init() {
}`), del_max_lon); err != nil {
return err
}
collection.Schema.AddField(del_max_lon)
collection.Fields.Add(del_max_lon)
// add
del_min_lat := &schema.SchemaField{}
del_min_lat := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "z4qsnjeb",
@@ -168,10 +164,10 @@ func init() {
}`), del_min_lat); err != nil {
return err
}
collection.Schema.AddField(del_min_lat)
collection.Fields.Add(del_min_lat)
// add
del_min_lon := &schema.SchemaField{}
del_min_lon := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "p66xomdb",
@@ -186,20 +182,20 @@ func init() {
}`), del_min_lon); err != nil {
return err
}
collection.Schema.AddField(del_min_lon)
collection.Fields.Add(del_min_lon)
// remove
collection.Schema.RemoveField("osfey1yx")
collection.Fields.RemoveById("osfey1yx")
// remove
collection.Schema.RemoveField("eohslzky")
collection.Fields.RemoveById("eohslzky")
// remove
collection.Schema.RemoveField("kigvankd")
collection.Fields.RemoveById("kigvankd")
// remove
collection.Schema.RemoveField("ifnks9mg")
collection.Fields.RemoveById("ifnks9mg")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -1,17 +1,15 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("lf06qip3f4d11yk")
collection, err := app.FindCollectionByNameOrId("lf06qip3f4d11yk")
if err != nil {
return err
}
@@ -26,11 +24,10 @@ func init() {
collection.DeleteRule = types.Pointer("@request.auth.id = author")
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("lf06qip3f4d11yk")
collection, err := app.FindCollectionByNameOrId("lf06qip3f4d11yk")
if err != nil {
return err
}
@@ -45,6 +42,6 @@ func init() {
collection.DeleteRule = types.Pointer("")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -1,17 +1,15 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
if err != nil {
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)")
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
if err != nil {
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")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,14 +3,12 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models"
)
func init() {
m.Register(func(db dbx.Builder) error {
m.Register(func(app core.App) error {
jsonData := `{
"id": "xku110v5a5xbufa",
"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 {
return err
}
return daos.New(db).SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("xku110v5a5xbufa")
collection, err := app.FindCollectionByNameOrId("xku110v5a5xbufa")
if err != nil {
return err
}
return dao.DeleteCollection(collection)
return app.Delete(collection)
})
}

View File

@@ -3,18 +3,15 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db)
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("xku110v5a5xbufa")
collection, err := app.FindCollectionByNameOrId("xku110v5a5xbufa")
if err != nil {
return err
}
@@ -24,10 +21,10 @@ func init() {
collection.ViewRule = types.Pointer("@request.auth.id != \"\"")
// remove
collection.Schema.RemoveField("cknini6y")
collection.Fields.RemoveById("cknini6y")
// add
new_username := &schema.SchemaField{}
new_username := &core.TextField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "qzkmy7nv",
@@ -44,13 +41,12 @@ func init() {
}`), new_username); err != nil {
return err
}
collection.Schema.AddField(new_username)
collection.Fields.Add(new_username)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db)
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("xku110v5a5xbufa")
collection, err := app.FindCollectionByNameOrId("xku110v5a5xbufa")
if err != nil {
return err
}
@@ -60,7 +56,7 @@ func init() {
collection.ViewRule = nil
// add
del_username := &schema.SchemaField{}
del_username := &core.TextField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "cknini6y",
@@ -77,11 +73,11 @@ func init() {
}`), del_username); err != nil {
return err
}
collection.Schema.AddField(del_username)
collection.Fields.Add(del_username)
// remove
collection.Schema.RemoveField("qzkmy7nv")
collection.Fields.RemoveById("qzkmy7nv")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,14 +3,12 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models"
)
func init() {
m.Register(func(db dbx.Builder) error {
m.Register(func(app core.App) error {
jsonData := `{
"id": "1mns8mlal6uf9ku",
"created": "2024-05-09 17:48:01.382Z",
@@ -77,20 +75,19 @@ func init() {
"options": {}
}`
collection := &models.Collection{}
collection := &core.Collection{}
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
return err
}
return daos.New(db).SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("1mns8mlal6uf9ku")
collection, err := app.FindCollectionByNameOrId("1mns8mlal6uf9ku")
if err != nil {
return err
}
return dao.DeleteCollection(collection)
return app.Delete(collection)
})
}

View File

@@ -3,34 +3,25 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("xku110v5a5xbufa")
collection, err := app.FindCollectionByNameOrId("xku110v5a5xbufa")
if err != nil {
return err
}
options := map[string]any{}
if err := json.Unmarshal([]byte(`{
"query": "SELECT id, username, avatar FROM users"
}`), &options); err != nil {
return err
}
collection.SetOptions(options)
collection.ViewQuery = "SELECT id, username, avatar FROM users"
// remove
collection.Schema.RemoveField("qzkmy7nv")
collection.Fields.RemoveById("qzkmy7nv")
// add
new_username := &schema.SchemaField{}
new_username := &core.TextField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "mbokwbb3",
@@ -47,10 +38,10 @@ func init() {
}`), new_username); err != nil {
return err
}
collection.Schema.AddField(new_username)
collection.Fields.Add(new_username)
// add
new_avatar := &schema.SchemaField{}
new_avatar := &core.FileField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "60wozbto",
@@ -75,27 +66,20 @@ func init() {
}`), new_avatar); err != nil {
return err
}
collection.Schema.AddField(new_avatar)
collection.Fields.Add(new_avatar)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("xku110v5a5xbufa")
collection, err := app.FindCollectionByNameOrId("xku110v5a5xbufa")
if err != nil {
return err
}
options := map[string]any{}
if err := json.Unmarshal([]byte(`{
"query": "SELECT id, username FROM users"
}`), &options); err != nil {
return err
}
collection.SetOptions(options)
collection.ViewQuery = "SELECT id, username FROM users"
// add
del_username := &schema.SchemaField{}
del_username := &core.TextField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "qzkmy7nv",
@@ -112,14 +96,14 @@ func init() {
}`), del_username); err != nil {
return err
}
collection.Schema.AddField(del_username)
collection.Fields.Add(del_username)
// remove
collection.Schema.RemoveField("mbokwbb3")
collection.Fields.RemoveById("mbokwbb3")
// remove
collection.Schema.RemoveField("60wozbto")
collection.Fields.RemoveById("60wozbto")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -1,17 +1,15 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
if err != nil {
return err
}
@@ -20,11 +18,10 @@ func init() {
collection.ViewRule = types.Pointer("id = @request.auth.id")
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
if err != nil {
return err
}
@@ -33,6 +30,6 @@ func init() {
collection.ViewRule = types.Pointer("@request.auth.id != \"\"")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -1,17 +1,15 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
if err != nil {
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)")
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
if err != nil {
return err
}
@@ -33,6 +30,6 @@ func init() {
collection.ViewRule = types.Pointer("author = @request.auth.id || public = true")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -1,17 +1,15 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
if err != nil {
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\")")
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
if err != nil {
return err
}
@@ -37,6 +34,6 @@ func init() {
collection.UpdateRule = types.Pointer("author = @request.auth.id ")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -1,17 +1,15 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("1mns8mlal6uf9ku")
collection, err := app.FindCollectionByNameOrId("1mns8mlal6uf9ku")
if err != nil {
return err
}
@@ -20,11 +18,10 @@ func init() {
collection.ViewRule = types.Pointer("trail.author = @request.auth.id || user = @request.auth.id")
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("1mns8mlal6uf9ku")
collection, err := app.FindCollectionByNameOrId("1mns8mlal6uf9ku")
if err != nil {
return err
}
@@ -33,6 +30,6 @@ func init() {
collection.ViewRule = types.Pointer("trail.author = @request.auth.id")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -1,34 +1,31 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
if err != nil {
return err
}
collection.ViewRule = types.Pointer("author = @request.auth.id || public = true || (trail_share_via_trail.user ?= @request.auth.id)")
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
if err != nil {
return err
}
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)
})
}

View File

@@ -1,34 +1,31 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
if err != nil {
return err
}
collection.ListRule = types.Pointer("author = @request.auth.id || public = true || (trail_share_via_trail.user ?= @request.auth.id)")
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
if err != nil {
return err
}
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)
})
}

View File

@@ -1,34 +1,31 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
if err != nil {
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\")")
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
if err != nil {
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\")")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -5,16 +5,15 @@ import (
"pocketbase/util"
"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"
)
func init() {
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{
"_geo", "author", "category", "completed", "date", "difficulty", "distance", "elevation_gain", "public", "shares",
})
@@ -23,18 +22,15 @@ func init() {
return err
}
dao := daos.New(db)
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 {
return err
}
for _, username := range usernames {
record, err := dao.FindAuthRecordByUsername("users", username)
record, err := app.FindFirstRecordByData("users", "username", username)
if err != nil {
return err
}
@@ -51,7 +47,7 @@ func init() {
} else {
record.Set("token", token)
if err := dao.SaveRecord(record); err != nil {
if err := app.Save(record); err != nil {
return err
}
}
@@ -59,7 +55,7 @@ func init() {
}
return nil
}, func(db dbx.Builder) error {
}, func(app core.App) error {
// add down queries...
return nil

View File

@@ -1,17 +1,15 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("lf06qip3f4d11yk")
collection, err := app.FindCollectionByNameOrId("lf06qip3f4d11yk")
if err != nil {
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)")
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("lf06qip3f4d11yk")
collection, err := app.FindCollectionByNameOrId("lf06qip3f4d11yk")
if err != nil {
return err
}
@@ -37,6 +34,6 @@ func init() {
collection.CreateRule = types.Pointer("@request.auth.id != \"\" && (trail.author = @request.auth.id || trail.public = true)")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -1,17 +1,15 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
if err != nil {
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\")")
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
if err != nil {
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\")")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -4,15 +4,15 @@ import (
"os"
"github.com/meilisearch/meilisearch-go"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
)
func init() {
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{
"created", "date", "difficulty", "distance", "elevation_gain", "name",
})
@@ -22,7 +22,7 @@ func init() {
}
return nil
}, func(db dbx.Builder) error {
}, func(app core.App) error {
_, err := client.Index("trails").UpdateSortableAttributes(&[]string{
"created", "difficulty", "distance", "elevation_gain", "name",
})

View File

@@ -3,23 +3,20 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("uavt73rsqcn1n13")
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
if err != nil {
return err
}
// update
edit_language := &schema.SchemaField{}
edit_language := &core.SelectField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "0sepzvkh",
@@ -45,19 +42,18 @@ func init() {
}`), edit_language); err != nil {
return err
}
collection.Schema.AddField(edit_language)
collection.Fields.Add(edit_language)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("uavt73rsqcn1n13")
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
if err != nil {
return err
}
// update
edit_language := &schema.SchemaField{}
edit_language := &core.SelectField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "0sepzvkh",
@@ -82,8 +78,8 @@ func init() {
}`), edit_language); err != nil {
return err
}
collection.Schema.AddField(edit_language)
collection.Fields.Add(edit_language)
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,23 +3,20 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("uavt73rsqcn1n13")
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
if err != nil {
return err
}
// add
new_category := &schema.SchemaField{}
new_category := &core.RelationField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "owlyzl1x",
@@ -38,20 +35,19 @@ func init() {
}`), new_category); err != nil {
return err
}
collection.Schema.AddField(new_category)
collection.Fields.Add(new_category)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("uavt73rsqcn1n13")
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
if err != nil {
return err
}
// remove
collection.Schema.RemoveField("owlyzl1x")
collection.Fields.RemoveById("owlyzl1x")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,23 +3,20 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("uavt73rsqcn1n13")
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
if err != nil {
return err
}
// add
new_tilesets := &schema.SchemaField{}
new_tilesets := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "xdbayoqg",
@@ -34,20 +31,19 @@ func init() {
}`), new_tilesets); err != nil {
return err
}
collection.Schema.AddField(new_tilesets)
collection.Fields.Add(new_tilesets)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("uavt73rsqcn1n13")
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
if err != nil {
return err
}
// remove
collection.Schema.RemoveField("xdbayoqg")
collection.Fields.RemoveById("xdbayoqg")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,23 +3,20 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
if err != nil {
return err
}
// update
edit_photos := &schema.SchemaField{}
edit_photos := &core.FileField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "aqbpyawe",
@@ -45,19 +42,18 @@ func init() {
}`), edit_photos); err != nil {
return err
}
collection.Schema.AddField(edit_photos)
collection.Fields.Add(edit_photos)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
if err != nil {
return err
}
// update
edit_photos := &schema.SchemaField{}
edit_photos := &core.FileField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "aqbpyawe",
@@ -82,8 +78,8 @@ func init() {
}`), edit_photos); err != nil {
return err
}
collection.Schema.AddField(edit_photos)
collection.Fields.Add(edit_photos)
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,14 +3,12 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models"
)
func init() {
m.Register(func(db dbx.Builder) error {
m.Register(func(app core.App) error {
jsonData := `{
"id": "1kot7t9na3hi0gl",
"created": "2024-09-13 12:40:20.308Z",
@@ -77,20 +75,19 @@ func init() {
"options": {}
}`
collection := &models.Collection{}
collection := &core.Collection{}
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
return err
}
return daos.New(db).SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("1kot7t9na3hi0gl")
collection, err := app.FindCollectionByNameOrId("1kot7t9na3hi0gl")
if err != nil {
return err
}
return dao.DeleteCollection(collection)
return app.Delete(collection)
})
}

View File

@@ -1,17 +1,15 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("1kot7t9na3hi0gl")
collection, err := app.FindCollectionByNameOrId("1kot7t9na3hi0gl")
if err != nil {
return err
}
@@ -26,11 +24,10 @@ func init() {
collection.DeleteRule = types.Pointer("list.author = @request.auth.id")
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("1kot7t9na3hi0gl")
collection, err := app.FindCollectionByNameOrId("1kot7t9na3hi0gl")
if err != nil {
return err
}
@@ -45,6 +42,6 @@ func init() {
collection.DeleteRule = nil
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -1,17 +1,15 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("r6gu2ajyidy1x69")
collection, err := app.FindCollectionByNameOrId("r6gu2ajyidy1x69")
if err != nil {
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\")")
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("r6gu2ajyidy1x69")
collection, err := app.FindCollectionByNameOrId("r6gu2ajyidy1x69")
if err != nil {
return err
}
@@ -41,6 +38,6 @@ func init() {
collection.UpdateRule = types.Pointer("author = @request.auth.id ")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,49 +3,40 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
if err != nil {
return err
}
options := map[string]any{}
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)
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;"
// remove
collection.Schema.RemoveField("6tuhuumw")
collection.Fields.RemoveById("6tuhuumw")
// remove
collection.Schema.RemoveField("xarhom23")
collection.Fields.RemoveById("xarhom23")
// remove
collection.Schema.RemoveField("kl9wsxwf")
collection.Fields.RemoveById("kl9wsxwf")
// remove
collection.Schema.RemoveField("ipd1ohgc")
collection.Fields.RemoveById("ipd1ohgc")
// remove
collection.Schema.RemoveField("o4s7acfv")
collection.Fields.RemoveById("o4s7acfv")
// remove
collection.Schema.RemoveField("d9lfg9vd")
collection.Fields.RemoveById("d9lfg9vd")
// add
new_max_distance := &schema.SchemaField{}
new_max_distance := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "ixfa8u8m",
@@ -60,10 +51,10 @@ func init() {
}`), new_max_distance); err != nil {
return err
}
collection.Schema.AddField(new_max_distance)
collection.Fields.Add(new_max_distance)
// add
new_max_elevation_gain := &schema.SchemaField{}
new_max_elevation_gain := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "bhn0jj40",
@@ -78,10 +69,10 @@ func init() {
}`), new_max_elevation_gain); err != nil {
return err
}
collection.Schema.AddField(new_max_elevation_gain)
collection.Fields.Add(new_max_elevation_gain)
// add
new_max_duration := &schema.SchemaField{}
new_max_duration := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "3kujiwzh",
@@ -96,10 +87,10 @@ func init() {
}`), new_max_duration); err != nil {
return err
}
collection.Schema.AddField(new_max_duration)
collection.Fields.Add(new_max_duration)
// add
new_min_distance := &schema.SchemaField{}
new_min_distance := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "yf3zwzn4",
@@ -114,10 +105,10 @@ func init() {
}`), new_min_distance); err != nil {
return err
}
collection.Schema.AddField(new_min_distance)
collection.Fields.Add(new_min_distance)
// add
new_min_elevation_gain := &schema.SchemaField{}
new_min_elevation_gain := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "skvtkith",
@@ -132,10 +123,10 @@ func init() {
}`), new_min_elevation_gain); err != nil {
return err
}
collection.Schema.AddField(new_min_elevation_gain)
collection.Fields.Add(new_min_elevation_gain)
// add
new_min_duration := &schema.SchemaField{}
new_min_duration := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "gydvo1ug",
@@ -150,27 +141,25 @@ func init() {
}`), new_min_duration); err != nil {
return err
}
collection.Schema.AddField(new_min_duration)
collection.Fields.Add(new_min_duration)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
if err != nil {
return err
}
options := map[string]any{}
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 {
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
del_max_distance := &schema.SchemaField{}
del_max_distance := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "6tuhuumw",
@@ -185,10 +174,10 @@ func init() {
}`), del_max_distance); err != nil {
return err
}
collection.Schema.AddField(del_max_distance)
collection.Fields.Add(del_max_distance)
// add
del_max_elevation_gain := &schema.SchemaField{}
del_max_elevation_gain := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "xarhom23",
@@ -203,10 +192,10 @@ func init() {
}`), del_max_elevation_gain); err != nil {
return err
}
collection.Schema.AddField(del_max_elevation_gain)
collection.Fields.Add(del_max_elevation_gain)
// add
del_max_duration := &schema.SchemaField{}
del_max_duration := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "kl9wsxwf",
@@ -221,10 +210,10 @@ func init() {
}`), del_max_duration); err != nil {
return err
}
collection.Schema.AddField(del_max_duration)
collection.Fields.Add(del_max_duration)
// add
del_min_distance := &schema.SchemaField{}
del_min_distance := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "ipd1ohgc",
@@ -239,10 +228,10 @@ func init() {
}`), del_min_distance); err != nil {
return err
}
collection.Schema.AddField(del_min_distance)
collection.Fields.Add(del_min_distance)
// add
del_min_elevation_gain := &schema.SchemaField{}
del_min_elevation_gain := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "o4s7acfv",
@@ -257,10 +246,10 @@ func init() {
}`), del_min_elevation_gain); err != nil {
return err
}
collection.Schema.AddField(del_min_elevation_gain)
collection.Fields.Add(del_min_elevation_gain)
// add
del_min_duration := &schema.SchemaField{}
del_min_duration := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "d9lfg9vd",
@@ -275,26 +264,26 @@ func init() {
}`), del_min_duration); err != nil {
return err
}
collection.Schema.AddField(del_min_duration)
collection.Fields.Add(del_min_duration)
// remove
collection.Schema.RemoveField("ixfa8u8m")
collection.Fields.RemoveById("ixfa8u8m")
// remove
collection.Schema.RemoveField("bhn0jj40")
collection.Fields.RemoveById("bhn0jj40")
// remove
collection.Schema.RemoveField("3kujiwzh")
collection.Fields.RemoveById("3kujiwzh")
// remove
collection.Schema.RemoveField("yf3zwzn4")
collection.Fields.RemoveById("yf3zwzn4")
// remove
collection.Schema.RemoveField("skvtkith")
collection.Fields.RemoveById("skvtkith")
// remove
collection.Schema.RemoveField("gydvo1ug")
collection.Fields.RemoveById("gydvo1ug")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,23 +3,20 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
if err != nil {
return err
}
// add
new_gpx := &schema.SchemaField{}
new_gpx := &core.FileField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "rfwmdcpt",
@@ -38,20 +35,19 @@ func init() {
}`), new_gpx); err != nil {
return err
}
collection.Schema.AddField(new_gpx)
collection.Fields.Add(new_gpx)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
if err != nil {
return err
}
// remove
collection.Schema.RemoveField("rfwmdcpt")
collection.Fields.RemoveById("rfwmdcpt")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,18 +3,15 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
if err != nil {
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)")
// add
new_author := &schema.SchemaField{}
new_author := &core.RelationField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "r0mj3tkr",
@@ -47,13 +44,12 @@ func init() {
}`), new_author); err != nil {
return err
}
collection.Schema.AddField(new_author)
collection.Fields.Add(new_author)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
if err != nil {
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)")
// remove
collection.Schema.RemoveField("r0mj3tkr")
collection.Fields.RemoveById("r0mj3tkr")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,23 +3,20 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db)
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
if err != nil {
return err
}
// add
new_distance := &schema.SchemaField{}
new_distance := &core.NumberField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "jovws28m",
@@ -36,10 +33,10 @@ func init() {
}`), new_distance); err != nil {
return err
}
collection.Schema.AddField(new_distance)
collection.Fields.Add(new_distance)
// add
new_elevation_gain := &schema.SchemaField{}
new_elevation_gain := &core.NumberField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "m2kndtwn",
@@ -56,10 +53,10 @@ func init() {
}`), new_elevation_gain); err != nil {
return err
}
collection.Schema.AddField(new_elevation_gain)
collection.Fields.Add(new_elevation_gain)
// add
new_elevation_loss := &schema.SchemaField{}
new_elevation_loss := &core.NumberField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "uqqo9cws",
@@ -76,10 +73,10 @@ func init() {
}`), new_elevation_loss); err != nil {
return err
}
collection.Schema.AddField(new_elevation_loss)
collection.Fields.Add(new_elevation_loss)
// add
new_duration := &schema.SchemaField{}
new_duration := &core.NumberField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "vwxjsrae",
@@ -96,29 +93,28 @@ func init() {
}`), new_duration); err != nil {
return err
}
collection.Schema.AddField(new_duration)
collection.Fields.Add(new_duration)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db)
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
if err != nil {
return err
}
// remove
collection.Schema.RemoveField("jovws28m")
collection.Fields.RemoveById("jovws28m")
// remove
collection.Schema.RemoveField("m2kndtwn")
collection.Fields.RemoveById("m2kndtwn")
// remove
collection.Schema.RemoveField("uqqo9cws")
collection.Fields.RemoveById("uqqo9cws")
// remove
collection.Schema.RemoveField("vwxjsrae")
collection.Fields.RemoveById("vwxjsrae")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,23 +3,20 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
if err != nil {
return err
}
// add
new_elevation_loss := &schema.SchemaField{}
new_elevation_loss := &core.NumberField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "xutbwpq4",
@@ -36,20 +33,19 @@ func init() {
}`), new_elevation_loss); err != nil {
return err
}
collection.Schema.AddField(new_elevation_loss)
collection.Fields.Add(new_elevation_loss)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
if err != nil {
return err
}
// remove
collection.Schema.RemoveField("xutbwpq4")
collection.Fields.RemoveById("xutbwpq4")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,49 +3,45 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
if err != nil {
return err
}
options := map[string]any{}
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 {
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
collection.Schema.RemoveField("ixfa8u8m")
collection.Fields.RemoveById("ixfa8u8m")
// remove
collection.Schema.RemoveField("bhn0jj40")
collection.Fields.RemoveById("bhn0jj40")
// remove
collection.Schema.RemoveField("3kujiwzh")
collection.Fields.RemoveById("3kujiwzh")
// remove
collection.Schema.RemoveField("yf3zwzn4")
collection.Fields.RemoveById("yf3zwzn4")
// remove
collection.Schema.RemoveField("skvtkith")
collection.Fields.RemoveById("skvtkith")
// remove
collection.Schema.RemoveField("gydvo1ug")
collection.Fields.RemoveById("gydvo1ug")
// add
new_max_distance := &schema.SchemaField{}
new_max_distance := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "oyvx8oaq",
@@ -60,10 +56,10 @@ func init() {
}`), new_max_distance); err != nil {
return err
}
collection.Schema.AddField(new_max_distance)
collection.Fields.Add(new_max_distance)
// add
new_max_elevation_gain := &schema.SchemaField{}
new_max_elevation_gain := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "4xu7voeh",
@@ -78,10 +74,10 @@ func init() {
}`), new_max_elevation_gain); err != nil {
return err
}
collection.Schema.AddField(new_max_elevation_gain)
collection.Fields.Add(new_max_elevation_gain)
// add
new_max_elevation_loss := &schema.SchemaField{}
new_max_elevation_loss := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "sqzilovv",
@@ -96,10 +92,10 @@ func init() {
}`), new_max_elevation_loss); err != nil {
return err
}
collection.Schema.AddField(new_max_elevation_loss)
collection.Fields.Add(new_max_elevation_loss)
// add
new_max_duration := &schema.SchemaField{}
new_max_duration := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "rupidtew",
@@ -114,10 +110,10 @@ func init() {
}`), new_max_duration); err != nil {
return err
}
collection.Schema.AddField(new_max_duration)
collection.Fields.Add(new_max_duration)
// add
new_min_distance := &schema.SchemaField{}
new_min_distance := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "2y7dbhf9",
@@ -132,10 +128,10 @@ func init() {
}`), new_min_distance); err != nil {
return err
}
collection.Schema.AddField(new_min_distance)
collection.Fields.Add(new_min_distance)
// add
new_min_elevation_gain := &schema.SchemaField{}
new_min_elevation_gain := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "ooiwexpc",
@@ -150,10 +146,10 @@ func init() {
}`), new_min_elevation_gain); err != nil {
return err
}
collection.Schema.AddField(new_min_elevation_gain)
collection.Fields.Add(new_min_elevation_gain)
// add
new_min_elevation_loss := &schema.SchemaField{}
new_min_elevation_loss := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "ondmfwce",
@@ -168,10 +164,10 @@ func init() {
}`), new_min_elevation_loss); err != nil {
return err
}
collection.Schema.AddField(new_min_elevation_loss)
collection.Fields.Add(new_min_elevation_loss)
// add
new_min_duration := &schema.SchemaField{}
new_min_duration := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "kcrhzmaw",
@@ -186,27 +182,25 @@ func init() {
}`), new_min_duration); err != nil {
return err
}
collection.Schema.AddField(new_min_duration)
collection.Fields.Add(new_min_duration)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
if err != nil {
return err
}
options := map[string]any{}
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)
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
del_max_distance := &schema.SchemaField{}
del_max_distance := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "ixfa8u8m",
@@ -221,10 +215,10 @@ func init() {
}`), del_max_distance); err != nil {
return err
}
collection.Schema.AddField(del_max_distance)
collection.Fields.Add(del_max_distance)
// add
del_max_elevation_gain := &schema.SchemaField{}
del_max_elevation_gain := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "bhn0jj40",
@@ -239,10 +233,10 @@ func init() {
}`), del_max_elevation_gain); err != nil {
return err
}
collection.Schema.AddField(del_max_elevation_gain)
collection.Fields.Add(del_max_elevation_gain)
// add
del_max_duration := &schema.SchemaField{}
del_max_duration := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "3kujiwzh",
@@ -257,10 +251,10 @@ func init() {
}`), del_max_duration); err != nil {
return err
}
collection.Schema.AddField(del_max_duration)
collection.Fields.Add(del_max_duration)
// add
del_min_distance := &schema.SchemaField{}
del_min_distance := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "yf3zwzn4",
@@ -275,10 +269,10 @@ func init() {
}`), del_min_distance); err != nil {
return err
}
collection.Schema.AddField(del_min_distance)
collection.Fields.Add(del_min_distance)
// add
del_min_elevation_gain := &schema.SchemaField{}
del_min_elevation_gain := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "skvtkith",
@@ -293,10 +287,10 @@ func init() {
}`), del_min_elevation_gain); err != nil {
return err
}
collection.Schema.AddField(del_min_elevation_gain)
collection.Fields.Add(del_min_elevation_gain)
// add
del_min_duration := &schema.SchemaField{}
del_min_duration := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "gydvo1ug",
@@ -311,32 +305,32 @@ func init() {
}`), del_min_duration); err != nil {
return err
}
collection.Schema.AddField(del_min_duration)
collection.Fields.Add(del_min_duration)
// remove
collection.Schema.RemoveField("oyvx8oaq")
collection.Fields.RemoveById("oyvx8oaq")
// remove
collection.Schema.RemoveField("4xu7voeh")
collection.Fields.RemoveById("4xu7voeh")
// remove
collection.Schema.RemoveField("sqzilovv")
collection.Fields.RemoveById("sqzilovv")
// remove
collection.Schema.RemoveField("rupidtew")
collection.Fields.RemoveById("rupidtew")
// remove
collection.Schema.RemoveField("2y7dbhf9")
collection.Fields.RemoveById("2y7dbhf9")
// remove
collection.Schema.RemoveField("ooiwexpc")
collection.Fields.RemoveById("ooiwexpc")
// remove
collection.Schema.RemoveField("ondmfwce")
collection.Fields.RemoveById("ondmfwce")
// remove
collection.Schema.RemoveField("kcrhzmaw")
collection.Fields.RemoveById("kcrhzmaw")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -4,15 +4,15 @@ import (
"os"
"github.com/meilisearch/meilisearch-go"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
)
func init() {
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{
"created", "date", "difficulty", "distance", "elevation_gain", "elevation_loss", "name",
})
@@ -30,7 +30,7 @@ func init() {
}
return nil
}, func(db dbx.Builder) error {
}, func(app core.App) error {
_, err := client.Index("trails").UpdateSortableAttributes(&[]string{
"created", "date", "difficulty", "distance", "elevation_gain", "name",
})

View File

@@ -1,17 +1,15 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
if err != nil {
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)")
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
if err != nil {
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)")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,37 +3,28 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("xku110v5a5xbufa")
collection, err := app.FindCollectionByNameOrId("xku110v5a5xbufa")
if err != nil {
return err
}
options := map[string]any{}
if err := json.Unmarshal([]byte(`{
"query": "SELECT id, username, avatar, created FROM users"
}`), &options); err != nil {
return err
}
collection.SetOptions(options)
collection.ViewQuery = "SELECT id, username, avatar, created FROM users"
// remove
collection.Schema.RemoveField("ogrxf4ps")
collection.Fields.RemoveById("ogrxf4ps")
// remove
collection.Schema.RemoveField("7k4bozux")
collection.Fields.RemoveById("7k4bozux")
// add
new_username := &schema.SchemaField{}
new_username := &core.TextField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "kvteagv6",
@@ -50,10 +41,10 @@ func init() {
}`), new_username); err != nil {
return err
}
collection.Schema.AddField(new_username)
collection.Fields.Add(new_username)
// add
new_avatar := &schema.SchemaField{}
new_avatar := &core.FileField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "m9efnpak",
@@ -78,27 +69,20 @@ func init() {
}`), new_avatar); err != nil {
return err
}
collection.Schema.AddField(new_avatar)
collection.Fields.Add(new_avatar)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("xku110v5a5xbufa")
collection, err := app.FindCollectionByNameOrId("xku110v5a5xbufa")
if err != nil {
return err
}
options := map[string]any{}
if err := json.Unmarshal([]byte(`{
"query": "SELECT id, username, avatar FROM users"
}`), &options); err != nil {
return err
}
collection.SetOptions(options)
collection.ViewQuery = "SELECT id, username, avatar FROM users"
// add
del_username := &schema.SchemaField{}
del_username := &core.TextField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "ogrxf4ps",
@@ -115,10 +99,10 @@ func init() {
}`), del_username); err != nil {
return err
}
collection.Schema.AddField(del_username)
collection.Fields.Add(del_username)
// add
del_avatar := &schema.SchemaField{}
del_avatar := &core.FileField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "7k4bozux",
@@ -143,14 +127,14 @@ func init() {
}`), del_avatar); err != nil {
return err
}
collection.Schema.AddField(del_avatar)
collection.Fields.Add(del_avatar)
// remove
collection.Schema.RemoveField("kvteagv6")
collection.Fields.RemoveById("kvteagv6")
// remove
collection.Schema.RemoveField("m9efnpak")
collection.Fields.RemoveById("m9efnpak")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -1,34 +1,31 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
if err != nil {
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)")
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9")
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
if err != nil {
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)")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -1,17 +1,15 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
if err != nil {
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)")
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
if err != nil {
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)")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -1,24 +1,19 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db)
settings, err := dao.FindSettings()
m.Register(func(app core.App) error {
if err != nil {
return err
}
settings := app.Settings()
settings.Meta.AppName = "wanderer"
settings.Meta.ResetPasswordTemplate.ActionUrl = "{APP_URL}/auth/confirm-reset/{TOKEN}"
settings.Meta.VerificationTemplate.ActionUrl = "{APP_URL}/auth/confirm-verification/{TOKEN}"
settings.Meta.ConfirmEmailChangeTemplate.ActionUrl = "{APP_URL}/auth/confirm-email-change/{TOKEN}"
// settings.Meta.ResetPasswordTemplate.ActionUrl = "{APP_URL}/auth/confirm-reset/{TOKEN}"
// settings.Meta.VerificationTemplate.ActionUrl = "{APP_URL}/auth/confirm-verification/{TOKEN}"
// settings.Meta.ConfirmEmailChangeTemplate.ActionUrl = "{APP_URL}/auth/confirm-email-change/{TOKEN}"
// settings.meta.verificationTemplate.subject = 'your default subject';
// 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
// "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...
return nil

View File

@@ -3,18 +3,15 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("xku110v5a5xbufa")
collection, err := app.FindCollectionByNameOrId("xku110v5a5xbufa")
if err != nil {
return err
}
@@ -24,13 +21,13 @@ func init() {
collection.ViewRule = types.Pointer("")
// remove
collection.Schema.RemoveField("kvteagv6")
collection.Fields.RemoveById("kvteagv6")
// remove
collection.Schema.RemoveField("m9efnpak")
collection.Fields.RemoveById("m9efnpak")
// add
new_username := &schema.SchemaField{}
new_username := &core.TextField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "femc0ok5",
@@ -47,10 +44,10 @@ func init() {
}`), new_username); err != nil {
return err
}
collection.Schema.AddField(new_username)
collection.Fields.Add(new_username)
// add
new_avatar := &schema.SchemaField{}
new_avatar := &core.FileField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "aglcodpn",
@@ -75,13 +72,12 @@ func init() {
}`), new_avatar); err != nil {
return err
}
collection.Schema.AddField(new_avatar)
collection.Fields.Add(new_avatar)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("xku110v5a5xbufa")
collection, err := app.FindCollectionByNameOrId("xku110v5a5xbufa")
if err != nil {
return err
}
@@ -91,7 +87,7 @@ func init() {
collection.ViewRule = types.Pointer("@request.auth.id != \"\"")
// add
del_username := &schema.SchemaField{}
del_username := &core.TextField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "kvteagv6",
@@ -108,10 +104,10 @@ func init() {
}`), del_username); err != nil {
return err
}
collection.Schema.AddField(del_username)
collection.Fields.Add(del_username)
// add
del_avatar := &schema.SchemaField{}
del_avatar := &core.FileField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "m9efnpak",
@@ -136,14 +132,14 @@ func init() {
}`), del_avatar); err != nil {
return err
}
collection.Schema.AddField(del_avatar)
collection.Fields.Add(del_avatar)
// remove
collection.Schema.RemoveField("femc0ok5")
collection.Fields.RemoveById("femc0ok5")
// remove
collection.Schema.RemoveField("aglcodpn")
collection.Fields.RemoveById("aglcodpn")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,23 +3,20 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
if err != nil {
return err
}
// add
new_photos := &schema.SchemaField{}
new_photos := &core.FileField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "ixnksbkt",
@@ -45,20 +42,19 @@ func init() {
}`), new_photos); err != nil {
return err
}
collection.Schema.AddField(new_photos)
collection.Fields.Add(new_photos)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
if err != nil {
return err
}
// remove
collection.Schema.RemoveField("ixnksbkt")
collection.Fields.RemoveById("ixnksbkt")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,23 +3,20 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("uavt73rsqcn1n13")
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
if err != nil {
return err
}
// add
new_terrain := &schema.SchemaField{}
new_terrain := &core.URLField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "mvxf9llv",
@@ -35,20 +32,19 @@ func init() {
}`), new_terrain); err != nil {
return err
}
collection.Schema.AddField(new_terrain)
collection.Fields.Add(new_terrain)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("uavt73rsqcn1n13")
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
if err != nil {
return err
}
// remove
collection.Schema.RemoveField("mvxf9llv")
collection.Fields.RemoveById("mvxf9llv")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,26 +3,23 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("uavt73rsqcn1n13")
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
if err != nil {
return err
}
// remove
collection.Schema.RemoveField("mvxf9llv")
collection.Fields.RemoveById("mvxf9llv")
// add
new_terrain := &schema.SchemaField{}
new_terrain := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "unsh0qsp",
@@ -37,19 +34,18 @@ func init() {
}`), new_terrain); err != nil {
return err
}
collection.Schema.AddField(new_terrain)
collection.Fields.Add(new_terrain)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("uavt73rsqcn1n13")
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
if err != nil {
return err
}
// add
del_terrain := &schema.SchemaField{}
del_terrain := &core.URLField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "mvxf9llv",
@@ -65,11 +61,11 @@ func init() {
}`), del_terrain); err != nil {
return err
}
collection.Schema.AddField(del_terrain)
collection.Fields.Add(del_terrain)
// remove
collection.Schema.RemoveField("unsh0qsp")
collection.Fields.RemoveById("unsh0qsp")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -4,15 +4,15 @@ import (
"os"
"github.com/meilisearch/meilisearch-go"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
)
func init() {
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{
"created", "date", "difficulty", "distance", "elevation_gain", "elevation_loss", "name", "duration", "author",
})
@@ -22,7 +22,7 @@ func init() {
}
return nil
}, func(db dbx.Builder) error {
}, func(app core.App) error {
_, err := client.Index("trails").UpdateSortableAttributes(&[]string{
"created", "date", "difficulty", "distance", "elevation_gain", "elevation_loss", "name",
})

View File

@@ -3,23 +3,20 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
if err != nil {
return err
}
// add
new_bio := &schema.SchemaField{}
new_bio := &core.TextField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "pd2cq8sq",
@@ -36,20 +33,19 @@ func init() {
}`), new_bio); err != nil {
return err
}
collection.Schema.AddField(new_bio)
collection.Fields.Add(new_bio)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
if err != nil {
return err
}
// remove
collection.Schema.RemoveField("pd2cq8sq")
collection.Fields.RemoveById("pd2cq8sq")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,37 +3,28 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("xku110v5a5xbufa")
collection, err := app.FindCollectionByNameOrId("xku110v5a5xbufa")
if err != nil {
return err
}
options := map[string]any{}
if err := json.Unmarshal([]byte(`{
"query": "SELECT id, username, avatar, bio, created FROM users"
}`), &options); err != nil {
return err
}
collection.SetOptions(options)
collection.ViewQuery = "SELECT id, username, avatar, bio, created FROM users"
// remove
collection.Schema.RemoveField("femc0ok5")
collection.Fields.RemoveById("femc0ok5")
// remove
collection.Schema.RemoveField("aglcodpn")
collection.Fields.RemoveById("aglcodpn")
// add
new_username := &schema.SchemaField{}
new_username := &core.TextField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "tkxbpwxe",
@@ -50,10 +41,10 @@ func init() {
}`), new_username); err != nil {
return err
}
collection.Schema.AddField(new_username)
collection.Fields.Add(new_username)
// add
new_avatar := &schema.SchemaField{}
new_avatar := &core.FileField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "xs5qvkih",
@@ -78,10 +69,10 @@ func init() {
}`), new_avatar); err != nil {
return err
}
collection.Schema.AddField(new_avatar)
collection.Fields.Add(new_avatar)
// add
new_bio := &schema.SchemaField{}
new_bio := &core.TextField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "agsa8h5z",
@@ -98,27 +89,20 @@ func init() {
}`), new_bio); err != nil {
return err
}
collection.Schema.AddField(new_bio)
collection.Fields.Add(new_bio)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("xku110v5a5xbufa")
collection, err := app.FindCollectionByNameOrId("xku110v5a5xbufa")
if err != nil {
return err
}
options := map[string]any{}
if err := json.Unmarshal([]byte(`{
"query": "SELECT id, username, avatar, created FROM users"
}`), &options); err != nil {
return err
}
collection.SetOptions(options)
collection.ViewQuery = "SELECT id, username, avatar, created FROM users"
// add
del_username := &schema.SchemaField{}
del_username := &core.TextField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "femc0ok5",
@@ -135,10 +119,10 @@ func init() {
}`), del_username); err != nil {
return err
}
collection.Schema.AddField(del_username)
collection.Fields.Add(del_username)
// add
del_avatar := &schema.SchemaField{}
del_avatar := &core.FileField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "aglcodpn",
@@ -163,17 +147,17 @@ func init() {
}`), del_avatar); err != nil {
return err
}
collection.Schema.AddField(del_avatar)
collection.Fields.Add(del_avatar)
// remove
collection.Schema.RemoveField("tkxbpwxe")
collection.Fields.RemoveById("tkxbpwxe")
// remove
collection.Schema.RemoveField("xs5qvkih")
collection.Fields.RemoveById("xs5qvkih")
// remove
collection.Schema.RemoveField("agsa8h5z")
collection.Fields.RemoveById("agsa8h5z")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,18 +3,15 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("r6gu2ajyidy1x69")
collection, err := app.FindCollectionByNameOrId("r6gu2ajyidy1x69")
if err != nil {
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)")
// add
new_public := &schema.SchemaField{}
new_public := &core.BoolField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "rolk3q3j",
@@ -37,13 +34,12 @@ func init() {
}`), new_public); err != nil {
return err
}
collection.Schema.AddField(new_public)
collection.Fields.Add(new_public)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("r6gu2ajyidy1x69")
collection, err := app.FindCollectionByNameOrId("r6gu2ajyidy1x69")
if err != nil {
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)")
// remove
collection.Schema.RemoveField("rolk3q3j")
collection.Fields.RemoveById("rolk3q3j")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,14 +3,12 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models"
)
func init() {
m.Register(func(db dbx.Builder) error {
m.Register(func(app core.App) error {
jsonData := `{
"id": "t9lphichi5xwyeu",
"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 {
return err
}
return daos.New(db).SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db)
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("t9lphichi5xwyeu")
collection, err := app.FindCollectionByNameOrId("t9lphichi5xwyeu")
if err != nil {
return err
}
return dao.DeleteCollection(collection)
return app.Delete(collection)
})
}

View File

@@ -3,18 +3,15 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("t9lphichi5xwyeu")
collection, err := app.FindCollectionByNameOrId("t9lphichi5xwyeu")
if err != nil {
return err
}
@@ -24,40 +21,40 @@ func init() {
collection.ViewRule = types.Pointer("")
// remove
collection.Schema.RemoveField("zegqj8bt")
collection.Fields.RemoveById("zegqj8bt")
// remove
collection.Schema.RemoveField("mztv5od5")
collection.Fields.RemoveById("mztv5od5")
// remove
collection.Schema.RemoveField("4hq14mc5")
collection.Fields.RemoveById("4hq14mc5")
// remove
collection.Schema.RemoveField("hbyuxehw")
collection.Fields.RemoveById("hbyuxehw")
// remove
collection.Schema.RemoveField("syp8ya96")
collection.Fields.RemoveById("syp8ya96")
// remove
collection.Schema.RemoveField("rrfp5omm")
collection.Fields.RemoveById("rrfp5omm")
// remove
collection.Schema.RemoveField("tacveduk")
collection.Fields.RemoveById("tacveduk")
// remove
collection.Schema.RemoveField("ydhldat1")
collection.Fields.RemoveById("ydhldat1")
// remove
collection.Schema.RemoveField("9gg24ge8")
collection.Fields.RemoveById("9gg24ge8")
// remove
collection.Schema.RemoveField("ujsn6lqc")
collection.Fields.RemoveById("ujsn6lqc")
// remove
collection.Schema.RemoveField("nvvrulvj")
collection.Fields.RemoveById("nvvrulvj")
// add
new_date := &schema.SchemaField{}
new_date := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "qejtfjom",
@@ -72,10 +69,10 @@ func init() {
}`), new_date); err != nil {
return err
}
collection.Schema.AddField(new_date)
collection.Fields.Add(new_date)
// add
new_name := &schema.SchemaField{}
new_name := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "nskezkjx",
@@ -90,10 +87,10 @@ func init() {
}`), new_name); err != nil {
return err
}
collection.Schema.AddField(new_name)
collection.Fields.Add(new_name)
// add
new_description := &schema.SchemaField{}
new_description := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "viedej4h",
@@ -108,10 +105,10 @@ func init() {
}`), new_description); err != nil {
return err
}
collection.Schema.AddField(new_description)
collection.Fields.Add(new_description)
// add
new_gpx := &schema.SchemaField{}
new_gpx := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "vljhhvdy",
@@ -126,10 +123,10 @@ func init() {
}`), new_gpx); err != nil {
return err
}
collection.Schema.AddField(new_gpx)
collection.Fields.Add(new_gpx)
// add
new_author := &schema.SchemaField{}
new_author := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "z1uaeqzu",
@@ -144,10 +141,10 @@ func init() {
}`), new_author); err != nil {
return err
}
collection.Schema.AddField(new_author)
collection.Fields.Add(new_author)
// add
new_photos := &schema.SchemaField{}
new_photos := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "9nnpyhlq",
@@ -162,10 +159,10 @@ func init() {
}`), new_photos); err != nil {
return err
}
collection.Schema.AddField(new_photos)
collection.Fields.Add(new_photos)
// add
new_distance := &schema.SchemaField{}
new_distance := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "7kzcclzu",
@@ -180,10 +177,10 @@ func init() {
}`), new_distance); err != nil {
return err
}
collection.Schema.AddField(new_distance)
collection.Fields.Add(new_distance)
// add
new_duration := &schema.SchemaField{}
new_duration := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "gwpsktbu",
@@ -198,10 +195,10 @@ func init() {
}`), new_duration); err != nil {
return err
}
collection.Schema.AddField(new_duration)
collection.Fields.Add(new_duration)
// add
new_elevation_gain := &schema.SchemaField{}
new_elevation_gain := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "5tze9ybp",
@@ -216,10 +213,10 @@ func init() {
}`), new_elevation_gain); err != nil {
return err
}
collection.Schema.AddField(new_elevation_gain)
collection.Fields.Add(new_elevation_gain)
// add
new_elevation_loss := &schema.SchemaField{}
new_elevation_loss := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "xkuz8ixp",
@@ -234,10 +231,10 @@ func init() {
}`), new_elevation_loss); err != nil {
return err
}
collection.Schema.AddField(new_elevation_loss)
collection.Fields.Add(new_elevation_loss)
// add
new_type := &schema.SchemaField{}
new_type := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "soylsusn",
@@ -252,13 +249,12 @@ func init() {
}`), new_type); err != nil {
return err
}
collection.Schema.AddField(new_type)
collection.Fields.Add(new_type)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("t9lphichi5xwyeu")
collection, err := app.FindCollectionByNameOrId("t9lphichi5xwyeu")
if err != nil {
return err
}
@@ -268,7 +264,7 @@ func init() {
collection.ViewRule = nil
// add
del_date := &schema.SchemaField{}
del_date := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "zegqj8bt",
@@ -283,10 +279,10 @@ func init() {
}`), del_date); err != nil {
return err
}
collection.Schema.AddField(del_date)
collection.Fields.Add(del_date)
// add
del_name := &schema.SchemaField{}
del_name := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "mztv5od5",
@@ -301,10 +297,10 @@ func init() {
}`), del_name); err != nil {
return err
}
collection.Schema.AddField(del_name)
collection.Fields.Add(del_name)
// add
del_description := &schema.SchemaField{}
del_description := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "4hq14mc5",
@@ -319,10 +315,10 @@ func init() {
}`), del_description); err != nil {
return err
}
collection.Schema.AddField(del_description)
collection.Fields.Add(del_description)
// add
del_gpx := &schema.SchemaField{}
del_gpx := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "hbyuxehw",
@@ -337,10 +333,10 @@ func init() {
}`), del_gpx); err != nil {
return err
}
collection.Schema.AddField(del_gpx)
collection.Fields.Add(del_gpx)
// add
del_author := &schema.SchemaField{}
del_author := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "syp8ya96",
@@ -355,10 +351,10 @@ func init() {
}`), del_author); err != nil {
return err
}
collection.Schema.AddField(del_author)
collection.Fields.Add(del_author)
// add
del_photos := &schema.SchemaField{}
del_photos := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "rrfp5omm",
@@ -373,10 +369,10 @@ func init() {
}`), del_photos); err != nil {
return err
}
collection.Schema.AddField(del_photos)
collection.Fields.Add(del_photos)
// add
del_distance := &schema.SchemaField{}
del_distance := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "tacveduk",
@@ -391,10 +387,10 @@ func init() {
}`), del_distance); err != nil {
return err
}
collection.Schema.AddField(del_distance)
collection.Fields.Add(del_distance)
// add
del_duration := &schema.SchemaField{}
del_duration := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "ydhldat1",
@@ -409,10 +405,10 @@ func init() {
}`), del_duration); err != nil {
return err
}
collection.Schema.AddField(del_duration)
collection.Fields.Add(del_duration)
// add
del_elevation_gain := &schema.SchemaField{}
del_elevation_gain := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "9gg24ge8",
@@ -427,10 +423,10 @@ func init() {
}`), del_elevation_gain); err != nil {
return err
}
collection.Schema.AddField(del_elevation_gain)
collection.Fields.Add(del_elevation_gain)
// add
del_elevation_loss := &schema.SchemaField{}
del_elevation_loss := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "ujsn6lqc",
@@ -445,10 +441,10 @@ func init() {
}`), del_elevation_loss); err != nil {
return err
}
collection.Schema.AddField(del_elevation_loss)
collection.Fields.Add(del_elevation_loss)
// add
del_type := &schema.SchemaField{}
del_type := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "nvvrulvj",
@@ -463,41 +459,41 @@ func init() {
}`), del_type); err != nil {
return err
}
collection.Schema.AddField(del_type)
collection.Fields.Add(del_type)
// remove
collection.Schema.RemoveField("qejtfjom")
collection.Fields.RemoveById("qejtfjom")
// remove
collection.Schema.RemoveField("nskezkjx")
collection.Fields.RemoveById("nskezkjx")
// remove
collection.Schema.RemoveField("viedej4h")
collection.Fields.RemoveById("viedej4h")
// remove
collection.Schema.RemoveField("vljhhvdy")
collection.Fields.RemoveById("vljhhvdy")
// remove
collection.Schema.RemoveField("z1uaeqzu")
collection.Fields.RemoveById("z1uaeqzu")
// remove
collection.Schema.RemoveField("9nnpyhlq")
collection.Fields.RemoveById("9nnpyhlq")
// remove
collection.Schema.RemoveField("7kzcclzu")
collection.Fields.RemoveById("7kzcclzu")
// remove
collection.Schema.RemoveField("gwpsktbu")
collection.Fields.RemoveById("gwpsktbu")
// remove
collection.Schema.RemoveField("5tze9ybp")
collection.Fields.RemoveById("5tze9ybp")
// remove
collection.Schema.RemoveField("xkuz8ixp")
collection.Fields.RemoveById("xkuz8ixp")
// remove
collection.Schema.RemoveField("soylsusn")
collection.Fields.RemoveById("soylsusn")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,64 +3,55 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("t9lphichi5xwyeu")
collection, err := app.FindCollectionByNameOrId("t9lphichi5xwyeu")
if err != nil {
return err
}
options := map[string]any{}
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)
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"
// remove
collection.Schema.RemoveField("qejtfjom")
collection.Fields.RemoveById("qejtfjom")
// remove
collection.Schema.RemoveField("nskezkjx")
collection.Fields.RemoveById("nskezkjx")
// remove
collection.Schema.RemoveField("viedej4h")
collection.Fields.RemoveById("viedej4h")
// remove
collection.Schema.RemoveField("vljhhvdy")
collection.Fields.RemoveById("vljhhvdy")
// remove
collection.Schema.RemoveField("z1uaeqzu")
collection.Fields.RemoveById("z1uaeqzu")
// remove
collection.Schema.RemoveField("9nnpyhlq")
collection.Fields.RemoveById("9nnpyhlq")
// remove
collection.Schema.RemoveField("7kzcclzu")
collection.Fields.RemoveById("7kzcclzu")
// remove
collection.Schema.RemoveField("gwpsktbu")
collection.Fields.RemoveById("gwpsktbu")
// remove
collection.Schema.RemoveField("5tze9ybp")
collection.Fields.RemoveById("5tze9ybp")
// remove
collection.Schema.RemoveField("xkuz8ixp")
collection.Fields.RemoveById("xkuz8ixp")
// remove
collection.Schema.RemoveField("soylsusn")
collection.Fields.RemoveById("soylsusn")
// add
new_trail_id := &schema.SchemaField{}
new_trail_id := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "xbcmb4ax",
@@ -75,10 +66,10 @@ func init() {
}`), new_trail_id); err != nil {
return err
}
collection.Schema.AddField(new_trail_id)
collection.Fields.Add(new_trail_id)
// add
new_date := &schema.SchemaField{}
new_date := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "elenpjfu",
@@ -93,10 +84,10 @@ func init() {
}`), new_date); err != nil {
return err
}
collection.Schema.AddField(new_date)
collection.Fields.Add(new_date)
// add
new_name := &schema.SchemaField{}
new_name := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "gvcm04wv",
@@ -111,10 +102,10 @@ func init() {
}`), new_name); err != nil {
return err
}
collection.Schema.AddField(new_name)
collection.Fields.Add(new_name)
// add
new_description := &schema.SchemaField{}
new_description := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "lzg9ifgi",
@@ -129,10 +120,10 @@ func init() {
}`), new_description); err != nil {
return err
}
collection.Schema.AddField(new_description)
collection.Fields.Add(new_description)
// add
new_gpx := &schema.SchemaField{}
new_gpx := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "rzqpztsp",
@@ -147,10 +138,10 @@ func init() {
}`), new_gpx); err != nil {
return err
}
collection.Schema.AddField(new_gpx)
collection.Fields.Add(new_gpx)
// add
new_author := &schema.SchemaField{}
new_author := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "oqzupzz2",
@@ -165,10 +156,10 @@ func init() {
}`), new_author); err != nil {
return err
}
collection.Schema.AddField(new_author)
collection.Fields.Add(new_author)
// add
new_photos := &schema.SchemaField{}
new_photos := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "xmzmcgjm",
@@ -183,10 +174,10 @@ func init() {
}`), new_photos); err != nil {
return err
}
collection.Schema.AddField(new_photos)
collection.Fields.Add(new_photos)
// add
new_distance := &schema.SchemaField{}
new_distance := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "rslhnvby",
@@ -201,10 +192,10 @@ func init() {
}`), new_distance); err != nil {
return err
}
collection.Schema.AddField(new_distance)
collection.Fields.Add(new_distance)
// add
new_duration := &schema.SchemaField{}
new_duration := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "xgfy26z9",
@@ -219,10 +210,10 @@ func init() {
}`), new_duration); err != nil {
return err
}
collection.Schema.AddField(new_duration)
collection.Fields.Add(new_duration)
// add
new_elevation_gain := &schema.SchemaField{}
new_elevation_gain := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "iuhfh4vo",
@@ -237,10 +228,10 @@ func init() {
}`), new_elevation_gain); err != nil {
return err
}
collection.Schema.AddField(new_elevation_gain)
collection.Fields.Add(new_elevation_gain)
// add
new_elevation_loss := &schema.SchemaField{}
new_elevation_loss := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "hoauojgi",
@@ -255,10 +246,10 @@ func init() {
}`), new_elevation_loss); err != nil {
return err
}
collection.Schema.AddField(new_elevation_loss)
collection.Fields.Add(new_elevation_loss)
// add
new_type := &schema.SchemaField{}
new_type := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "7b25xfwx",
@@ -273,27 +264,20 @@ func init() {
}`), new_type); err != nil {
return err
}
collection.Schema.AddField(new_type)
collection.Fields.Add(new_type)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("t9lphichi5xwyeu")
collection, err := app.FindCollectionByNameOrId("t9lphichi5xwyeu")
if err != nil {
return err
}
options := map[string]any{}
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)
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"
// add
del_date := &schema.SchemaField{}
del_date := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "qejtfjom",
@@ -308,10 +292,10 @@ func init() {
}`), del_date); err != nil {
return err
}
collection.Schema.AddField(del_date)
collection.Fields.Add(del_date)
// add
del_name := &schema.SchemaField{}
del_name := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "nskezkjx",
@@ -326,10 +310,10 @@ func init() {
}`), del_name); err != nil {
return err
}
collection.Schema.AddField(del_name)
collection.Fields.Add(del_name)
// add
del_description := &schema.SchemaField{}
del_description := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "viedej4h",
@@ -344,10 +328,10 @@ func init() {
}`), del_description); err != nil {
return err
}
collection.Schema.AddField(del_description)
collection.Fields.Add(del_description)
// add
del_gpx := &schema.SchemaField{}
del_gpx := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "vljhhvdy",
@@ -362,10 +346,10 @@ func init() {
}`), del_gpx); err != nil {
return err
}
collection.Schema.AddField(del_gpx)
collection.Fields.Add(del_gpx)
// add
del_author := &schema.SchemaField{}
del_author := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "z1uaeqzu",
@@ -380,10 +364,10 @@ func init() {
}`), del_author); err != nil {
return err
}
collection.Schema.AddField(del_author)
collection.Fields.Add(del_author)
// add
del_photos := &schema.SchemaField{}
del_photos := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "9nnpyhlq",
@@ -398,10 +382,10 @@ func init() {
}`), del_photos); err != nil {
return err
}
collection.Schema.AddField(del_photos)
collection.Fields.Add(del_photos)
// add
del_distance := &schema.SchemaField{}
del_distance := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "7kzcclzu",
@@ -416,10 +400,10 @@ func init() {
}`), del_distance); err != nil {
return err
}
collection.Schema.AddField(del_distance)
collection.Fields.Add(del_distance)
// add
del_duration := &schema.SchemaField{}
del_duration := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "gwpsktbu",
@@ -434,10 +418,10 @@ func init() {
}`), del_duration); err != nil {
return err
}
collection.Schema.AddField(del_duration)
collection.Fields.Add(del_duration)
// add
del_elevation_gain := &schema.SchemaField{}
del_elevation_gain := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "5tze9ybp",
@@ -452,10 +436,10 @@ func init() {
}`), del_elevation_gain); err != nil {
return err
}
collection.Schema.AddField(del_elevation_gain)
collection.Fields.Add(del_elevation_gain)
// add
del_elevation_loss := &schema.SchemaField{}
del_elevation_loss := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "xkuz8ixp",
@@ -470,10 +454,10 @@ func init() {
}`), del_elevation_loss); err != nil {
return err
}
collection.Schema.AddField(del_elevation_loss)
collection.Fields.Add(del_elevation_loss)
// add
del_type := &schema.SchemaField{}
del_type := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "soylsusn",
@@ -488,44 +472,44 @@ func init() {
}`), del_type); err != nil {
return err
}
collection.Schema.AddField(del_type)
collection.Fields.Add(del_type)
// remove
collection.Schema.RemoveField("xbcmb4ax")
collection.Fields.RemoveById("xbcmb4ax")
// remove
collection.Schema.RemoveField("elenpjfu")
collection.Fields.RemoveById("elenpjfu")
// remove
collection.Schema.RemoveField("gvcm04wv")
collection.Fields.RemoveById("gvcm04wv")
// remove
collection.Schema.RemoveField("lzg9ifgi")
collection.Fields.RemoveById("lzg9ifgi")
// remove
collection.Schema.RemoveField("rzqpztsp")
collection.Fields.RemoveById("rzqpztsp")
// remove
collection.Schema.RemoveField("oqzupzz2")
collection.Fields.RemoveById("oqzupzz2")
// remove
collection.Schema.RemoveField("xmzmcgjm")
collection.Fields.RemoveById("xmzmcgjm")
// remove
collection.Schema.RemoveField("rslhnvby")
collection.Fields.RemoveById("rslhnvby")
// remove
collection.Schema.RemoveField("xgfy26z9")
collection.Fields.RemoveById("xgfy26z9")
// remove
collection.Schema.RemoveField("iuhfh4vo")
collection.Fields.RemoveById("iuhfh4vo")
// remove
collection.Schema.RemoveField("hoauojgi")
collection.Fields.RemoveById("hoauojgi")
// remove
collection.Schema.RemoveField("7b25xfwx")
collection.Fields.RemoveById("7b25xfwx")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,14 +3,12 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models"
)
func init() {
m.Register(func(db dbx.Builder) error {
m.Register(func(app core.App) error {
jsonData := `{
"id": "8obn1ukumze565i",
"created": "2024-12-14 17:17:00.381Z",
@@ -61,20 +59,19 @@ func init() {
"options": {}
}`
collection := &models.Collection{}
collection := &core.Collection{}
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
return err
}
return daos.New(db).SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db)
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("8obn1ukumze565i")
collection, err := app.FindCollectionByNameOrId("8obn1ukumze565i")
if err != nil {
return err
}
return dao.DeleteCollection(collection)
return app.Delete(collection)
})
}

View File

@@ -3,14 +3,12 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models"
)
func init() {
m.Register(func(db dbx.Builder) error {
m.Register(func(app core.App) error {
jsonData := `{
"id": "j6w72f0kb5ivd7x",
"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 {
return err
}
return daos.New(db).SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db)
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("j6w72f0kb5ivd7x")
collection, err := app.FindCollectionByNameOrId("j6w72f0kb5ivd7x")
if err != nil {
return err
}
return dao.DeleteCollection(collection)
return app.Delete(collection)
})
}

View File

@@ -1,16 +1,12 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models"
)
func init() {
m.Register(func(db dbx.Builder) error {
m.Register(func(app core.App) error {
jsonData := `[
{
"id": "e864strfxo14pm4",
@@ -19,7 +15,7 @@ func init() {
"name": "trails",
"type": "base",
"system": false,
"schema": [
"fields": [
{
"system": false,
"id": "wquvuytd",
@@ -319,7 +315,7 @@ func init() {
"name": "categories",
"type": "base",
"system": false,
"schema": [
"fields": [
{
"system": false,
"id": "38tbd8u4",
@@ -366,7 +362,7 @@ func init() {
"name": "waypoints",
"type": "base",
"system": false,
"schema": [
"fields": [
{
"system": false,
"id": "2yegzjtk",
@@ -491,7 +487,7 @@ func init() {
"name": "summit_logs",
"type": "base",
"system": false,
"schema": [
"fields": [
{
"system": false,
"id": "gxq1yeld",
@@ -646,7 +642,7 @@ func init() {
"name": "lists",
"type": "base",
"system": false,
"schema": [
"fields": [
{
"system": false,
"id": "0goi1ipa",
@@ -755,7 +751,7 @@ func init() {
"name": "trails_filter",
"type": "view",
"system": false,
"schema": [
"fields": [
{
"system": false,
"id": "oyvx8oaq",
@@ -870,7 +866,7 @@ func init() {
"name": "comments",
"type": "base",
"system": false,
"schema": [
"fields": [
{
"system": false,
"id": "0udwb0kl",
@@ -947,7 +943,7 @@ func init() {
"name": "settings",
"type": "base",
"system": false,
"schema": [
"fields": [
{
"system": false,
"id": "0sepzvkh",
@@ -1099,7 +1095,7 @@ func init() {
"name": "trails_bounding_box",
"type": "view",
"system": false,
"schema": [
"fields": [
{
"system": false,
"id": "qtzda9la",
@@ -1166,7 +1162,7 @@ func init() {
"name": "users_anonymous",
"type": "view",
"system": false,
"schema": [
"fields": [
{
"system": false,
"id": "hkdk6yjz",
@@ -1245,7 +1241,7 @@ func init() {
"name": "trail_share",
"type": "base",
"system": false,
"schema": [
"fields": [
{
"system": false,
"id": "eskurfx6",
@@ -1310,7 +1306,7 @@ func init() {
"name": "users",
"type": "auth",
"system": false,
"schema": [
"fields": [
{
"system": false,
"id": "dlzhxcn2",
@@ -1387,7 +1383,7 @@ func init() {
"name": "list_share",
"type": "base",
"system": false,
"schema": [
"fields": [
{
"system": false,
"id": "luqrtipy",
@@ -1452,7 +1448,7 @@ func init() {
"name": "activities",
"type": "view",
"system": false,
"schema": [
"fields": [
{
"system": false,
"id": "7xrdkudh",
@@ -1615,7 +1611,7 @@ func init() {
"name": "follows",
"type": "base",
"system": false,
"schema": [
"fields": [
{
"system": false,
"id": "in1traur",
@@ -1664,7 +1660,7 @@ func init() {
"name": "follow_counts",
"type": "view",
"system": false,
"schema": [
"fields": [
{
"system": false,
"id": "6axn8l2f",
@@ -1702,13 +1698,8 @@ func init() {
}
]`
collections := []*models.Collection{}
if err := json.Unmarshal([]byte(jsonData), &collections); err != nil {
return err
}
return daos.New(db).ImportCollections(collections, true, nil)
}, func(db dbx.Builder) error {
return app.ImportCollectionsByMarshaledJSON([]byte(jsonData), true)
}, func(app core.App) error {
return nil
})
}

View File

@@ -3,14 +3,12 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models"
)
func init() {
m.Register(func(db dbx.Builder) error {
m.Register(func(app core.App) error {
jsonData := `{
"id": "khrcci2uqknny8h",
"created": "2024-12-20 17:33:49.887Z",
@@ -101,20 +99,19 @@ func init() {
"options": {}
}`
collection := &models.Collection{}
collection := &core.Collection{}
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
return err
}
return daos.New(db).SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("khrcci2uqknny8h")
collection, err := app.FindCollectionByNameOrId("khrcci2uqknny8h")
if err != nil {
return err
}
return dao.DeleteCollection(collection)
return app.Delete(collection)
})
}

View File

@@ -3,23 +3,20 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("khrcci2uqknny8h")
collection, err := app.FindCollectionByNameOrId("khrcci2uqknny8h")
if err != nil {
return err
}
// update
edit_type := &schema.SchemaField{}
edit_type := &core.SelectField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "b57prsbu",
@@ -42,19 +39,18 @@ func init() {
}`), edit_type); err != nil {
return err
}
collection.Schema.AddField(edit_type)
collection.Fields.Add(edit_type)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("khrcci2uqknny8h")
collection, err := app.FindCollectionByNameOrId("khrcci2uqknny8h")
if err != nil {
return err
}
// update
edit_type := &schema.SchemaField{}
edit_type := &core.SelectField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "b57prsbu",
@@ -75,8 +71,8 @@ func init() {
}`), edit_type); err != nil {
return err
}
collection.Schema.AddField(edit_type)
collection.Fields.Add(edit_type)
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,23 +3,20 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("uavt73rsqcn1n13")
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
if err != nil {
return err
}
// add
new_notifications := &schema.SchemaField{}
new_notifications := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "sbwmk0q2",
@@ -34,20 +31,19 @@ func init() {
}`), new_notifications); err != nil {
return err
}
collection.Schema.AddField(new_notifications)
collection.Fields.Add(new_notifications)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("uavt73rsqcn1n13")
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
if err != nil {
return err
}
// remove
collection.Schema.RemoveField("sbwmk0q2")
collection.Fields.RemoveById("sbwmk0q2")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -1,34 +1,31 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("khrcci2uqknny8h")
collection, err := app.FindCollectionByNameOrId("khrcci2uqknny8h")
if err != nil {
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")
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("khrcci2uqknny8h")
collection, err := app.FindCollectionByNameOrId("khrcci2uqknny8h")
if err != nil {
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")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,23 +3,20 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("1kot7t9na3hi0gl")
collection, err := app.FindCollectionByNameOrId("1kot7t9na3hi0gl")
if err != nil {
return err
}
// update
edit_list := &schema.SchemaField{}
edit_list := &core.RelationField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "luqrtipy",
@@ -38,19 +35,18 @@ func init() {
}`), edit_list); err != nil {
return err
}
collection.Schema.AddField(edit_list)
collection.Fields.Add(edit_list)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("1kot7t9na3hi0gl")
collection, err := app.FindCollectionByNameOrId("1kot7t9na3hi0gl")
if err != nil {
return err
}
// update
edit_list := &schema.SchemaField{}
edit_list := &core.RelationField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "luqrtipy",
@@ -69,8 +65,8 @@ func init() {
}`), edit_list); err != nil {
return err
}
collection.Schema.AddField(edit_list)
collection.Fields.Add(edit_list)
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,23 +3,20 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("khrcci2uqknny8h")
collection, err := app.FindCollectionByNameOrId("khrcci2uqknny8h")
if err != nil {
return err
}
// update
edit_type := &schema.SchemaField{}
edit_type := &core.SelectField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "b57prsbu",
@@ -42,19 +39,18 @@ func init() {
}`), edit_type); err != nil {
return err
}
collection.Schema.AddField(edit_type)
collection.Fields.Add(edit_type)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("khrcci2uqknny8h")
collection, err := app.FindCollectionByNameOrId("khrcci2uqknny8h")
if err != nil {
return err
}
// update
edit_type := &schema.SchemaField{}
edit_type := &core.SelectField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "b57prsbu",
@@ -77,8 +73,8 @@ func init() {
}`), edit_type); err != nil {
return err
}
collection.Schema.AddField(edit_type)
collection.Fields.Add(edit_type)
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,67 +3,58 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("t9lphichi5xwyeu")
collection, err := app.FindCollectionByNameOrId("t9lphichi5xwyeu")
if err != nil {
return err
}
options := map[string]any{}
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)
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"
// remove
collection.Schema.RemoveField("zmvj8lcq")
collection.Fields.RemoveById("zmvj8lcq")
// remove
collection.Schema.RemoveField("ujwzemal")
collection.Fields.RemoveById("ujwzemal")
// remove
collection.Schema.RemoveField("royuu8hr")
collection.Fields.RemoveById("royuu8hr")
// remove
collection.Schema.RemoveField("e5myhqi1")
collection.Fields.RemoveById("e5myhqi1")
// remove
collection.Schema.RemoveField("twzxntjy")
collection.Fields.RemoveById("twzxntjy")
// remove
collection.Schema.RemoveField("mbgymehy")
collection.Fields.RemoveById("mbgymehy")
// remove
collection.Schema.RemoveField("jvd9zgrj")
collection.Fields.RemoveById("jvd9zgrj")
// remove
collection.Schema.RemoveField("v6t7ybts")
collection.Fields.RemoveById("v6t7ybts")
// remove
collection.Schema.RemoveField("vnddbe3a")
collection.Fields.RemoveById("vnddbe3a")
// remove
collection.Schema.RemoveField("mp9jqukw")
collection.Fields.RemoveById("mp9jqukw")
// remove
collection.Schema.RemoveField("c6zw4l4h")
collection.Fields.RemoveById("c6zw4l4h")
// remove
collection.Schema.RemoveField("njsy8gsh")
collection.Fields.RemoveById("njsy8gsh")
// add
new_trail_id := &schema.SchemaField{}
new_trail_id := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "mpcwfh4x",
@@ -78,10 +69,10 @@ func init() {
}`), new_trail_id); err != nil {
return err
}
collection.Schema.AddField(new_trail_id)
collection.Fields.Add(new_trail_id)
// add
new_date := &schema.SchemaField{}
new_date := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "xsxx8b8a",
@@ -96,10 +87,10 @@ func init() {
}`), new_date); err != nil {
return err
}
collection.Schema.AddField(new_date)
collection.Fields.Add(new_date)
// add
new_name := &schema.SchemaField{}
new_name := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "4ybgblqj",
@@ -114,10 +105,10 @@ func init() {
}`), new_name); err != nil {
return err
}
collection.Schema.AddField(new_name)
collection.Fields.Add(new_name)
// add
new_description := &schema.SchemaField{}
new_description := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "f7y3unyx",
@@ -132,10 +123,10 @@ func init() {
}`), new_description); err != nil {
return err
}
collection.Schema.AddField(new_description)
collection.Fields.Add(new_description)
// add
new_gpx := &schema.SchemaField{}
new_gpx := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "cowkmcyy",
@@ -150,10 +141,10 @@ func init() {
}`), new_gpx); err != nil {
return err
}
collection.Schema.AddField(new_gpx)
collection.Fields.Add(new_gpx)
// add
new_author := &schema.SchemaField{}
new_author := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "dgewwftr",
@@ -168,10 +159,10 @@ func init() {
}`), new_author); err != nil {
return err
}
collection.Schema.AddField(new_author)
collection.Fields.Add(new_author)
// add
new_photos := &schema.SchemaField{}
new_photos := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "ugtikydq",
@@ -186,10 +177,10 @@ func init() {
}`), new_photos); err != nil {
return err
}
collection.Schema.AddField(new_photos)
collection.Fields.Add(new_photos)
// add
new_distance := &schema.SchemaField{}
new_distance := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "gal6bffx",
@@ -204,10 +195,10 @@ func init() {
}`), new_distance); err != nil {
return err
}
collection.Schema.AddField(new_distance)
collection.Fields.Add(new_distance)
// add
new_duration := &schema.SchemaField{}
new_duration := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "kimwtlps",
@@ -222,10 +213,10 @@ func init() {
}`), new_duration); err != nil {
return err
}
collection.Schema.AddField(new_duration)
collection.Fields.Add(new_duration)
// add
new_elevation_gain := &schema.SchemaField{}
new_elevation_gain := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "80vmdusd",
@@ -240,10 +231,10 @@ func init() {
}`), new_elevation_gain); err != nil {
return err
}
collection.Schema.AddField(new_elevation_gain)
collection.Fields.Add(new_elevation_gain)
// add
new_elevation_loss := &schema.SchemaField{}
new_elevation_loss := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "mrq3rozi",
@@ -258,10 +249,10 @@ func init() {
}`), new_elevation_loss); err != nil {
return err
}
collection.Schema.AddField(new_elevation_loss)
collection.Fields.Add(new_elevation_loss)
// add
new_type := &schema.SchemaField{}
new_type := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "i4dy54g8",
@@ -276,27 +267,20 @@ func init() {
}`), new_type); err != nil {
return err
}
collection.Schema.AddField(new_type)
collection.Fields.Add(new_type)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("t9lphichi5xwyeu")
collection, err := app.FindCollectionByNameOrId("t9lphichi5xwyeu")
if err != nil {
return err
}
options := map[string]any{}
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)
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"
// add
del_trail_id := &schema.SchemaField{}
del_trail_id := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "zmvj8lcq",
@@ -311,10 +295,10 @@ func init() {
}`), del_trail_id); err != nil {
return err
}
collection.Schema.AddField(del_trail_id)
collection.Fields.Add(del_trail_id)
// add
del_date := &schema.SchemaField{}
del_date := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "ujwzemal",
@@ -329,10 +313,10 @@ func init() {
}`), del_date); err != nil {
return err
}
collection.Schema.AddField(del_date)
collection.Fields.Add(del_date)
// add
del_name := &schema.SchemaField{}
del_name := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "royuu8hr",
@@ -347,10 +331,10 @@ func init() {
}`), del_name); err != nil {
return err
}
collection.Schema.AddField(del_name)
collection.Fields.Add(del_name)
// add
del_description := &schema.SchemaField{}
del_description := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "e5myhqi1",
@@ -365,10 +349,10 @@ func init() {
}`), del_description); err != nil {
return err
}
collection.Schema.AddField(del_description)
collection.Fields.Add(del_description)
// add
del_gpx := &schema.SchemaField{}
del_gpx := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "twzxntjy",
@@ -383,10 +367,10 @@ func init() {
}`), del_gpx); err != nil {
return err
}
collection.Schema.AddField(del_gpx)
collection.Fields.Add(del_gpx)
// add
del_author := &schema.SchemaField{}
del_author := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "mbgymehy",
@@ -401,10 +385,10 @@ func init() {
}`), del_author); err != nil {
return err
}
collection.Schema.AddField(del_author)
collection.Fields.Add(del_author)
// add
del_photos := &schema.SchemaField{}
del_photos := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "jvd9zgrj",
@@ -419,10 +403,10 @@ func init() {
}`), del_photos); err != nil {
return err
}
collection.Schema.AddField(del_photos)
collection.Fields.Add(del_photos)
// add
del_distance := &schema.SchemaField{}
del_distance := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "v6t7ybts",
@@ -437,10 +421,10 @@ func init() {
}`), del_distance); err != nil {
return err
}
collection.Schema.AddField(del_distance)
collection.Fields.Add(del_distance)
// add
del_duration := &schema.SchemaField{}
del_duration := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "vnddbe3a",
@@ -455,10 +439,10 @@ func init() {
}`), del_duration); err != nil {
return err
}
collection.Schema.AddField(del_duration)
collection.Fields.Add(del_duration)
// add
del_elevation_gain := &schema.SchemaField{}
del_elevation_gain := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "mp9jqukw",
@@ -473,10 +457,10 @@ func init() {
}`), del_elevation_gain); err != nil {
return err
}
collection.Schema.AddField(del_elevation_gain)
collection.Fields.Add(del_elevation_gain)
// add
del_elevation_loss := &schema.SchemaField{}
del_elevation_loss := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "c6zw4l4h",
@@ -491,10 +475,10 @@ func init() {
}`), del_elevation_loss); err != nil {
return err
}
collection.Schema.AddField(del_elevation_loss)
collection.Fields.Add(del_elevation_loss)
// add
del_type := &schema.SchemaField{}
del_type := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "njsy8gsh",
@@ -509,44 +493,44 @@ func init() {
}`), del_type); err != nil {
return err
}
collection.Schema.AddField(del_type)
collection.Fields.Add(del_type)
// remove
collection.Schema.RemoveField("mpcwfh4x")
collection.Fields.RemoveById("mpcwfh4x")
// remove
collection.Schema.RemoveField("xsxx8b8a")
collection.Fields.RemoveById("xsxx8b8a")
// remove
collection.Schema.RemoveField("4ybgblqj")
collection.Fields.RemoveById("4ybgblqj")
// remove
collection.Schema.RemoveField("f7y3unyx")
collection.Fields.RemoveById("f7y3unyx")
// remove
collection.Schema.RemoveField("cowkmcyy")
collection.Fields.RemoveById("cowkmcyy")
// remove
collection.Schema.RemoveField("dgewwftr")
collection.Fields.RemoveById("dgewwftr")
// remove
collection.Schema.RemoveField("ugtikydq")
collection.Fields.RemoveById("ugtikydq")
// remove
collection.Schema.RemoveField("gal6bffx")
collection.Fields.RemoveById("gal6bffx")
// remove
collection.Schema.RemoveField("kimwtlps")
collection.Fields.RemoveById("kimwtlps")
// remove
collection.Schema.RemoveField("80vmdusd")
collection.Fields.RemoveById("80vmdusd")
// remove
collection.Schema.RemoveField("mrq3rozi")
collection.Fields.RemoveById("mrq3rozi")
// remove
collection.Schema.RemoveField("i4dy54g8")
collection.Fields.RemoveById("i4dy54g8")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,67 +3,58 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("t9lphichi5xwyeu")
collection, err := app.FindCollectionByNameOrId("t9lphichi5xwyeu")
if err != nil {
return err
}
options := map[string]any{}
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)
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"
// remove
collection.Schema.RemoveField("mpcwfh4x")
collection.Fields.RemoveById("mpcwfh4x")
// remove
collection.Schema.RemoveField("xsxx8b8a")
collection.Fields.RemoveById("xsxx8b8a")
// remove
collection.Schema.RemoveField("4ybgblqj")
collection.Fields.RemoveById("4ybgblqj")
// remove
collection.Schema.RemoveField("f7y3unyx")
collection.Fields.RemoveById("f7y3unyx")
// remove
collection.Schema.RemoveField("cowkmcyy")
collection.Fields.RemoveById("cowkmcyy")
// remove
collection.Schema.RemoveField("dgewwftr")
collection.Fields.RemoveById("dgewwftr")
// remove
collection.Schema.RemoveField("ugtikydq")
collection.Fields.RemoveById("ugtikydq")
// remove
collection.Schema.RemoveField("gal6bffx")
collection.Fields.RemoveById("gal6bffx")
// remove
collection.Schema.RemoveField("kimwtlps")
collection.Fields.RemoveById("kimwtlps")
// remove
collection.Schema.RemoveField("80vmdusd")
collection.Fields.RemoveById("80vmdusd")
// remove
collection.Schema.RemoveField("mrq3rozi")
collection.Fields.RemoveById("mrq3rozi")
// remove
collection.Schema.RemoveField("i4dy54g8")
collection.Fields.RemoveById("i4dy54g8")
// add
new_trail_id := &schema.SchemaField{}
new_trail_id := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "nsakta5t",
@@ -78,10 +69,10 @@ func init() {
}`), new_trail_id); err != nil {
return err
}
collection.Schema.AddField(new_trail_id)
collection.Fields.Add(new_trail_id)
// add
new_date := &schema.SchemaField{}
new_date := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "oahimwtf",
@@ -96,10 +87,10 @@ func init() {
}`), new_date); err != nil {
return err
}
collection.Schema.AddField(new_date)
collection.Fields.Add(new_date)
// add
new_name := &schema.SchemaField{}
new_name := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "t9nlksmj",
@@ -114,10 +105,10 @@ func init() {
}`), new_name); err != nil {
return err
}
collection.Schema.AddField(new_name)
collection.Fields.Add(new_name)
// add
new_description := &schema.SchemaField{}
new_description := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "fzfiex8c",
@@ -132,10 +123,10 @@ func init() {
}`), new_description); err != nil {
return err
}
collection.Schema.AddField(new_description)
collection.Fields.Add(new_description)
// add
new_gpx := &schema.SchemaField{}
new_gpx := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "1vk5125z",
@@ -150,10 +141,10 @@ func init() {
}`), new_gpx); err != nil {
return err
}
collection.Schema.AddField(new_gpx)
collection.Fields.Add(new_gpx)
// add
new_author := &schema.SchemaField{}
new_author := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "skmgodvs",
@@ -168,10 +159,10 @@ func init() {
}`), new_author); err != nil {
return err
}
collection.Schema.AddField(new_author)
collection.Fields.Add(new_author)
// add
new_photos := &schema.SchemaField{}
new_photos := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "5rkwvgcy",
@@ -186,10 +177,10 @@ func init() {
}`), new_photos); err != nil {
return err
}
collection.Schema.AddField(new_photos)
collection.Fields.Add(new_photos)
// add
new_distance := &schema.SchemaField{}
new_distance := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "xsuyuifg",
@@ -204,10 +195,10 @@ func init() {
}`), new_distance); err != nil {
return err
}
collection.Schema.AddField(new_distance)
collection.Fields.Add(new_distance)
// add
new_duration := &schema.SchemaField{}
new_duration := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "0hsfxjcm",
@@ -222,10 +213,10 @@ func init() {
}`), new_duration); err != nil {
return err
}
collection.Schema.AddField(new_duration)
collection.Fields.Add(new_duration)
// add
new_elevation_gain := &schema.SchemaField{}
new_elevation_gain := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "izyphasx",
@@ -240,10 +231,10 @@ func init() {
}`), new_elevation_gain); err != nil {
return err
}
collection.Schema.AddField(new_elevation_gain)
collection.Fields.Add(new_elevation_gain)
// add
new_elevation_loss := &schema.SchemaField{}
new_elevation_loss := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "bffz6a6t",
@@ -258,10 +249,10 @@ func init() {
}`), new_elevation_loss); err != nil {
return err
}
collection.Schema.AddField(new_elevation_loss)
collection.Fields.Add(new_elevation_loss)
// add
new_type := &schema.SchemaField{}
new_type := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "2xlfylnh",
@@ -276,27 +267,20 @@ func init() {
}`), new_type); err != nil {
return err
}
collection.Schema.AddField(new_type)
collection.Fields.Add(new_type)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("t9lphichi5xwyeu")
collection, err := app.FindCollectionByNameOrId("t9lphichi5xwyeu")
if err != nil {
return err
}
options := map[string]any{}
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)
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"
// add
del_trail_id := &schema.SchemaField{}
del_trail_id := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "mpcwfh4x",
@@ -311,10 +295,10 @@ func init() {
}`), del_trail_id); err != nil {
return err
}
collection.Schema.AddField(del_trail_id)
collection.Fields.Add(del_trail_id)
// add
del_date := &schema.SchemaField{}
del_date := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "xsxx8b8a",
@@ -329,10 +313,10 @@ func init() {
}`), del_date); err != nil {
return err
}
collection.Schema.AddField(del_date)
collection.Fields.Add(del_date)
// add
del_name := &schema.SchemaField{}
del_name := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "4ybgblqj",
@@ -347,10 +331,10 @@ func init() {
}`), del_name); err != nil {
return err
}
collection.Schema.AddField(del_name)
collection.Fields.Add(del_name)
// add
del_description := &schema.SchemaField{}
del_description := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "f7y3unyx",
@@ -365,10 +349,10 @@ func init() {
}`), del_description); err != nil {
return err
}
collection.Schema.AddField(del_description)
collection.Fields.Add(del_description)
// add
del_gpx := &schema.SchemaField{}
del_gpx := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "cowkmcyy",
@@ -383,10 +367,10 @@ func init() {
}`), del_gpx); err != nil {
return err
}
collection.Schema.AddField(del_gpx)
collection.Fields.Add(del_gpx)
// add
del_author := &schema.SchemaField{}
del_author := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "dgewwftr",
@@ -401,10 +385,10 @@ func init() {
}`), del_author); err != nil {
return err
}
collection.Schema.AddField(del_author)
collection.Fields.Add(del_author)
// add
del_photos := &schema.SchemaField{}
del_photos := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "ugtikydq",
@@ -419,10 +403,10 @@ func init() {
}`), del_photos); err != nil {
return err
}
collection.Schema.AddField(del_photos)
collection.Fields.Add(del_photos)
// add
del_distance := &schema.SchemaField{}
del_distance := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "gal6bffx",
@@ -437,10 +421,10 @@ func init() {
}`), del_distance); err != nil {
return err
}
collection.Schema.AddField(del_distance)
collection.Fields.Add(del_distance)
// add
del_duration := &schema.SchemaField{}
del_duration := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "kimwtlps",
@@ -455,10 +439,10 @@ func init() {
}`), del_duration); err != nil {
return err
}
collection.Schema.AddField(del_duration)
collection.Fields.Add(del_duration)
// add
del_elevation_gain := &schema.SchemaField{}
del_elevation_gain := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "80vmdusd",
@@ -473,10 +457,10 @@ func init() {
}`), del_elevation_gain); err != nil {
return err
}
collection.Schema.AddField(del_elevation_gain)
collection.Fields.Add(del_elevation_gain)
// add
del_elevation_loss := &schema.SchemaField{}
del_elevation_loss := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "mrq3rozi",
@@ -491,10 +475,10 @@ func init() {
}`), del_elevation_loss); err != nil {
return err
}
collection.Schema.AddField(del_elevation_loss)
collection.Fields.Add(del_elevation_loss)
// add
del_type := &schema.SchemaField{}
del_type := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "i4dy54g8",
@@ -509,44 +493,44 @@ func init() {
}`), del_type); err != nil {
return err
}
collection.Schema.AddField(del_type)
collection.Fields.Add(del_type)
// remove
collection.Schema.RemoveField("nsakta5t")
collection.Fields.RemoveById("nsakta5t")
// remove
collection.Schema.RemoveField("oahimwtf")
collection.Fields.RemoveById("oahimwtf")
// remove
collection.Schema.RemoveField("t9nlksmj")
collection.Fields.RemoveById("t9nlksmj")
// remove
collection.Schema.RemoveField("fzfiex8c")
collection.Fields.RemoveById("fzfiex8c")
// remove
collection.Schema.RemoveField("1vk5125z")
collection.Fields.RemoveById("1vk5125z")
// remove
collection.Schema.RemoveField("skmgodvs")
collection.Fields.RemoveById("skmgodvs")
// remove
collection.Schema.RemoveField("5rkwvgcy")
collection.Fields.RemoveById("5rkwvgcy")
// remove
collection.Schema.RemoveField("xsuyuifg")
collection.Fields.RemoveById("xsuyuifg")
// remove
collection.Schema.RemoveField("0hsfxjcm")
collection.Fields.RemoveById("0hsfxjcm")
// remove
collection.Schema.RemoveField("izyphasx")
collection.Fields.RemoveById("izyphasx")
// remove
collection.Schema.RemoveField("bffz6a6t")
collection.Fields.RemoveById("bffz6a6t")
// remove
collection.Schema.RemoveField("2xlfylnh")
collection.Fields.RemoveById("2xlfylnh")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -1,34 +1,31 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("khrcci2uqknny8h")
collection, err := app.FindCollectionByNameOrId("khrcci2uqknny8h")
if err != nil {
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")
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("khrcci2uqknny8h")
collection, err := app.FindCollectionByNameOrId("khrcci2uqknny8h")
if err != nil {
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")
return dao.SaveCollection(collection)
return app.Save(collection)
})
}

View File

@@ -3,18 +3,15 @@ package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
m.Register(func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("t9lphichi5xwyeu")
collection, err := app.FindCollectionByNameOrId("t9lphichi5xwyeu")
if err != nil {
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)")
// remove
collection.Schema.RemoveField("nsakta5t")
collection.Fields.RemoveById("nsakta5t")
// remove
collection.Schema.RemoveField("oahimwtf")
collection.Fields.RemoveById("oahimwtf")
// remove
collection.Schema.RemoveField("t9nlksmj")
collection.Fields.RemoveById("t9nlksmj")
// remove
collection.Schema.RemoveField("fzfiex8c")
collection.Fields.RemoveById("fzfiex8c")
// remove
collection.Schema.RemoveField("1vk5125z")
collection.Fields.RemoveById("1vk5125z")
// remove
collection.Schema.RemoveField("skmgodvs")
collection.Fields.RemoveById("skmgodvs")
// remove
collection.Schema.RemoveField("5rkwvgcy")
collection.Fields.RemoveById("5rkwvgcy")
// remove
collection.Schema.RemoveField("xsuyuifg")
collection.Fields.RemoveById("xsuyuifg")
// remove
collection.Schema.RemoveField("0hsfxjcm")
collection.Fields.RemoveById("0hsfxjcm")
// remove
collection.Schema.RemoveField("izyphasx")
collection.Fields.RemoveById("izyphasx")
// remove
collection.Schema.RemoveField("bffz6a6t")
collection.Fields.RemoveById("bffz6a6t")
// remove
collection.Schema.RemoveField("2xlfylnh")
collection.Fields.RemoveById("2xlfylnh")
// add
new_trail_id := &schema.SchemaField{}
new_trail_id := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "1gmbao3t",
@@ -75,10 +72,10 @@ func init() {
}`), new_trail_id); err != nil {
return err
}
collection.Schema.AddField(new_trail_id)
collection.Fields.Add(new_trail_id)
// add
new_date := &schema.SchemaField{}
new_date := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "pvlr9fv1",
@@ -93,10 +90,10 @@ func init() {
}`), new_date); err != nil {
return err
}
collection.Schema.AddField(new_date)
collection.Fields.Add(new_date)
// add
new_name := &schema.SchemaField{}
new_name := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "ueqomhey",
@@ -111,10 +108,10 @@ func init() {
}`), new_name); err != nil {
return err
}
collection.Schema.AddField(new_name)
collection.Fields.Add(new_name)
// add
new_description := &schema.SchemaField{}
new_description := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "chjcbrid",
@@ -129,10 +126,10 @@ func init() {
}`), new_description); err != nil {
return err
}
collection.Schema.AddField(new_description)
collection.Fields.Add(new_description)
// add
new_gpx := &schema.SchemaField{}
new_gpx := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "2wwngiu1",
@@ -147,10 +144,10 @@ func init() {
}`), new_gpx); err != nil {
return err
}
collection.Schema.AddField(new_gpx)
collection.Fields.Add(new_gpx)
// add
new_author := &schema.SchemaField{}
new_author := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "vfbs4wij",
@@ -165,10 +162,10 @@ func init() {
}`), new_author); err != nil {
return err
}
collection.Schema.AddField(new_author)
collection.Fields.Add(new_author)
// add
new_photos := &schema.SchemaField{}
new_photos := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "kpitkmnj",
@@ -183,10 +180,10 @@ func init() {
}`), new_photos); err != nil {
return err
}
collection.Schema.AddField(new_photos)
collection.Fields.Add(new_photos)
// add
new_distance := &schema.SchemaField{}
new_distance := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "90almjd5",
@@ -201,10 +198,10 @@ func init() {
}`), new_distance); err != nil {
return err
}
collection.Schema.AddField(new_distance)
collection.Fields.Add(new_distance)
// add
new_duration := &schema.SchemaField{}
new_duration := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "49io1roa",
@@ -219,10 +216,10 @@ func init() {
}`), new_duration); err != nil {
return err
}
collection.Schema.AddField(new_duration)
collection.Fields.Add(new_duration)
// add
new_elevation_gain := &schema.SchemaField{}
new_elevation_gain := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "kngt1gs1",
@@ -237,10 +234,10 @@ func init() {
}`), new_elevation_gain); err != nil {
return err
}
collection.Schema.AddField(new_elevation_gain)
collection.Fields.Add(new_elevation_gain)
// add
new_elevation_loss := &schema.SchemaField{}
new_elevation_loss := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "faei1oos",
@@ -255,10 +252,10 @@ func init() {
}`), new_elevation_loss); err != nil {
return err
}
collection.Schema.AddField(new_elevation_loss)
collection.Fields.Add(new_elevation_loss)
// add
new_type := &schema.SchemaField{}
new_type := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "fyeket06",
@@ -273,13 +270,12 @@ func init() {
}`), new_type); err != nil {
return err
}
collection.Schema.AddField(new_type)
collection.Fields.Add(new_type)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
return app.Save(collection)
}, func(app core.App) error {
collection, err := dao.FindCollectionByNameOrId("t9lphichi5xwyeu")
collection, err := app.FindCollectionByNameOrId("t9lphichi5xwyeu")
if err != nil {
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)")
// add
del_trail_id := &schema.SchemaField{}
del_trail_id := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "nsakta5t",
@@ -304,10 +300,10 @@ func init() {
}`), del_trail_id); err != nil {
return err
}
collection.Schema.AddField(del_trail_id)
collection.Fields.Add(del_trail_id)
// add
del_date := &schema.SchemaField{}
del_date := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "oahimwtf",
@@ -322,10 +318,10 @@ func init() {
}`), del_date); err != nil {
return err
}
collection.Schema.AddField(del_date)
collection.Fields.Add(del_date)
// add
del_name := &schema.SchemaField{}
del_name := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "t9nlksmj",
@@ -340,10 +336,10 @@ func init() {
}`), del_name); err != nil {
return err
}
collection.Schema.AddField(del_name)
collection.Fields.Add(del_name)
// add
del_description := &schema.SchemaField{}
del_description := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "fzfiex8c",
@@ -358,10 +354,10 @@ func init() {
}`), del_description); err != nil {
return err
}
collection.Schema.AddField(del_description)
collection.Fields.Add(del_description)
// add
del_gpx := &schema.SchemaField{}
del_gpx := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "1vk5125z",
@@ -376,10 +372,10 @@ func init() {
}`), del_gpx); err != nil {
return err
}
collection.Schema.AddField(del_gpx)
collection.Fields.Add(del_gpx)
// add
del_author := &schema.SchemaField{}
del_author := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "skmgodvs",
@@ -394,10 +390,10 @@ func init() {
}`), del_author); err != nil {
return err
}
collection.Schema.AddField(del_author)
collection.Fields.Add(del_author)
// add
del_photos := &schema.SchemaField{}
del_photos := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "5rkwvgcy",
@@ -412,10 +408,10 @@ func init() {
}`), del_photos); err != nil {
return err
}
collection.Schema.AddField(del_photos)
collection.Fields.Add(del_photos)
// add
del_distance := &schema.SchemaField{}
del_distance := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "xsuyuifg",
@@ -430,10 +426,10 @@ func init() {
}`), del_distance); err != nil {
return err
}
collection.Schema.AddField(del_distance)
collection.Fields.Add(del_distance)
// add
del_duration := &schema.SchemaField{}
del_duration := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "0hsfxjcm",
@@ -448,10 +444,10 @@ func init() {
}`), del_duration); err != nil {
return err
}
collection.Schema.AddField(del_duration)
collection.Fields.Add(del_duration)
// add
del_elevation_gain := &schema.SchemaField{}
del_elevation_gain := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "izyphasx",
@@ -466,10 +462,10 @@ func init() {
}`), del_elevation_gain); err != nil {
return err
}
collection.Schema.AddField(del_elevation_gain)
collection.Fields.Add(del_elevation_gain)
// add
del_elevation_loss := &schema.SchemaField{}
del_elevation_loss := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "bffz6a6t",
@@ -484,10 +480,10 @@ func init() {
}`), del_elevation_loss); err != nil {
return err
}
collection.Schema.AddField(del_elevation_loss)
collection.Fields.Add(del_elevation_loss)
// add
del_type := &schema.SchemaField{}
del_type := &core.JSONField{}
if err := json.Unmarshal([]byte(`{
"system": false,
"id": "2xlfylnh",
@@ -502,44 +498,44 @@ func init() {
}`), del_type); err != nil {
return err
}
collection.Schema.AddField(del_type)
collection.Fields.Add(del_type)
// remove
collection.Schema.RemoveField("1gmbao3t")
collection.Fields.RemoveById("1gmbao3t")
// remove
collection.Schema.RemoveField("pvlr9fv1")
collection.Fields.RemoveById("pvlr9fv1")
// remove
collection.Schema.RemoveField("ueqomhey")
collection.Fields.RemoveById("ueqomhey")
// remove
collection.Schema.RemoveField("chjcbrid")
collection.Fields.RemoveById("chjcbrid")
// remove
collection.Schema.RemoveField("2wwngiu1")
collection.Fields.RemoveById("2wwngiu1")
// remove
collection.Schema.RemoveField("vfbs4wij")
collection.Fields.RemoveById("vfbs4wij")
// remove
collection.Schema.RemoveField("kpitkmnj")
collection.Fields.RemoveById("kpitkmnj")
// remove
collection.Schema.RemoveField("90almjd5")
collection.Fields.RemoveById("90almjd5")
// remove
collection.Schema.RemoveField("49io1roa")
collection.Fields.RemoveById("49io1roa")
// remove
collection.Schema.RemoveField("kngt1gs1")
collection.Fields.RemoveById("kngt1gs1")
// remove
collection.Schema.RemoveField("faei1oos")
collection.Fields.RemoveById("faei1oos")
// 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