mirror of
https://github.com/Flomp/wanderer.git
synced 2025-12-19 03:30:50 -06:00
fixes migrations
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -4,7 +4,7 @@
|
||||
db/pocketbase*
|
||||
|
||||
search/meilisearch
|
||||
search/data.ms
|
||||
search/data.ms*
|
||||
search/dumps
|
||||
|
||||
run.sh
|
||||
|
||||
@@ -1,653 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/meilisearch/meilisearch-go"
|
||||
"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(app core.App) error {
|
||||
_, err := client.CreateIndex(&meilisearch.IndexConfig{
|
||||
Uid: "trails",
|
||||
PrimaryKey: "id",
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
jsonData := `[
|
||||
{
|
||||
"id": "_pb_users_auth_",
|
||||
"created": "2024-01-26 15:05:23.262Z",
|
||||
"updated": "2024-02-29 16:52:40.743Z",
|
||||
"name": "users",
|
||||
"type": "auth",
|
||||
"system": false,
|
||||
"fields": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "dlzhxcn2",
|
||||
"name": "token",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "users_avatar",
|
||||
"name": "avatar",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"mimeTypes": [
|
||||
"image/jpeg",
|
||||
"image/png",
|
||||
"image/svg+xml",
|
||||
"image/gif",
|
||||
"image/webp"
|
||||
],
|
||||
"thumbs": null,
|
||||
"maxSelect": 1,
|
||||
"maxSize": 5242880,
|
||||
"protected": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "wjofulpg",
|
||||
"name": "unit",
|
||||
"type": "select",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
"metric",
|
||||
"imperial"
|
||||
]
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "t1wlsqyp",
|
||||
"name": "language",
|
||||
"type": "select",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
"en",
|
||||
"de"
|
||||
]
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "wosrk4ue",
|
||||
"name": "location",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"maxSize": 2000000
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
"listRule": "id = @request.auth.id",
|
||||
"viewRule": "id = @request.auth.id",
|
||||
"createRule": "",
|
||||
"updateRule": "id = @request.auth.id",
|
||||
"deleteRule": "id = @request.auth.id",
|
||||
"options": {
|
||||
"allowEmailAuth": true,
|
||||
"allowOAuth2Auth": true,
|
||||
"allowUsernameAuth": true,
|
||||
"exceptEmailDomains": null,
|
||||
"manageRule": null,
|
||||
"minPasswordLength": 8,
|
||||
"onlyEmailDomains": null,
|
||||
"onlyVerified": false,
|
||||
"requireEmail": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "e864strfxo14pm4",
|
||||
"created": "2024-01-26 18:46:35.843Z",
|
||||
"updated": "2024-02-23 12:47:30.327Z",
|
||||
"name": "trails",
|
||||
"type": "base",
|
||||
"system": false,
|
||||
"fields": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "wquvuytd",
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "6kkucam1",
|
||||
"name": "description",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "8x74ba26",
|
||||
"name": "location",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "ehrmydva",
|
||||
"name": "public",
|
||||
"type": "bool",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "epgmtyxy",
|
||||
"name": "distance",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"min": 0,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "5wxdt3aj",
|
||||
"name": "elevation_gain",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"min": null,
|
||||
"max": null,
|
||||
"onlyInt": true
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "ukr9rqz4",
|
||||
"name": "duration",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"min": 0,
|
||||
"max": null,
|
||||
"onlyInt": true
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "eqeqja1s",
|
||||
"name": "lat",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "y6dbfyw6",
|
||||
"name": "lon",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "mcqce8l9",
|
||||
"name": "thumbnail",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "aqbpyawe",
|
||||
"name": "photos",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"mimeTypes": [
|
||||
"image/jpeg",
|
||||
"image/vnd.mozilla.apng",
|
||||
"image/png",
|
||||
"image/webp",
|
||||
"image/svg+xml"
|
||||
],
|
||||
"thumbs": [],
|
||||
"maxSelect": 99,
|
||||
"maxSize": 5242880,
|
||||
"protected": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "k8xdrsyv",
|
||||
"name": "gpx",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"mimeTypes": [],
|
||||
"thumbs": [],
|
||||
"maxSelect": 1,
|
||||
"maxSize": 5242880,
|
||||
"protected": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "b49obm5u",
|
||||
"name": "category",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "kjxvi8asj2igqwf",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "1utgul91",
|
||||
"name": "author",
|
||||
"type": "relation",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "_pb_users_auth_",
|
||||
"cascadeDelete": true,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "e1lwowvd",
|
||||
"name": "summit_logs",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "dd2l9a4vxpy2ni8",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": null,
|
||||
"displayFields": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "ppq2sist",
|
||||
"name": "waypoints",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "goeo2ubp103rzp9",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": null,
|
||||
"displayFields": null
|
||||
}
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
"listRule": "author = @request.auth.id || public = true",
|
||||
"viewRule": "author = @request.auth.id || public = true",
|
||||
"createRule": "@request.auth.id != \"\" && (@request.data.author = @request.auth.id)",
|
||||
"updateRule": "author = @request.auth.id ",
|
||||
"deleteRule": "author = @request.auth.id ",
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": "kjxvi8asj2igqwf",
|
||||
"created": "2024-01-26 18:47:30.797Z",
|
||||
"updated": "2024-01-27 09:38:36.240Z",
|
||||
"name": "categories",
|
||||
"type": "base",
|
||||
"system": false,
|
||||
"fields": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "38tbd8u4",
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "64dsnxtb",
|
||||
"name": "img",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"mimeTypes": [],
|
||||
"thumbs": [],
|
||||
"maxSelect": 1,
|
||||
"maxSize": 5242880,
|
||||
"protected": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
"listRule": "",
|
||||
"viewRule": "",
|
||||
"createRule": null,
|
||||
"updateRule": null,
|
||||
"deleteRule": null,
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": "goeo2ubp103rzp9",
|
||||
"created": "2024-01-26 18:50:13.695Z",
|
||||
"updated": "2024-02-04 11:49:30.732Z",
|
||||
"name": "waypoints",
|
||||
"type": "base",
|
||||
"system": false,
|
||||
"fields": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "2yegzjtk",
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "3xtcjtxv",
|
||||
"name": "description",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "ygotgxzy",
|
||||
"name": "lat",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "q0ygnxd2",
|
||||
"name": "lon",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "rnjgm2tk",
|
||||
"name": "icon",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
"listRule": "@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)",
|
||||
"viewRule": "@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)",
|
||||
"createRule": "@request.auth.id != \"\"",
|
||||
"updateRule": "@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id)",
|
||||
"deleteRule": "@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id)",
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": "dd2l9a4vxpy2ni8",
|
||||
"created": "2024-01-27 12:23:48.069Z",
|
||||
"updated": "2024-02-02 21:24:15.600Z",
|
||||
"name": "summit_logs",
|
||||
"type": "base",
|
||||
"system": false,
|
||||
"fields": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "gxq1yeld",
|
||||
"name": "date",
|
||||
"type": "date",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": "",
|
||||
"max": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "0ykzwuia",
|
||||
"name": "text",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
"listRule": "@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)",
|
||||
"viewRule": "@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)",
|
||||
"createRule": "@request.auth.id != \"\"",
|
||||
"updateRule": "@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author = @request.auth.id)",
|
||||
"deleteRule": "@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author = @request.auth.id)",
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": "r6gu2ajyidy1x69",
|
||||
"created": "2024-02-27 11:46:07.367Z",
|
||||
"updated": "2024-02-27 13:22:52.195Z",
|
||||
"name": "lists",
|
||||
"type": "base",
|
||||
"system": false,
|
||||
"fields": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "0goi1ipa",
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 1,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "3v3pwnqn",
|
||||
"name": "description",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "decatj0h",
|
||||
"name": "avatar",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"mimeTypes": [
|
||||
"image/png",
|
||||
"image/vnd.mozilla.apng",
|
||||
"image/jpeg",
|
||||
"image/webp",
|
||||
"image/svg+xml"
|
||||
],
|
||||
"thumbs": [],
|
||||
"maxSelect": 1,
|
||||
"maxSize": 5242880,
|
||||
"protected": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "jqtcrcnq",
|
||||
"name": "trails",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "e864strfxo14pm4",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": null,
|
||||
"displayFields": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "kwm6zdet",
|
||||
"name": "author",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "_pb_users_auth_",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": null
|
||||
}
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
"listRule": "author = @request.auth.id ",
|
||||
"viewRule": "author = @request.auth.id ",
|
||||
"createRule": "author = @request.auth.id ",
|
||||
"updateRule": "author = @request.auth.id ",
|
||||
"deleteRule": "author = @request.auth.id ",
|
||||
"options": {}
|
||||
}
|
||||
]`
|
||||
|
||||
return app.ImportCollectionsByMarshaledJSON([]byte(jsonData), true)
|
||||
}, nil)
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("mcqce8l9")
|
||||
|
||||
// add
|
||||
new_thumbnail := &core.NumberField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "k2giqyjq",
|
||||
"name": "thumbnail",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
}`), new_thumbnail)
|
||||
collection.Fields.Add(new_thumbnail)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// add
|
||||
del_thumbnail := &core.TextField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "mcqce8l9",
|
||||
"name": "thumbnail",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
}`), del_thumbnail)
|
||||
collection.Fields.Add(del_thumbnail)
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("k2giqyjq")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// add
|
||||
new_difficulty := &core.SelectField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "dywtnynw",
|
||||
"name": "difficulty",
|
||||
"type": "select",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
"easy",
|
||||
"moderate",
|
||||
"difficult"
|
||||
]
|
||||
}
|
||||
}`), new_difficulty)
|
||||
collection.Fields.Add(new_difficulty)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("dywtnynw")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// add
|
||||
new_photo := &core.FileField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "tfhs3juh",
|
||||
"name": "photo",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"mimeTypes": [
|
||||
"image/jpeg",
|
||||
"image/png",
|
||||
"image/vnd.mozilla.apng",
|
||||
"image/webp",
|
||||
"image/svg+xml"
|
||||
],
|
||||
"thumbs": [],
|
||||
"maxSelect": 1,
|
||||
"maxSize": 5242880,
|
||||
"protected": false
|
||||
}
|
||||
}`), new_photo)
|
||||
collection.Fields.Add(new_photo)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("tfhs3juh")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update
|
||||
edit_photo := &core.FileField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "tfhs3juh",
|
||||
"name": "photo",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"mimeTypes": [
|
||||
"image/jpeg",
|
||||
"image/png",
|
||||
"image/vnd.mozilla.apng",
|
||||
"image/webp",
|
||||
"image/svg+xml"
|
||||
],
|
||||
"thumbs": [],
|
||||
"maxSelect": 99,
|
||||
"maxSize": 5242880,
|
||||
"protected": false
|
||||
}
|
||||
}`), edit_photo)
|
||||
collection.Fields.Add(edit_photo)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update
|
||||
edit_photo := &core.FileField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "tfhs3juh",
|
||||
"name": "photo",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"mimeTypes": [
|
||||
"image/jpeg",
|
||||
"image/png",
|
||||
"image/vnd.mozilla.apng",
|
||||
"image/webp",
|
||||
"image/svg+xml"
|
||||
],
|
||||
"thumbs": [],
|
||||
"maxSelect": 1,
|
||||
"maxSize": 5242880,
|
||||
"protected": false
|
||||
}
|
||||
}`), edit_photo)
|
||||
collection.Fields.Add(edit_photo)
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// add
|
||||
new_author := &core.RelationField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "8qbxrsd8",
|
||||
"name": "author",
|
||||
"type": "relation",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "_pb_users_auth_",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": null
|
||||
}
|
||||
}`), new_author)
|
||||
collection.Fields.Add(new_author)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("8qbxrsd8")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
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)")
|
||||
|
||||
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 app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
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)")
|
||||
|
||||
collection.DeleteRule = types.Pointer("@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id)")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.UpdateRule = types.Pointer("")
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
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 app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
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)")
|
||||
|
||||
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 app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.UpdateRule = types.Pointer("")
|
||||
|
||||
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 app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
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) || @collection.waypoints.author = @request.auth.id)")
|
||||
|
||||
collection.DeleteRule = types.Pointer("@request.auth.id != \"\" && ((@collection.trails.waypoints.id ?= id && @collection.trails.author = @request.auth.id) || @collection.waypoints.author = @request.auth.id)")
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
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)")
|
||||
|
||||
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 app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
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)")
|
||||
|
||||
collection.DeleteRule = types.Pointer("@request.auth.id != \"\" && ((@collection.trails.waypoints.id ?= id && @collection.trails.author = @request.auth.id) || author = @request.auth.id)")
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
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) || @collection.waypoints.author = @request.auth.id)")
|
||||
|
||||
collection.DeleteRule = types.Pointer("@request.auth.id != \"\" && ((@collection.trails.waypoints.id ?= id && @collection.trails.author = @request.auth.id) || @collection.waypoints.author = @request.auth.id)")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update
|
||||
edit_photos := &core.FileField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "tfhs3juh",
|
||||
"name": "photos",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"mimeTypes": [
|
||||
"image/jpeg",
|
||||
"image/png",
|
||||
"image/vnd.mozilla.apng",
|
||||
"image/webp",
|
||||
"image/svg+xml"
|
||||
],
|
||||
"thumbs": [],
|
||||
"maxSelect": 99,
|
||||
"maxSize": 5242880,
|
||||
"protected": false
|
||||
}
|
||||
}`), edit_photos)
|
||||
collection.Fields.Add(edit_photos)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update
|
||||
edit_photos := &core.FileField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "tfhs3juh",
|
||||
"name": "photo",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"mimeTypes": [
|
||||
"image/jpeg",
|
||||
"image/png",
|
||||
"image/vnd.mozilla.apng",
|
||||
"image/webp",
|
||||
"image/svg+xml"
|
||||
],
|
||||
"thumbs": [],
|
||||
"maxSelect": 99,
|
||||
"maxSize": 5242880,
|
||||
"protected": false
|
||||
}
|
||||
}`), edit_photos)
|
||||
collection.Fields.Add(edit_photos)
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.UpdateRule = types.Pointer("")
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
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 app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
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 app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.UpdateRule = types.Pointer("")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
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 app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
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 app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
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 app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
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 app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update
|
||||
edit_language := &core.SelectField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "t1wlsqyp",
|
||||
"name": "language",
|
||||
"type": "select",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
"en",
|
||||
"de",
|
||||
"nl",
|
||||
"pl",
|
||||
"pt"
|
||||
]
|
||||
}
|
||||
}`), edit_language)
|
||||
collection.Fields.Add(edit_language)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update
|
||||
edit_language := &core.SelectField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "t1wlsqyp",
|
||||
"name": "language",
|
||||
"type": "select",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
"en",
|
||||
"de"
|
||||
]
|
||||
}
|
||||
}`), edit_language)
|
||||
collection.Fields.Add(edit_language)
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update
|
||||
edit_language := &core.SelectField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "t1wlsqyp",
|
||||
"name": "language",
|
||||
"type": "select",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
"en",
|
||||
"de",
|
||||
"fr",
|
||||
"nl",
|
||||
"pl",
|
||||
"pt"
|
||||
]
|
||||
}
|
||||
}`), edit_language)
|
||||
collection.Fields.Add(edit_language)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update
|
||||
edit_language := &core.SelectField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "t1wlsqyp",
|
||||
"name": "language",
|
||||
"type": "select",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
"en",
|
||||
"de",
|
||||
"nl",
|
||||
"pl",
|
||||
"pt"
|
||||
]
|
||||
}
|
||||
}`), edit_language)
|
||||
collection.Fields.Add(edit_language)
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update
|
||||
edit_language := &core.SelectField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "t1wlsqyp",
|
||||
"name": "language",
|
||||
"type": "select",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
"en",
|
||||
"de",
|
||||
"fr",
|
||||
"hu",
|
||||
"nl",
|
||||
"pl",
|
||||
"pt"
|
||||
]
|
||||
}
|
||||
}`), edit_language)
|
||||
collection.Fields.Add(edit_language)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update
|
||||
edit_language := &core.SelectField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "t1wlsqyp",
|
||||
"name": "language",
|
||||
"type": "select",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
"en",
|
||||
"de",
|
||||
"fr",
|
||||
"nl",
|
||||
"pl",
|
||||
"pt"
|
||||
]
|
||||
}
|
||||
}`), edit_language)
|
||||
collection.Fields.Add(edit_language)
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
jsonData := `{
|
||||
"id": "4wbv9tz5zjdrjh1",
|
||||
"created": "2024-04-01 17:47:10.015Z",
|
||||
"updated": "2024-04-01 17:47:10.015Z",
|
||||
"name": "trails_filter",
|
||||
"type": "view",
|
||||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "ovledory",
|
||||
"name": "max_distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
"listRule": null,
|
||||
"viewRule": null,
|
||||
"createRule": null,
|
||||
"updateRule": null,
|
||||
"deleteRule": null,
|
||||
"options": {
|
||||
"query": "SELECT (ROW_NUMBER() OVER()) as id, MAX(trails.distance) AS max_distance FROM trails;"
|
||||
}
|
||||
}`
|
||||
|
||||
collection := &core.Collection{}
|
||||
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return app.Delete(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,165 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
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.Fields.RemoveById("ovledory")
|
||||
|
||||
// add
|
||||
new_max_distance := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "3neuurse",
|
||||
"name": "max_distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_max_distance)
|
||||
collection.Fields.Add(new_max_distance)
|
||||
|
||||
// add
|
||||
new_max_elevation_gain := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "oynpksx3",
|
||||
"name": "max_elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_max_elevation_gain)
|
||||
collection.Fields.Add(new_max_elevation_gain)
|
||||
|
||||
// add
|
||||
new_max_duration := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "tkoppkjw",
|
||||
"name": "max_duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_max_duration)
|
||||
collection.Fields.Add(new_max_duration)
|
||||
|
||||
// add
|
||||
new_min_distance := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "uxc0eimu",
|
||||
"name": "min_distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_min_distance)
|
||||
collection.Fields.Add(new_min_distance)
|
||||
|
||||
// add
|
||||
new_min_elevation_gain := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "qcktbht6",
|
||||
"name": "min_elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_min_elevation_gain)
|
||||
collection.Fields.Add(new_min_elevation_gain)
|
||||
|
||||
// add
|
||||
new_min_duration := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "qpkhyujt",
|
||||
"name": "min_duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_min_duration)
|
||||
collection.Fields.Add(new_min_duration)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ViewQuery = "SELECT (ROW_NUMBER() OVER()) as id, MAX(trails.distance) AS max_distance FROM trails;"
|
||||
|
||||
// add
|
||||
del_max_distance := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "ovledory",
|
||||
"name": "max_distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_max_distance)
|
||||
collection.Fields.Add(del_max_distance)
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("3neuurse")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("oynpksx3")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("tkoppkjw")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("uxc0eimu")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("qcktbht6")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("qpkhyujt")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,261 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("@request.auth.id != \"\"")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("3neuurse")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("oynpksx3")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("tkoppkjw")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("uxc0eimu")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("qcktbht6")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("qpkhyujt")
|
||||
|
||||
// add
|
||||
new_max_distance := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "54a1hvuq",
|
||||
"name": "max_distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_max_distance)
|
||||
collection.Fields.Add(new_max_distance)
|
||||
|
||||
// add
|
||||
new_max_elevation_gain := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "stcnunkf",
|
||||
"name": "max_elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_max_elevation_gain)
|
||||
collection.Fields.Add(new_max_elevation_gain)
|
||||
|
||||
// add
|
||||
new_max_duration := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "bholagx7",
|
||||
"name": "max_duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_max_duration)
|
||||
collection.Fields.Add(new_max_duration)
|
||||
|
||||
// add
|
||||
new_min_distance := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "qjrtggwi",
|
||||
"name": "min_distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_min_distance)
|
||||
collection.Fields.Add(new_min_distance)
|
||||
|
||||
// add
|
||||
new_min_elevation_gain := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "wtlhqwd2",
|
||||
"name": "min_elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_min_elevation_gain)
|
||||
collection.Fields.Add(new_min_elevation_gain)
|
||||
|
||||
// add
|
||||
new_min_duration := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "sputfuyq",
|
||||
"name": "min_duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_min_duration)
|
||||
collection.Fields.Add(new_min_duration)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = nil
|
||||
|
||||
// add
|
||||
del_max_distance := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "3neuurse",
|
||||
"name": "max_distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_max_distance)
|
||||
collection.Fields.Add(del_max_distance)
|
||||
|
||||
// add
|
||||
del_max_elevation_gain := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "oynpksx3",
|
||||
"name": "max_elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_max_elevation_gain)
|
||||
collection.Fields.Add(del_max_elevation_gain)
|
||||
|
||||
// add
|
||||
del_max_duration := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "tkoppkjw",
|
||||
"name": "max_duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_max_duration)
|
||||
collection.Fields.Add(del_max_duration)
|
||||
|
||||
// add
|
||||
del_min_distance := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "uxc0eimu",
|
||||
"name": "min_distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_min_distance)
|
||||
collection.Fields.Add(del_min_distance)
|
||||
|
||||
// add
|
||||
del_min_elevation_gain := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "qcktbht6",
|
||||
"name": "min_elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_min_elevation_gain)
|
||||
collection.Fields.Add(del_min_elevation_gain)
|
||||
|
||||
// add
|
||||
del_min_duration := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "qpkhyujt",
|
||||
"name": "min_duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_min_duration)
|
||||
collection.Fields.Add(del_min_duration)
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("54a1hvuq")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("stcnunkf")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("bholagx7")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("qjrtggwi")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("wtlhqwd2")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("sputfuyq")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,260 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
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.Fields.RemoveById("54a1hvuq")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("stcnunkf")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("bholagx7")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("qjrtggwi")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("wtlhqwd2")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("sputfuyq")
|
||||
|
||||
// add
|
||||
new_max_distance := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "5udo4avx",
|
||||
"name": "max_distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_max_distance)
|
||||
collection.Fields.Add(new_max_distance)
|
||||
|
||||
// add
|
||||
new_max_elevation_gain := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "omuxiatj",
|
||||
"name": "max_elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_max_elevation_gain)
|
||||
collection.Fields.Add(new_max_elevation_gain)
|
||||
|
||||
// add
|
||||
new_max_duration := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "yq4snqnf",
|
||||
"name": "max_duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_max_duration)
|
||||
collection.Fields.Add(new_max_duration)
|
||||
|
||||
// add
|
||||
new_min_distance := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "q8d41loj",
|
||||
"name": "min_distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_min_distance)
|
||||
collection.Fields.Add(new_min_distance)
|
||||
|
||||
// add
|
||||
new_min_elevation_gain := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "xsetw0o6",
|
||||
"name": "min_elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_min_elevation_gain)
|
||||
collection.Fields.Add(new_min_elevation_gain)
|
||||
|
||||
// add
|
||||
new_min_duration := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "n4pq80mu",
|
||||
"name": "min_duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_min_duration)
|
||||
collection.Fields.Add(new_min_duration)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
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 := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "54a1hvuq",
|
||||
"name": "max_distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_max_distance)
|
||||
collection.Fields.Add(del_max_distance)
|
||||
|
||||
// add
|
||||
del_max_elevation_gain := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "stcnunkf",
|
||||
"name": "max_elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_max_elevation_gain)
|
||||
collection.Fields.Add(del_max_elevation_gain)
|
||||
|
||||
// add
|
||||
del_max_duration := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "bholagx7",
|
||||
"name": "max_duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_max_duration)
|
||||
collection.Fields.Add(del_max_duration)
|
||||
|
||||
// add
|
||||
del_min_distance := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "qjrtggwi",
|
||||
"name": "min_distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_min_distance)
|
||||
collection.Fields.Add(del_min_distance)
|
||||
|
||||
// add
|
||||
del_min_elevation_gain := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "wtlhqwd2",
|
||||
"name": "min_elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_min_elevation_gain)
|
||||
collection.Fields.Add(del_min_elevation_gain)
|
||||
|
||||
// add
|
||||
del_min_duration := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "sputfuyq",
|
||||
"name": "min_duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_min_duration)
|
||||
collection.Fields.Add(del_min_duration)
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("5udo4avx")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("omuxiatj")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("yq4snqnf")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("q8d41loj")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("xsetw0o6")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("n4pq80mu")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,265 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = nil
|
||||
|
||||
collection.ViewRule = types.Pointer("@request.auth.id = id")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("5udo4avx")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("omuxiatj")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("yq4snqnf")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("q8d41loj")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("xsetw0o6")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("n4pq80mu")
|
||||
|
||||
// add
|
||||
new_max_distance := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "nqiuah7b",
|
||||
"name": "max_distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_max_distance)
|
||||
collection.Fields.Add(new_max_distance)
|
||||
|
||||
// add
|
||||
new_max_elevation_gain := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "rpzvilry",
|
||||
"name": "max_elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_max_elevation_gain)
|
||||
collection.Fields.Add(new_max_elevation_gain)
|
||||
|
||||
// add
|
||||
new_max_duration := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "pfppgcfx",
|
||||
"name": "max_duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_max_duration)
|
||||
collection.Fields.Add(new_max_duration)
|
||||
|
||||
// add
|
||||
new_min_distance := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "jrqp7c8d",
|
||||
"name": "min_distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_min_distance)
|
||||
collection.Fields.Add(new_min_distance)
|
||||
|
||||
// add
|
||||
new_min_elevation_gain := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "xjcpg4su",
|
||||
"name": "min_elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_min_elevation_gain)
|
||||
collection.Fields.Add(new_min_elevation_gain)
|
||||
|
||||
// add
|
||||
new_min_duration := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "cuj9awlq",
|
||||
"name": "min_duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_min_duration)
|
||||
collection.Fields.Add(new_min_duration)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("@request.auth.id != \"\"")
|
||||
|
||||
collection.ViewRule = nil
|
||||
|
||||
// add
|
||||
del_max_distance := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "5udo4avx",
|
||||
"name": "max_distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_max_distance)
|
||||
collection.Fields.Add(del_max_distance)
|
||||
|
||||
// add
|
||||
del_max_elevation_gain := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "omuxiatj",
|
||||
"name": "max_elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_max_elevation_gain)
|
||||
collection.Fields.Add(del_max_elevation_gain)
|
||||
|
||||
// add
|
||||
del_max_duration := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "yq4snqnf",
|
||||
"name": "max_duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_max_duration)
|
||||
collection.Fields.Add(del_max_duration)
|
||||
|
||||
// add
|
||||
del_min_distance := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "q8d41loj",
|
||||
"name": "min_distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_min_distance)
|
||||
collection.Fields.Add(del_min_distance)
|
||||
|
||||
// add
|
||||
del_min_elevation_gain := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "xsetw0o6",
|
||||
"name": "min_elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_min_elevation_gain)
|
||||
collection.Fields.Add(del_min_elevation_gain)
|
||||
|
||||
// add
|
||||
del_min_duration := &core.JSONField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "n4pq80mu",
|
||||
"name": "min_duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_min_duration)
|
||||
collection.Fields.Add(del_min_duration)
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("nqiuah7b")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("rpzvilry")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("pfppgcfx")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("jrqp7c8d")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("xjcpg4su")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("cuj9awlq")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update
|
||||
edit_language := &core.SelectField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "t1wlsqyp",
|
||||
"name": "language",
|
||||
"type": "select",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
"en",
|
||||
"de",
|
||||
"fr",
|
||||
"hu",
|
||||
"nl",
|
||||
"pl",
|
||||
"pt",
|
||||
"zh"
|
||||
]
|
||||
}
|
||||
}`), edit_language)
|
||||
collection.Fields.Add(edit_language)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update
|
||||
edit_language := &core.SelectField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "t1wlsqyp",
|
||||
"name": "language",
|
||||
"type": "select",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
"en",
|
||||
"de",
|
||||
"fr",
|
||||
"hu",
|
||||
"nl",
|
||||
"pl",
|
||||
"pt"
|
||||
]
|
||||
}
|
||||
}`), edit_language)
|
||||
collection.Fields.Add(edit_language)
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
jsonData := `{
|
||||
"id": "lf06qip3f4d11yk",
|
||||
"created": "2024-04-03 18:44:47.201Z",
|
||||
"updated": "2024-04-03 18:44:47.201Z",
|
||||
"name": "comments",
|
||||
"type": "base",
|
||||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "0udwb0kl",
|
||||
"name": "text",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "fhgxdiam",
|
||||
"name": "rating",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "7lwo1mxx",
|
||||
"name": "author",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "_pb_users_auth_",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": null
|
||||
}
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
"listRule": "",
|
||||
"viewRule": "",
|
||||
"createRule": "",
|
||||
"updateRule": "",
|
||||
"deleteRule": "",
|
||||
"options": {}
|
||||
}`
|
||||
|
||||
collection := &core.Collection{}
|
||||
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("lf06qip3f4d11yk")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return app.Delete(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// add
|
||||
new_comments := &core.RelationField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "phhhroww",
|
||||
"name": "comments",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "lf06qip3f4d11yk",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": null,
|
||||
"displayFields": null
|
||||
}
|
||||
}`), new_comments)
|
||||
collection.Fields.Add(new_comments)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("phhhroww")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("lf06qip3f4d11yk")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// add
|
||||
new_trail := &core.RelationField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "snrlpxar",
|
||||
"name": "trail",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "e864strfxo14pm4",
|
||||
"cascadeDelete": true,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": null
|
||||
}
|
||||
}`), new_trail)
|
||||
collection.Fields.Add(new_trail)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("lf06qip3f4d11yk")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("snrlpxar")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("phhhroww")
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// add
|
||||
del_comments := &core.RelationField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "phhhroww",
|
||||
"name": "comments",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "lf06qip3f4d11yk",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": null,
|
||||
"displayFields": null
|
||||
}
|
||||
}`), del_comments)
|
||||
collection.Fields.Add(del_comments)
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,284 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
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.Fields.RemoveById("nqiuah7b")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("rpzvilry")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("pfppgcfx")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("jrqp7c8d")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("xjcpg4su")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("cuj9awlq")
|
||||
|
||||
// add
|
||||
new_max_distance := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "265lcwyn",
|
||||
"name": "max_distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_max_distance); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_max_distance)
|
||||
|
||||
// add
|
||||
new_max_elevation_gain := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "8udbn3hb",
|
||||
"name": "max_elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_max_elevation_gain); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_max_elevation_gain)
|
||||
|
||||
// add
|
||||
new_max_duration := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "0mw2f9gg",
|
||||
"name": "max_duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_max_duration); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_max_duration)
|
||||
|
||||
// add
|
||||
new_min_distance := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "qumwuc7g",
|
||||
"name": "min_distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_min_distance); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_min_distance)
|
||||
|
||||
// add
|
||||
new_min_elevation_gain := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "sins29kl",
|
||||
"name": "min_elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_min_elevation_gain); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_min_elevation_gain)
|
||||
|
||||
// add
|
||||
new_min_duration := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "dgfnqloa",
|
||||
"name": "min_duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_min_duration); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_min_duration)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
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 := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "nqiuah7b",
|
||||
"name": "max_distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_max_distance); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_max_distance)
|
||||
|
||||
// add
|
||||
del_max_elevation_gain := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "rpzvilry",
|
||||
"name": "max_elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_max_elevation_gain); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_max_elevation_gain)
|
||||
|
||||
// add
|
||||
del_max_duration := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "pfppgcfx",
|
||||
"name": "max_duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_max_duration); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_max_duration)
|
||||
|
||||
// add
|
||||
del_min_distance := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "jrqp7c8d",
|
||||
"name": "min_distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_min_distance); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_min_distance)
|
||||
|
||||
// add
|
||||
del_min_elevation_gain := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "xjcpg4su",
|
||||
"name": "min_elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_min_elevation_gain); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_min_elevation_gain)
|
||||
|
||||
// add
|
||||
del_min_duration := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "cuj9awlq",
|
||||
"name": "min_duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_min_duration); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_min_duration)
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("265lcwyn")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("8udbn3hb")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("0mw2f9gg")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("qumwuc7g")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("sins29kl")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("dgfnqloa")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,290 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
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.Fields.RemoveById("265lcwyn")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("8udbn3hb")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("0mw2f9gg")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("qumwuc7g")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("sins29kl")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("dgfnqloa")
|
||||
|
||||
// add
|
||||
new_max_distance := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "jahzab8l",
|
||||
"name": "max_distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_max_distance); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_max_distance)
|
||||
|
||||
// add
|
||||
new_max_elevation_gain := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "hz8wiojq",
|
||||
"name": "max_elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_max_elevation_gain); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_max_elevation_gain)
|
||||
|
||||
// add
|
||||
new_max_duration := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "mhdukuxo",
|
||||
"name": "max_duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_max_duration); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_max_duration)
|
||||
|
||||
// add
|
||||
new_min_distance := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "yl7yh4fi",
|
||||
"name": "min_distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_min_distance); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_min_distance)
|
||||
|
||||
// add
|
||||
new_min_elevation_gain := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "mmdluwag",
|
||||
"name": "min_elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_min_elevation_gain); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_min_elevation_gain)
|
||||
|
||||
// add
|
||||
new_min_duration := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "rruyzzld",
|
||||
"name": "min_duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_min_duration); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_min_duration)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
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.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 := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "265lcwyn",
|
||||
"name": "max_distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_max_distance); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_max_distance)
|
||||
|
||||
// add
|
||||
del_max_elevation_gain := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "8udbn3hb",
|
||||
"name": "max_elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_max_elevation_gain); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_max_elevation_gain)
|
||||
|
||||
// add
|
||||
del_max_duration := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "0mw2f9gg",
|
||||
"name": "max_duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_max_duration); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_max_duration)
|
||||
|
||||
// add
|
||||
del_min_distance := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "qumwuc7g",
|
||||
"name": "min_distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_min_distance); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_min_distance)
|
||||
|
||||
// add
|
||||
del_min_elevation_gain := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "sins29kl",
|
||||
"name": "min_elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_min_elevation_gain); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_min_elevation_gain)
|
||||
|
||||
// add
|
||||
del_min_duration := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "dgfnqloa",
|
||||
"name": "min_duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_min_duration); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_min_duration)
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("jahzab8l")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("hz8wiojq")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("mhdukuxo")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("yl7yh4fi")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("mmdluwag")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("rruyzzld")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,289 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
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.Fields.RemoveById("jahzab8l")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("hz8wiojq")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("mhdukuxo")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("yl7yh4fi")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("mmdluwag")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("rruyzzld")
|
||||
|
||||
// add
|
||||
new_max_distance := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "n42yecz5",
|
||||
"name": "max_distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_max_distance); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_max_distance)
|
||||
|
||||
// add
|
||||
new_max_elevation_gain := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "de8wl3e5",
|
||||
"name": "max_elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_max_elevation_gain); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_max_elevation_gain)
|
||||
|
||||
// add
|
||||
new_max_duration := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "lqhk4k6e",
|
||||
"name": "max_duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_max_duration); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_max_duration)
|
||||
|
||||
// add
|
||||
new_min_distance := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "ug5lh6ku",
|
||||
"name": "min_distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_min_distance); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_min_distance)
|
||||
|
||||
// add
|
||||
new_min_elevation_gain := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "lkrr7zr4",
|
||||
"name": "min_elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_min_elevation_gain); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_min_elevation_gain)
|
||||
|
||||
// add
|
||||
new_min_duration := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "sxhh02md",
|
||||
"name": "min_duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_min_duration); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_min_duration)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
options := map[string]any{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
}`), &options); err != nil {
|
||||
return err
|
||||
}
|
||||
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 := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "jahzab8l",
|
||||
"name": "max_distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_max_distance); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_max_distance)
|
||||
|
||||
// add
|
||||
del_max_elevation_gain := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "hz8wiojq",
|
||||
"name": "max_elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_max_elevation_gain); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_max_elevation_gain)
|
||||
|
||||
// add
|
||||
del_max_duration := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "mhdukuxo",
|
||||
"name": "max_duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_max_duration); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_max_duration)
|
||||
|
||||
// add
|
||||
del_min_distance := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "yl7yh4fi",
|
||||
"name": "min_distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_min_distance); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_min_distance)
|
||||
|
||||
// add
|
||||
del_min_elevation_gain := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "mmdluwag",
|
||||
"name": "min_elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_min_elevation_gain); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_min_elevation_gain)
|
||||
|
||||
// add
|
||||
del_min_duration := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "rruyzzld",
|
||||
"name": "min_duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_min_duration); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_min_duration)
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("n42yecz5")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("de8wl3e5")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("lqhk4k6e")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("ug5lh6ku")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("lkrr7zr4")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("sxhh02md")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("@request.auth.id != \"\"")
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("id = @request.auth.id")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ViewRule = types.Pointer("@request.auth.id != \"\"")
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ViewRule = types.Pointer("id = @request.auth.id")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// add
|
||||
new_date := &core.DateField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "hovyvbtt",
|
||||
"name": "date",
|
||||
"type": "date",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": "",
|
||||
"max": ""
|
||||
}
|
||||
}`), new_date); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_date)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("hovyvbtt")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && @collection.trails.author ?= @request.auth.id) || (@collection.trails.summit_logs.id ?= id && @collection.trails.public = true)")
|
||||
|
||||
collection.ViewRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && @collection.trails.author ?= @request.auth.id) || (@collection.trails.summit_logs.id ?= id && @collection.trails.public = true)")
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && @collection.trails.author ?= @request.auth.id) || @collection.trails.summit_logs.id ?= id && @collection.trails.public = true")
|
||||
|
||||
collection.ViewRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && @collection.trails.author ?= @request.auth.id) || @collection.trails.summit_logs.id ?= id && @collection.trails.public = true")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.UpdateRule = types.Pointer("@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author ?= @request.auth.id)")
|
||||
|
||||
collection.DeleteRule = types.Pointer("@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author ?= @request.auth.id)")
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.UpdateRule = types.Pointer("@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author = @request.auth.id)")
|
||||
|
||||
collection.DeleteRule = types.Pointer("@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author = @request.auth.id)")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
jsonData := `{
|
||||
"id": "uavt73rsqcn1n13",
|
||||
"created": "2024-04-13 13:54:26.023Z",
|
||||
"updated": "2024-04-13 13:54:26.023Z",
|
||||
"name": "settings",
|
||||
"type": "base",
|
||||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "0sepzvkh",
|
||||
"name": "language",
|
||||
"type": "select",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
"en",
|
||||
"de",
|
||||
"fr",
|
||||
"hu",
|
||||
"nl",
|
||||
"pl",
|
||||
"pt",
|
||||
"zh"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "zwg1jl0d",
|
||||
"name": "unit",
|
||||
"type": "select",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
"metric",
|
||||
"imperial"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "jo1zcsbu",
|
||||
"name": "mapFocus",
|
||||
"type": "select",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
"trails",
|
||||
"location"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "ufhepjxo",
|
||||
"name": "location",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 2000000
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "5uip7a4p",
|
||||
"name": "user",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "_pb_users_auth_",
|
||||
"cascadeDelete": true,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": null
|
||||
}
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
"listRule": null,
|
||||
"viewRule": null,
|
||||
"createRule": null,
|
||||
"updateRule": null,
|
||||
"deleteRule": null,
|
||||
"options": {}
|
||||
}`
|
||||
|
||||
collection := &core.Collection{}
|
||||
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return app.Delete(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,157 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("wjofulpg")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("t1wlsqyp")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("fhxhln9g")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("wosrk4ue")
|
||||
|
||||
query := app.RecordQuery("_pb_users_auth_")
|
||||
|
||||
users := []*core.Record{}
|
||||
if err := query.All(&users); err != nil {
|
||||
return err
|
||||
}
|
||||
settingsCollection, err := app.FindCollectionByNameOrId("settings")
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, user := range users {
|
||||
settings := core.NewRecord(settingsCollection)
|
||||
language := user.Get("language")
|
||||
unit := user.Get("unit")
|
||||
location := user.Get("location")
|
||||
settings.Set("language", language)
|
||||
settings.Set("unit", unit)
|
||||
settings.Set("location", location)
|
||||
settings.Set("user", user.Id)
|
||||
settings.Set("mapFocus", "location")
|
||||
if err := app.Save(settings); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// add
|
||||
del_unit := &core.SelectField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "wjofulpg",
|
||||
"name": "unit",
|
||||
"type": "select",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
"metric",
|
||||
"imperial"
|
||||
]
|
||||
}
|
||||
}`), del_unit); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_unit)
|
||||
|
||||
// add
|
||||
del_language := &core.SelectField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "t1wlsqyp",
|
||||
"name": "language",
|
||||
"type": "select",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
"en",
|
||||
"de",
|
||||
"fr",
|
||||
"hu",
|
||||
"nl",
|
||||
"pl",
|
||||
"pt",
|
||||
"zh"
|
||||
]
|
||||
}
|
||||
}`), del_language); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_language)
|
||||
|
||||
// add
|
||||
del_mapView := &core.SelectField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "fhxhln9g",
|
||||
"name": "mapView",
|
||||
"type": "select",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
"location",
|
||||
"trails"
|
||||
]
|
||||
}
|
||||
}`), del_mapView); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_mapView)
|
||||
|
||||
// add
|
||||
del_location := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "wosrk4ue",
|
||||
"name": "location",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 2000000
|
||||
}
|
||||
}`), del_location); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_location)
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("user = @request.auth.id")
|
||||
|
||||
collection.ViewRule = types.Pointer("user = @request.auth.id")
|
||||
|
||||
collection.CreateRule = types.Pointer("")
|
||||
|
||||
collection.UpdateRule = types.Pointer("user = @request.auth.id")
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = nil
|
||||
|
||||
collection.ViewRule = nil
|
||||
|
||||
collection.CreateRule = nil
|
||||
|
||||
collection.UpdateRule = nil
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
jsonData := `{
|
||||
"id": "urytyc428mwlbqq",
|
||||
"created": "2024-04-13 17:00:41.541Z",
|
||||
"updated": "2024-04-13 17:00:41.541Z",
|
||||
"name": "trails_bounding_box",
|
||||
"type": "view",
|
||||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "iyhsoisl",
|
||||
"name": "max_lat",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "kx2qfztr",
|
||||
"name": "max_lon",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "z4qsnjeb",
|
||||
"name": "min_lat",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "p66xomdb",
|
||||
"name": "min_lon",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
"listRule": null,
|
||||
"viewRule": null,
|
||||
"createRule": null,
|
||||
"updateRule": null,
|
||||
"deleteRule": null,
|
||||
"options": {
|
||||
"query": "SELECT users.id, COALESCE(MAX(trails.lat), 0) AS max_lat, COALESCE(MAX(trails.lon), 0) AS max_lon, COALESCE(MIN(trails.lat), 0) AS min_lat, COALESCE(MIN(trails.lon), 0) AS min_lon FROM users LEFT JOIN trails ON users.id = trails.author GROUP BY users.id;"
|
||||
}
|
||||
}`
|
||||
|
||||
collection := &core.Collection{}
|
||||
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("urytyc428mwlbqq")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return app.Delete(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,201 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("urytyc428mwlbqq")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ViewRule = types.Pointer("@request.auth.id = id")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("iyhsoisl")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("kx2qfztr")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("z4qsnjeb")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("p66xomdb")
|
||||
|
||||
// add
|
||||
new_max_lat := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "osfey1yx",
|
||||
"name": "max_lat",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_max_lat); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_max_lat)
|
||||
|
||||
// add
|
||||
new_max_lon := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "eohslzky",
|
||||
"name": "max_lon",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_max_lon); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_max_lon)
|
||||
|
||||
// add
|
||||
new_min_lat := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "kigvankd",
|
||||
"name": "min_lat",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_min_lat); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_min_lat)
|
||||
|
||||
// add
|
||||
new_min_lon := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "ifnks9mg",
|
||||
"name": "min_lon",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_min_lon); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_min_lon)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("urytyc428mwlbqq")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ViewRule = nil
|
||||
|
||||
// add
|
||||
del_max_lat := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "iyhsoisl",
|
||||
"name": "max_lat",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_max_lat); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_max_lat)
|
||||
|
||||
// add
|
||||
del_max_lon := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "kx2qfztr",
|
||||
"name": "max_lon",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_max_lon); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_max_lon)
|
||||
|
||||
// add
|
||||
del_min_lat := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "z4qsnjeb",
|
||||
"name": "min_lat",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_min_lat); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_min_lat)
|
||||
|
||||
// add
|
||||
del_min_lon := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "p66xomdb",
|
||||
"name": "min_lon",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_min_lon); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_min_lon)
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("osfey1yx")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("eohslzky")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("kigvankd")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("ifnks9mg")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("lf06qip3f4d11yk")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("((@request.auth.id != \"\" && trail.author = @request.auth.id) || trail.public = true) || author = @request.auth.id")
|
||||
|
||||
collection.ViewRule = types.Pointer("((@request.auth.id != \"\" && trail.author = @request.auth.id) || trail.public = true) || author = @request.auth.id")
|
||||
|
||||
collection.CreateRule = types.Pointer("@request.auth.id != \"\" && (trail.author = @request.auth.id || trail.public = true)")
|
||||
|
||||
collection.UpdateRule = types.Pointer("@request.auth.id = author")
|
||||
|
||||
collection.DeleteRule = types.Pointer("@request.auth.id = author")
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("lf06qip3f4d11yk")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("")
|
||||
|
||||
collection.ViewRule = types.Pointer("")
|
||||
|
||||
collection.CreateRule = types.Pointer("")
|
||||
|
||||
collection.UpdateRule = types.Pointer("")
|
||||
|
||||
collection.DeleteRule = types.Pointer("")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
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.waypoints.id ?= id && @collection.trails.public ?= true) || (author = @request.auth.id)")
|
||||
|
||||
collection.ViewRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && @collection.trails.author ?= @request.auth.id) || (@collection.trails.waypoints.id ?= id && @collection.trails.public ?= true) || (author = @request.auth.id)")
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
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.waypoints.id ?= id && @collection.trails.public ?= true) || author = @request.auth.id")
|
||||
|
||||
collection.ViewRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && @collection.trails.author ?= @request.auth.id) || (@collection.trails.waypoints.id ?= id && @collection.trails.public ?= true) || author = @request.auth.id")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
jsonData := `{
|
||||
"id": "xku110v5a5xbufa",
|
||||
"created": "2024-05-09 17:39:57.419Z",
|
||||
"updated": "2024-05-09 17:39:57.419Z",
|
||||
"name": "users_anonymous",
|
||||
"type": "view",
|
||||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "cknini6y",
|
||||
"name": "username",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
"listRule": null,
|
||||
"viewRule": null,
|
||||
"createRule": null,
|
||||
"updateRule": null,
|
||||
"deleteRule": null,
|
||||
"options": {
|
||||
"query": "SELECT id, username FROM users"
|
||||
}
|
||||
}`
|
||||
|
||||
collection := &core.Collection{}
|
||||
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("xku110v5a5xbufa")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return app.Delete(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("xku110v5a5xbufa")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("@request.auth.id != \"\"")
|
||||
|
||||
collection.ViewRule = types.Pointer("@request.auth.id != \"\"")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("cknini6y")
|
||||
|
||||
// add
|
||||
new_username := &core.TextField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "qzkmy7nv",
|
||||
"name": "username",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
}`), new_username); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_username)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("xku110v5a5xbufa")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = nil
|
||||
|
||||
collection.ViewRule = nil
|
||||
|
||||
// add
|
||||
del_username := &core.TextField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "cknini6y",
|
||||
"name": "username",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
}`), del_username); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_username)
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("qzkmy7nv")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
jsonData := `{
|
||||
"id": "1mns8mlal6uf9ku",
|
||||
"created": "2024-05-09 17:48:01.382Z",
|
||||
"updated": "2024-05-09 17:48:01.382Z",
|
||||
"name": "trail_share",
|
||||
"type": "base",
|
||||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "eskurfx6",
|
||||
"name": "trail",
|
||||
"type": "relation",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "e864strfxo14pm4",
|
||||
"cascadeDelete": true,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "yyzimwee",
|
||||
"name": "user",
|
||||
"type": "relation",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "_pb_users_auth_",
|
||||
"cascadeDelete": true,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "zr7aaqxl",
|
||||
"name": "permission",
|
||||
"type": "select",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
"view",
|
||||
"edit"
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
"listRule": "trail.author = @request.auth.id",
|
||||
"viewRule": "trail.author = @request.auth.id",
|
||||
"createRule": "trail.author = @request.auth.id",
|
||||
"updateRule": "trail.author = @request.auth.id",
|
||||
"deleteRule": "trail.author = @request.auth.id",
|
||||
"options": {}
|
||||
}`
|
||||
|
||||
collection := &core.Collection{}
|
||||
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("1mns8mlal6uf9ku")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return app.Delete(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("xku110v5a5xbufa")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ViewQuery = "SELECT id, username, avatar FROM users"
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("qzkmy7nv")
|
||||
|
||||
// add
|
||||
new_username := &core.TextField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "mbokwbb3",
|
||||
"name": "username",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
}`), new_username); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_username)
|
||||
|
||||
// add
|
||||
new_avatar := &core.FileField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "60wozbto",
|
||||
"name": "avatar",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"mimeTypes": [
|
||||
"image/jpeg",
|
||||
"image/png",
|
||||
"image/svg+xml",
|
||||
"image/gif",
|
||||
"image/webp"
|
||||
],
|
||||
"thumbs": null,
|
||||
"maxSelect": 1,
|
||||
"maxSize": 5242880,
|
||||
"protected": false
|
||||
}
|
||||
}`), new_avatar); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_avatar)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("xku110v5a5xbufa")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ViewQuery = "SELECT id, username FROM users"
|
||||
|
||||
// add
|
||||
del_username := &core.TextField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "qzkmy7nv",
|
||||
"name": "username",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
}`), del_username); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_username)
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("mbokwbb3")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("60wozbto")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("id = @request.auth.id")
|
||||
|
||||
collection.ViewRule = types.Pointer("id = @request.auth.id")
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("@request.auth.id != \"\"")
|
||||
|
||||
collection.ViewRule = types.Pointer("@request.auth.id != \"\"")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("author = @request.auth.id || public = true || (trail_share_via_trail.trail = id && trail_share_via_trail.user = @request.auth.id)")
|
||||
|
||||
collection.ViewRule = types.Pointer("author = @request.auth.id || public = true || (trail_share_via_trail.trail = id && trail_share_via_trail.user = @request.auth.id)")
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("author = @request.auth.id || public = true")
|
||||
|
||||
collection.ViewRule = types.Pointer("author = @request.auth.id || public = true")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
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)")
|
||||
|
||||
collection.ViewRule = types.Pointer("author = @request.auth.id || public = true || (trail_share_via_trail.user = @request.auth.id)")
|
||||
|
||||
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 app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("author = @request.auth.id || public = true || (trail_share_via_trail.trail = id && trail_share_via_trail.user = @request.auth.id)")
|
||||
|
||||
collection.ViewRule = types.Pointer("author = @request.auth.id || public = true || (trail_share_via_trail.trail = id && trail_share_via_trail.user = @request.auth.id)")
|
||||
|
||||
collection.UpdateRule = types.Pointer("author = @request.auth.id ")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("1mns8mlal6uf9ku")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("trail.author = @request.auth.id || user = @request.auth.id")
|
||||
|
||||
collection.ViewRule = types.Pointer("trail.author = @request.auth.id || user = @request.auth.id")
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("1mns8mlal6uf9ku")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("trail.author = @request.auth.id")
|
||||
|
||||
collection.ViewRule = types.Pointer("trail.author = @request.auth.id")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
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 app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
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 app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
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 app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
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 app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
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 app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
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 app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"os"
|
||||
"pocketbase/util"
|
||||
|
||||
"github.com/meilisearch/meilisearch-go"
|
||||
|
||||
"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(app core.App) error {
|
||||
_, err := client.Index("trails").UpdateFilterableAttributes(&[]string{
|
||||
"_geo", "author", "category", "completed", "date", "difficulty", "distance", "elevation_gain", "public", "shares",
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var usernames []string
|
||||
err = app.DB().NewQuery("SELECT username FROM users").Column(&usernames)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, username := range usernames {
|
||||
record, err := app.FindFirstRecordByData("users", "username", username)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
searchRules := map[string]interface{}{
|
||||
"cities500": map[string]string{},
|
||||
"trails": map[string]string{
|
||||
"filter": "public = true OR author = " + record.Id + " OR shares = " + record.Id,
|
||||
},
|
||||
}
|
||||
|
||||
if token, err := util.GenerateMeilisearchToken(searchRules, client); err != nil {
|
||||
return err
|
||||
} else {
|
||||
record.Set("token", token)
|
||||
|
||||
if err := app.Save(record); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}, func(app core.App) error {
|
||||
// add down queries...
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("lf06qip3f4d11yk")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("((@request.auth.id != \"\" && trail.author = @request.auth.id) || trail.public = true) || author = @request.auth.id || trail.trail_share_via_trail.user ?= @request.auth.id")
|
||||
|
||||
collection.ViewRule = types.Pointer("((@request.auth.id != \"\" && trail.author = @request.auth.id) || trail.public = true) || author = @request.auth.id || trail.trail_share_via_trail.user ?= @request.auth.id")
|
||||
|
||||
collection.CreateRule = types.Pointer("@request.auth.id != \"\" && (trail.author = @request.auth.id || trail.public = true || trail.trail_share_via_trail.user ?= @request.auth.id)")
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("lf06qip3f4d11yk")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("((@request.auth.id != \"\" && trail.author = @request.auth.id) || trail.public = true) || author = @request.auth.id")
|
||||
|
||||
collection.ViewRule = types.Pointer("((@request.auth.id != \"\" && trail.author = @request.auth.id) || trail.public = true) || author = @request.auth.id")
|
||||
|
||||
collection.CreateRule = types.Pointer("@request.auth.id != \"\" && (trail.author = @request.auth.id || trail.public = true)")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("author = @request.auth.id || public = true || (@request.auth.id != \"\" && trail_share_via_trail.user ?= @request.auth.id)")
|
||||
|
||||
collection.ViewRule = types.Pointer("author = @request.auth.id || public = true || (@request.auth.id != \"\" && trail_share_via_trail.user ?= @request.auth.id)")
|
||||
|
||||
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 app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
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)")
|
||||
|
||||
collection.ViewRule = types.Pointer("author = @request.auth.id || public = true || (trail_share_via_trail.user ?= @request.auth.id)")
|
||||
|
||||
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 app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/meilisearch/meilisearch-go"
|
||||
|
||||
"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(app core.App) error {
|
||||
_, err := client.Index("trails").UpdateSortableAttributes(&[]string{
|
||||
"created", "date", "difficulty", "distance", "elevation_gain", "name",
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}, func(app core.App) error {
|
||||
_, err := client.Index("trails").UpdateSortableAttributes(&[]string{
|
||||
"created", "difficulty", "distance", "elevation_gain", "name",
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update
|
||||
edit_language := &core.SelectField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "0sepzvkh",
|
||||
"name": "language",
|
||||
"type": "select",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
"en",
|
||||
"de",
|
||||
"fr",
|
||||
"hu",
|
||||
"it",
|
||||
"nl",
|
||||
"pl",
|
||||
"pt",
|
||||
"zh"
|
||||
]
|
||||
}
|
||||
}`), edit_language); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(edit_language)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update
|
||||
edit_language := &core.SelectField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "0sepzvkh",
|
||||
"name": "language",
|
||||
"type": "select",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
"en",
|
||||
"de",
|
||||
"fr",
|
||||
"hu",
|
||||
"nl",
|
||||
"pl",
|
||||
"pt",
|
||||
"zh"
|
||||
]
|
||||
}
|
||||
}`), edit_language); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(edit_language)
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// add
|
||||
new_category := &core.RelationField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "owlyzl1x",
|
||||
"name": "category",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "kjxvi8asj2igqwf",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": null
|
||||
}
|
||||
}`), new_category); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_category)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("owlyzl1x")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// add
|
||||
new_tilesets := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "xdbayoqg",
|
||||
"name": "tilesets",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 2000000
|
||||
}
|
||||
}`), new_tilesets); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_tilesets)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("xdbayoqg")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update
|
||||
edit_photos := &core.FileField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "aqbpyawe",
|
||||
"name": "photos",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"mimeTypes": [
|
||||
"image/jpeg",
|
||||
"image/vnd.mozilla.apng",
|
||||
"image/png",
|
||||
"image/webp",
|
||||
"image/svg+xml",
|
||||
"image/heic"
|
||||
],
|
||||
"thumbs": [],
|
||||
"maxSelect": 99,
|
||||
"maxSize": 5242880,
|
||||
"protected": false
|
||||
}
|
||||
}`), edit_photos); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(edit_photos)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update
|
||||
edit_photos := &core.FileField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "aqbpyawe",
|
||||
"name": "photos",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"mimeTypes": [
|
||||
"image/jpeg",
|
||||
"image/vnd.mozilla.apng",
|
||||
"image/png",
|
||||
"image/webp",
|
||||
"image/svg+xml"
|
||||
],
|
||||
"thumbs": [],
|
||||
"maxSelect": 99,
|
||||
"maxSize": 5242880,
|
||||
"protected": false
|
||||
}
|
||||
}`), edit_photos); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(edit_photos)
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
jsonData := `{
|
||||
"id": "1kot7t9na3hi0gl",
|
||||
"created": "2024-09-13 12:40:20.308Z",
|
||||
"updated": "2024-09-13 12:40:20.308Z",
|
||||
"name": "list_share",
|
||||
"type": "base",
|
||||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "luqrtipy",
|
||||
"name": "list",
|
||||
"type": "relation",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "r6gu2ajyidy1x69",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "mix12kkh",
|
||||
"name": "user",
|
||||
"type": "relation",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "_pb_users_auth_",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "n9rjdx5g",
|
||||
"name": "permission",
|
||||
"type": "select",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
"view",
|
||||
"edit"
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
"listRule": null,
|
||||
"viewRule": null,
|
||||
"createRule": null,
|
||||
"updateRule": null,
|
||||
"deleteRule": null,
|
||||
"options": {}
|
||||
}`
|
||||
|
||||
collection := &core.Collection{}
|
||||
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("1kot7t9na3hi0gl")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return app.Delete(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("1kot7t9na3hi0gl")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("list.author = @request.auth.id || user = @request.auth.id")
|
||||
|
||||
collection.ViewRule = types.Pointer("list.author = @request.auth.id || user = @request.auth.id")
|
||||
|
||||
collection.CreateRule = types.Pointer("list.author = @request.auth.id")
|
||||
|
||||
collection.UpdateRule = types.Pointer("list.author = @request.auth.id")
|
||||
|
||||
collection.DeleteRule = types.Pointer("list.author = @request.auth.id")
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("1kot7t9na3hi0gl")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = nil
|
||||
|
||||
collection.ViewRule = nil
|
||||
|
||||
collection.CreateRule = nil
|
||||
|
||||
collection.UpdateRule = nil
|
||||
|
||||
collection.DeleteRule = nil
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("r6gu2ajyidy1x69")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("author = @request.auth.id || (@request.auth.id != \"\" && list_share_via_list.user ?= @request.auth.id)")
|
||||
|
||||
collection.ViewRule = types.Pointer("author = @request.auth.id || (@request.auth.id != \"\" && list_share_via_list.user ?= @request.auth.id)")
|
||||
|
||||
collection.CreateRule = types.Pointer("@request.auth.id != \"\" && (@request.data.author = @request.auth.id)")
|
||||
|
||||
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 app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("r6gu2ajyidy1x69")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("author = @request.auth.id ")
|
||||
|
||||
collection.ViewRule = types.Pointer("author = @request.auth.id ")
|
||||
|
||||
collection.CreateRule = types.Pointer("author = @request.auth.id ")
|
||||
|
||||
collection.UpdateRule = types.Pointer("author = @request.auth.id ")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,289 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
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.Fields.RemoveById("6tuhuumw")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("xarhom23")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("kl9wsxwf")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("ipd1ohgc")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("o4s7acfv")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("d9lfg9vd")
|
||||
|
||||
// add
|
||||
new_max_distance := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "ixfa8u8m",
|
||||
"name": "max_distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_max_distance); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_max_distance)
|
||||
|
||||
// add
|
||||
new_max_elevation_gain := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "bhn0jj40",
|
||||
"name": "max_elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_max_elevation_gain); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_max_elevation_gain)
|
||||
|
||||
// add
|
||||
new_max_duration := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "3kujiwzh",
|
||||
"name": "max_duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_max_duration); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_max_duration)
|
||||
|
||||
// add
|
||||
new_min_distance := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "yf3zwzn4",
|
||||
"name": "min_distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_min_distance); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_min_distance)
|
||||
|
||||
// add
|
||||
new_min_elevation_gain := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "skvtkith",
|
||||
"name": "min_elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_min_elevation_gain); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_min_elevation_gain)
|
||||
|
||||
// add
|
||||
new_min_duration := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "gydvo1ug",
|
||||
"name": "min_duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_min_duration); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_min_duration)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
options := map[string]any{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
}`), &options); err != nil {
|
||||
return err
|
||||
}
|
||||
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 := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "6tuhuumw",
|
||||
"name": "max_distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_max_distance); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_max_distance)
|
||||
|
||||
// add
|
||||
del_max_elevation_gain := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "xarhom23",
|
||||
"name": "max_elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_max_elevation_gain); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_max_elevation_gain)
|
||||
|
||||
// add
|
||||
del_max_duration := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "kl9wsxwf",
|
||||
"name": "max_duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_max_duration); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_max_duration)
|
||||
|
||||
// add
|
||||
del_min_distance := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "ipd1ohgc",
|
||||
"name": "min_distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_min_distance); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_min_distance)
|
||||
|
||||
// add
|
||||
del_min_elevation_gain := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "o4s7acfv",
|
||||
"name": "min_elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_min_elevation_gain); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_min_elevation_gain)
|
||||
|
||||
// add
|
||||
del_min_duration := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "d9lfg9vd",
|
||||
"name": "min_duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_min_duration); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_min_duration)
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("ixfa8u8m")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("bhn0jj40")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("3kujiwzh")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("yf3zwzn4")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("skvtkith")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("gydvo1ug")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// add
|
||||
new_gpx := &core.FileField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "rfwmdcpt",
|
||||
"name": "gpx",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"mimeTypes": [],
|
||||
"thumbs": [],
|
||||
"maxSelect": 1,
|
||||
"maxSize": 5242880,
|
||||
"protected": false
|
||||
}
|
||||
}`), new_gpx); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_gpx)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("rfwmdcpt")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && @collection.trails.author ?= @request.auth.id) || (@collection.trails.summit_logs.id ?= id && @collection.trails.public = true) || (author = @request.auth.id)")
|
||||
|
||||
collection.ViewRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && @collection.trails.author ?= @request.auth.id) || (@collection.trails.summit_logs.id ?= id && @collection.trails.public = true) || (author = @request.auth.id)")
|
||||
|
||||
collection.UpdateRule = types.Pointer("@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author ?= @request.auth.id) || (author = @request.auth.id)")
|
||||
|
||||
collection.DeleteRule = types.Pointer("@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author ?= @request.auth.id) || (author = @request.auth.id)")
|
||||
|
||||
// add
|
||||
new_author := &core.RelationField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "r0mj3tkr",
|
||||
"name": "author",
|
||||
"type": "relation",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "_pb_users_auth_",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": null
|
||||
}
|
||||
}`), new_author); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_author)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && @collection.trails.author ?= @request.auth.id) || (@collection.trails.summit_logs.id ?= id && @collection.trails.public = true)")
|
||||
|
||||
collection.ViewRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && @collection.trails.author ?= @request.auth.id) || (@collection.trails.summit_logs.id ?= id && @collection.trails.public = true)")
|
||||
|
||||
collection.UpdateRule = types.Pointer("@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author ?= @request.auth.id)")
|
||||
|
||||
collection.DeleteRule = types.Pointer("@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author ?= @request.auth.id)")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("r0mj3tkr")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// add
|
||||
new_distance := &core.NumberField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "jovws28m",
|
||||
"name": "distance",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 0,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
}`), new_distance); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_distance)
|
||||
|
||||
// add
|
||||
new_elevation_gain := &core.NumberField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "m2kndtwn",
|
||||
"name": "elevation_gain",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 0,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
}`), new_elevation_gain); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_elevation_gain)
|
||||
|
||||
// add
|
||||
new_elevation_loss := &core.NumberField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "uqqo9cws",
|
||||
"name": "elevation_loss",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 0,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
}`), new_elevation_loss); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_elevation_loss)
|
||||
|
||||
// add
|
||||
new_duration := &core.NumberField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "vwxjsrae",
|
||||
"name": "duration",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 0,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
}`), new_duration); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_duration)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("jovws28m")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("m2kndtwn")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("uqqo9cws")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("vwxjsrae")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// add
|
||||
new_elevation_loss := &core.NumberField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "xutbwpq4",
|
||||
"name": "elevation_loss",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
}`), new_elevation_loss); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_elevation_loss)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("xutbwpq4")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,336 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
options := map[string]any{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
}`), &options); err != nil {
|
||||
return err
|
||||
}
|
||||
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.Fields.RemoveById("ixfa8u8m")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("bhn0jj40")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("3kujiwzh")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("yf3zwzn4")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("skvtkith")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("gydvo1ug")
|
||||
|
||||
// add
|
||||
new_max_distance := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "oyvx8oaq",
|
||||
"name": "max_distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_max_distance); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_max_distance)
|
||||
|
||||
// add
|
||||
new_max_elevation_gain := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "4xu7voeh",
|
||||
"name": "max_elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_max_elevation_gain); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_max_elevation_gain)
|
||||
|
||||
// add
|
||||
new_max_elevation_loss := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "sqzilovv",
|
||||
"name": "max_elevation_loss",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_max_elevation_loss); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_max_elevation_loss)
|
||||
|
||||
// add
|
||||
new_max_duration := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "rupidtew",
|
||||
"name": "max_duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_max_duration); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_max_duration)
|
||||
|
||||
// add
|
||||
new_min_distance := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "2y7dbhf9",
|
||||
"name": "min_distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_min_distance); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_min_distance)
|
||||
|
||||
// add
|
||||
new_min_elevation_gain := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "ooiwexpc",
|
||||
"name": "min_elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_min_elevation_gain); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_min_elevation_gain)
|
||||
|
||||
// add
|
||||
new_min_elevation_loss := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "ondmfwce",
|
||||
"name": "min_elevation_loss",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_min_elevation_loss); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_min_elevation_loss)
|
||||
|
||||
// add
|
||||
new_min_duration := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "kcrhzmaw",
|
||||
"name": "min_duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_min_duration); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_min_duration)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("4wbv9tz5zjdrjh1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
options := map[string]any{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
}`), &options); err != nil {
|
||||
return err
|
||||
}
|
||||
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 := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "ixfa8u8m",
|
||||
"name": "max_distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_max_distance); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_max_distance)
|
||||
|
||||
// add
|
||||
del_max_elevation_gain := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "bhn0jj40",
|
||||
"name": "max_elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_max_elevation_gain); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_max_elevation_gain)
|
||||
|
||||
// add
|
||||
del_max_duration := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "3kujiwzh",
|
||||
"name": "max_duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_max_duration); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_max_duration)
|
||||
|
||||
// add
|
||||
del_min_distance := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "yf3zwzn4",
|
||||
"name": "min_distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_min_distance); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_min_distance)
|
||||
|
||||
// add
|
||||
del_min_elevation_gain := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "skvtkith",
|
||||
"name": "min_elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_min_elevation_gain); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_min_elevation_gain)
|
||||
|
||||
// add
|
||||
del_min_duration := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "gydvo1ug",
|
||||
"name": "min_duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_min_duration); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_min_duration)
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("oyvx8oaq")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("4xu7voeh")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("sqzilovv")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("rupidtew")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("2y7dbhf9")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("ooiwexpc")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("ondmfwce")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("kcrhzmaw")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && @collection.trails.author ?= @request.auth.id) || (@collection.trails.summit_logs.id ?= id && @collection.trails.public ?= true) || (author = @request.auth.id)")
|
||||
|
||||
collection.ViewRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && @collection.trails.author ?= @request.auth.id) || (@collection.trails.summit_logs.id ?= id && @collection.trails.public ?= true) || (author = @request.auth.id)")
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && @collection.trails.author ?= @request.auth.id) || (@collection.trails.summit_logs.id ?= id && @collection.trails.public = true) || (author = @request.auth.id)")
|
||||
|
||||
collection.ViewRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && @collection.trails.author ?= @request.auth.id) || (@collection.trails.summit_logs.id ?= id && @collection.trails.public = true) || (author = @request.auth.id)")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("xku110v5a5xbufa")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ViewQuery = "SELECT id, username, avatar, created FROM users"
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("ogrxf4ps")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("7k4bozux")
|
||||
|
||||
// add
|
||||
new_username := &core.TextField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "kvteagv6",
|
||||
"name": "username",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
}`), new_username); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_username)
|
||||
|
||||
// add
|
||||
new_avatar := &core.FileField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "m9efnpak",
|
||||
"name": "avatar",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"mimeTypes": [
|
||||
"image/jpeg",
|
||||
"image/png",
|
||||
"image/svg+xml",
|
||||
"image/gif",
|
||||
"image/webp"
|
||||
],
|
||||
"thumbs": null,
|
||||
"maxSelect": 1,
|
||||
"maxSize": 5242880,
|
||||
"protected": false
|
||||
}
|
||||
}`), new_avatar); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_avatar)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("xku110v5a5xbufa")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ViewQuery = "SELECT id, username, avatar FROM users"
|
||||
|
||||
// add
|
||||
del_username := &core.TextField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "ogrxf4ps",
|
||||
"name": "username",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
}`), del_username); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_username)
|
||||
|
||||
// add
|
||||
del_avatar := &core.FileField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "7k4bozux",
|
||||
"name": "avatar",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"mimeTypes": [
|
||||
"image/jpeg",
|
||||
"image/png",
|
||||
"image/svg+xml",
|
||||
"image/gif",
|
||||
"image/webp"
|
||||
],
|
||||
"thumbs": null,
|
||||
"maxSelect": 1,
|
||||
"maxSize": 5242880,
|
||||
"protected": false
|
||||
}
|
||||
}`), del_avatar); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_avatar)
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("kvteagv6")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("m9efnpak")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
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 app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
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 app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && @collection.trails.author ?= @request.auth.id) || (@collection.trails.summit_logs.id ?= id && @collection.trails.public ?= true) ||\n(@collection.trail_share.trail.summit_logs.id ?= id && @collection.trail_share.user ?= @request.auth.id) ||\n(author = @request.auth.id)")
|
||||
|
||||
collection.ViewRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && @collection.trails.author ?= @request.auth.id) || (@collection.trails.summit_logs.id ?= id && @collection.trails.public ?= true) || \n(@collection.trail_share.trail.summit_logs.id ?= id && @collection.trail_share.user ?= @request.auth.id) ||\n(author = @request.auth.id)")
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && @collection.trails.author ?= @request.auth.id) || (@collection.trails.summit_logs.id ?= id && @collection.trails.public ?= true) || (author = @request.auth.id)")
|
||||
|
||||
collection.ViewRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && @collection.trails.author ?= @request.auth.id) || (@collection.trails.summit_logs.id ?= id && @collection.trails.public ?= true) || (author = @request.auth.id)")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
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.verificationTemplate.subject = 'your default subject';
|
||||
// settings.meta.verificationTemplate.body = '<p>Hello world - {ACTION_URL}!</p>';
|
||||
// settings.meta.verificationTemplate.actionUrl = '{APP_URL}/_/#/auth/confirm-verification/{TOKEN}';
|
||||
|
||||
// you can also change similarly any other template or setting
|
||||
//
|
||||
// all setting fields are identical to the json response so you can
|
||||
// use the https://pocketbase.io/docs/api-settings/ > Update settings
|
||||
// "Body parameters" section as a reference
|
||||
|
||||
return app.Save(settings)
|
||||
|
||||
}, func(app core.App) error {
|
||||
// add down queries...
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -1,145 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("xku110v5a5xbufa")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("")
|
||||
|
||||
collection.ViewRule = types.Pointer("")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("kvteagv6")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("m9efnpak")
|
||||
|
||||
// add
|
||||
new_username := &core.TextField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "femc0ok5",
|
||||
"name": "username",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
}`), new_username); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_username)
|
||||
|
||||
// add
|
||||
new_avatar := &core.FileField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "aglcodpn",
|
||||
"name": "avatar",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"mimeTypes": [
|
||||
"image/jpeg",
|
||||
"image/png",
|
||||
"image/svg+xml",
|
||||
"image/gif",
|
||||
"image/webp"
|
||||
],
|
||||
"thumbs": null,
|
||||
"maxSelect": 1,
|
||||
"maxSize": 5242880,
|
||||
"protected": false
|
||||
}
|
||||
}`), new_avatar); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_avatar)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("xku110v5a5xbufa")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("@request.auth.id != \"\"")
|
||||
|
||||
collection.ViewRule = types.Pointer("@request.auth.id != \"\"")
|
||||
|
||||
// add
|
||||
del_username := &core.TextField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "kvteagv6",
|
||||
"name": "username",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
}`), del_username); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_username)
|
||||
|
||||
// add
|
||||
del_avatar := &core.FileField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "m9efnpak",
|
||||
"name": "avatar",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"mimeTypes": [
|
||||
"image/jpeg",
|
||||
"image/png",
|
||||
"image/svg+xml",
|
||||
"image/gif",
|
||||
"image/webp"
|
||||
],
|
||||
"thumbs": null,
|
||||
"maxSelect": 1,
|
||||
"maxSize": 5242880,
|
||||
"protected": false
|
||||
}
|
||||
}`), del_avatar); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_avatar)
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("femc0ok5")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("aglcodpn")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// add
|
||||
new_photos := &core.FileField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "ixnksbkt",
|
||||
"name": "photos",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"mimeTypes": [
|
||||
"image/jpeg",
|
||||
"image/png",
|
||||
"image/vnd.mozilla.apng",
|
||||
"image/webp",
|
||||
"image/svg+xml",
|
||||
"image/heic"
|
||||
],
|
||||
"thumbs": [],
|
||||
"maxSelect": 99,
|
||||
"maxSize": 5242880,
|
||||
"protected": false
|
||||
}
|
||||
}`), new_photos); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_photos)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("ixnksbkt")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// add
|
||||
new_terrain := &core.URLField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "mvxf9llv",
|
||||
"name": "terrain",
|
||||
"type": "url",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"exceptDomains": [],
|
||||
"onlyDomains": []
|
||||
}
|
||||
}`), new_terrain); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_terrain)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("mvxf9llv")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("mvxf9llv")
|
||||
|
||||
// add
|
||||
new_terrain := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "unsh0qsp",
|
||||
"name": "terrain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 2000000
|
||||
}
|
||||
}`), new_terrain); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_terrain)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// add
|
||||
del_terrain := &core.URLField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "mvxf9llv",
|
||||
"name": "terrain",
|
||||
"type": "url",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"exceptDomains": [],
|
||||
"onlyDomains": []
|
||||
}
|
||||
}`), del_terrain); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_terrain)
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("unsh0qsp")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/meilisearch/meilisearch-go"
|
||||
|
||||
"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(app core.App) error {
|
||||
_, err := client.Index("trails").UpdateSortableAttributes(&[]string{
|
||||
"created", "date", "difficulty", "distance", "elevation_gain", "elevation_loss", "name", "duration", "author",
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}, func(app core.App) error {
|
||||
_, err := client.Index("trails").UpdateSortableAttributes(&[]string{
|
||||
"created", "date", "difficulty", "distance", "elevation_gain", "elevation_loss", "name",
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// add
|
||||
new_bio := &core.TextField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "pd2cq8sq",
|
||||
"name": "bio",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": 10000,
|
||||
"pattern": ""
|
||||
}
|
||||
}`), new_bio); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_bio)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("_pb_users_auth_")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("pd2cq8sq")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,163 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("xku110v5a5xbufa")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ViewQuery = "SELECT id, username, avatar, bio, created FROM users"
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("femc0ok5")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("aglcodpn")
|
||||
|
||||
// add
|
||||
new_username := &core.TextField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "tkxbpwxe",
|
||||
"name": "username",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
}`), new_username); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_username)
|
||||
|
||||
// add
|
||||
new_avatar := &core.FileField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "xs5qvkih",
|
||||
"name": "avatar",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"mimeTypes": [
|
||||
"image/jpeg",
|
||||
"image/png",
|
||||
"image/svg+xml",
|
||||
"image/gif",
|
||||
"image/webp"
|
||||
],
|
||||
"thumbs": null,
|
||||
"maxSelect": 1,
|
||||
"maxSize": 5242880,
|
||||
"protected": false
|
||||
}
|
||||
}`), new_avatar); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_avatar)
|
||||
|
||||
// add
|
||||
new_bio := &core.TextField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "agsa8h5z",
|
||||
"name": "bio",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": 10000,
|
||||
"pattern": ""
|
||||
}
|
||||
}`), new_bio); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_bio)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("xku110v5a5xbufa")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ViewQuery = "SELECT id, username, avatar, created FROM users"
|
||||
|
||||
// add
|
||||
del_username := &core.TextField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "femc0ok5",
|
||||
"name": "username",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
}`), del_username); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_username)
|
||||
|
||||
// add
|
||||
del_avatar := &core.FileField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "aglcodpn",
|
||||
"name": "avatar",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"mimeTypes": [
|
||||
"image/jpeg",
|
||||
"image/png",
|
||||
"image/svg+xml",
|
||||
"image/gif",
|
||||
"image/webp"
|
||||
],
|
||||
"thumbs": null,
|
||||
"maxSelect": 1,
|
||||
"maxSize": 5242880,
|
||||
"protected": false
|
||||
}
|
||||
}`), del_avatar); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_avatar)
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("tkxbpwxe")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("xs5qvkih")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("agsa8h5z")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("r6gu2ajyidy1x69")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("author = @request.auth.id || public = true || (@request.auth.id != \"\" && list_share_via_list.user ?= @request.auth.id)")
|
||||
|
||||
collection.ViewRule = types.Pointer("author = @request.auth.id || public = true || (@request.auth.id != \"\" && list_share_via_list.user ?= @request.auth.id)")
|
||||
|
||||
// add
|
||||
new_public := &core.BoolField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "rolk3q3j",
|
||||
"name": "public",
|
||||
"type": "bool",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {}
|
||||
}`), new_public); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_public)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("r6gu2ajyidy1x69")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("author = @request.auth.id || (@request.auth.id != \"\" && list_share_via_list.user ?= @request.auth.id)")
|
||||
|
||||
collection.ViewRule = types.Pointer("author = @request.auth.id || (@request.auth.id != \"\" && list_share_via_list.user ?= @request.auth.id)")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("rolk3q3j")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,179 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
jsonData := `{
|
||||
"id": "t9lphichi5xwyeu",
|
||||
"created": "2024-12-14 14:25:55.563Z",
|
||||
"updated": "2024-12-14 14:25:55.563Z",
|
||||
"name": "activities",
|
||||
"type": "view",
|
||||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "zegqj8bt",
|
||||
"name": "date",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "mztv5od5",
|
||||
"name": "name",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "4hq14mc5",
|
||||
"name": "description",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "hbyuxehw",
|
||||
"name": "gpx",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "syp8ya96",
|
||||
"name": "author",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "rrfp5omm",
|
||||
"name": "photos",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "tacveduk",
|
||||
"name": "distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "ydhldat1",
|
||||
"name": "duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "9gg24ge8",
|
||||
"name": "elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "ujsn6lqc",
|
||||
"name": "elevation_loss",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "nvvrulvj",
|
||||
"name": "type",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
"listRule": null,
|
||||
"viewRule": null,
|
||||
"createRule": null,
|
||||
"updateRule": null,
|
||||
"deleteRule": null,
|
||||
"options": {
|
||||
"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"
|
||||
}
|
||||
}`
|
||||
|
||||
collection := &core.Collection{}
|
||||
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("t9lphichi5xwyeu")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return app.Delete(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,499 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("t9lphichi5xwyeu")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("")
|
||||
|
||||
collection.ViewRule = types.Pointer("")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("zegqj8bt")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("mztv5od5")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("4hq14mc5")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("hbyuxehw")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("syp8ya96")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("rrfp5omm")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("tacveduk")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("ydhldat1")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("9gg24ge8")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("ujsn6lqc")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("nvvrulvj")
|
||||
|
||||
// add
|
||||
new_date := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "qejtfjom",
|
||||
"name": "date",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_date); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_date)
|
||||
|
||||
// add
|
||||
new_name := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "nskezkjx",
|
||||
"name": "name",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_name); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_name)
|
||||
|
||||
// add
|
||||
new_description := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "viedej4h",
|
||||
"name": "description",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_description); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_description)
|
||||
|
||||
// add
|
||||
new_gpx := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "vljhhvdy",
|
||||
"name": "gpx",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_gpx); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_gpx)
|
||||
|
||||
// add
|
||||
new_author := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "z1uaeqzu",
|
||||
"name": "author",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_author); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_author)
|
||||
|
||||
// add
|
||||
new_photos := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "9nnpyhlq",
|
||||
"name": "photos",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_photos); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_photos)
|
||||
|
||||
// add
|
||||
new_distance := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "7kzcclzu",
|
||||
"name": "distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_distance); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_distance)
|
||||
|
||||
// add
|
||||
new_duration := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "gwpsktbu",
|
||||
"name": "duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_duration); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_duration)
|
||||
|
||||
// add
|
||||
new_elevation_gain := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "5tze9ybp",
|
||||
"name": "elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_elevation_gain); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_elevation_gain)
|
||||
|
||||
// add
|
||||
new_elevation_loss := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "xkuz8ixp",
|
||||
"name": "elevation_loss",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_elevation_loss); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_elevation_loss)
|
||||
|
||||
// add
|
||||
new_type := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "soylsusn",
|
||||
"name": "type",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_type); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_type)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("t9lphichi5xwyeu")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = nil
|
||||
|
||||
collection.ViewRule = nil
|
||||
|
||||
// add
|
||||
del_date := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "zegqj8bt",
|
||||
"name": "date",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_date); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_date)
|
||||
|
||||
// add
|
||||
del_name := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "mztv5od5",
|
||||
"name": "name",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_name); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_name)
|
||||
|
||||
// add
|
||||
del_description := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "4hq14mc5",
|
||||
"name": "description",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_description); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_description)
|
||||
|
||||
// add
|
||||
del_gpx := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "hbyuxehw",
|
||||
"name": "gpx",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_gpx); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_gpx)
|
||||
|
||||
// add
|
||||
del_author := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "syp8ya96",
|
||||
"name": "author",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_author); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_author)
|
||||
|
||||
// add
|
||||
del_photos := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "rrfp5omm",
|
||||
"name": "photos",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_photos); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_photos)
|
||||
|
||||
// add
|
||||
del_distance := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "tacveduk",
|
||||
"name": "distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_distance); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_distance)
|
||||
|
||||
// add
|
||||
del_duration := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "ydhldat1",
|
||||
"name": "duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_duration); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_duration)
|
||||
|
||||
// add
|
||||
del_elevation_gain := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "9gg24ge8",
|
||||
"name": "elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_elevation_gain); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_elevation_gain)
|
||||
|
||||
// add
|
||||
del_elevation_loss := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "ujsn6lqc",
|
||||
"name": "elevation_loss",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_elevation_loss); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_elevation_loss)
|
||||
|
||||
// add
|
||||
del_type := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "nvvrulvj",
|
||||
"name": "type",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_type); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_type)
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("qejtfjom")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("nskezkjx")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("viedej4h")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("vljhhvdy")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("z1uaeqzu")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("9nnpyhlq")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("7kzcclzu")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("gwpsktbu")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("5tze9ybp")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("xkuz8ixp")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("soylsusn")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,515 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("t9lphichi5xwyeu")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
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.Fields.RemoveById("qejtfjom")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("nskezkjx")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("viedej4h")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("vljhhvdy")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("z1uaeqzu")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("9nnpyhlq")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("7kzcclzu")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("gwpsktbu")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("5tze9ybp")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("xkuz8ixp")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("soylsusn")
|
||||
|
||||
// add
|
||||
new_trail_id := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "xbcmb4ax",
|
||||
"name": "trail_id",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_trail_id); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_trail_id)
|
||||
|
||||
// add
|
||||
new_date := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "elenpjfu",
|
||||
"name": "date",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_date); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_date)
|
||||
|
||||
// add
|
||||
new_name := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "gvcm04wv",
|
||||
"name": "name",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_name); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_name)
|
||||
|
||||
// add
|
||||
new_description := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "lzg9ifgi",
|
||||
"name": "description",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_description); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_description)
|
||||
|
||||
// add
|
||||
new_gpx := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "rzqpztsp",
|
||||
"name": "gpx",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_gpx); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_gpx)
|
||||
|
||||
// add
|
||||
new_author := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "oqzupzz2",
|
||||
"name": "author",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_author); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_author)
|
||||
|
||||
// add
|
||||
new_photos := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "xmzmcgjm",
|
||||
"name": "photos",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_photos); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_photos)
|
||||
|
||||
// add
|
||||
new_distance := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "rslhnvby",
|
||||
"name": "distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_distance); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_distance)
|
||||
|
||||
// add
|
||||
new_duration := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "xgfy26z9",
|
||||
"name": "duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_duration); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_duration)
|
||||
|
||||
// add
|
||||
new_elevation_gain := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "iuhfh4vo",
|
||||
"name": "elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_elevation_gain); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_elevation_gain)
|
||||
|
||||
// add
|
||||
new_elevation_loss := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "hoauojgi",
|
||||
"name": "elevation_loss",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_elevation_loss); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_elevation_loss)
|
||||
|
||||
// add
|
||||
new_type := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "7b25xfwx",
|
||||
"name": "type",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_type); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_type)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("t9lphichi5xwyeu")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
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 := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "qejtfjom",
|
||||
"name": "date",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_date); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_date)
|
||||
|
||||
// add
|
||||
del_name := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "nskezkjx",
|
||||
"name": "name",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_name); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_name)
|
||||
|
||||
// add
|
||||
del_description := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "viedej4h",
|
||||
"name": "description",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_description); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_description)
|
||||
|
||||
// add
|
||||
del_gpx := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "vljhhvdy",
|
||||
"name": "gpx",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_gpx); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_gpx)
|
||||
|
||||
// add
|
||||
del_author := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "z1uaeqzu",
|
||||
"name": "author",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_author); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_author)
|
||||
|
||||
// add
|
||||
del_photos := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "9nnpyhlq",
|
||||
"name": "photos",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_photos); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_photos)
|
||||
|
||||
// add
|
||||
del_distance := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "7kzcclzu",
|
||||
"name": "distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_distance); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_distance)
|
||||
|
||||
// add
|
||||
del_duration := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "gwpsktbu",
|
||||
"name": "duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_duration); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_duration)
|
||||
|
||||
// add
|
||||
del_elevation_gain := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "5tze9ybp",
|
||||
"name": "elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_elevation_gain); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_elevation_gain)
|
||||
|
||||
// add
|
||||
del_elevation_loss := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "xkuz8ixp",
|
||||
"name": "elevation_loss",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_elevation_loss); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_elevation_loss)
|
||||
|
||||
// add
|
||||
del_type := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "soylsusn",
|
||||
"name": "type",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_type); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_type)
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("xbcmb4ax")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("elenpjfu")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("gvcm04wv")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("lzg9ifgi")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("rzqpztsp")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("oqzupzz2")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("xmzmcgjm")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("rslhnvby")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("xgfy26z9")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("iuhfh4vo")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("hoauojgi")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("7b25xfwx")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
jsonData := `{
|
||||
"id": "8obn1ukumze565i",
|
||||
"created": "2024-12-14 17:17:00.381Z",
|
||||
"updated": "2024-12-14 17:17:00.381Z",
|
||||
"name": "follows",
|
||||
"type": "base",
|
||||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "in1traur",
|
||||
"name": "follower",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "_pb_users_auth_",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "wxwomfd5",
|
||||
"name": "followee",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "_pb_users_auth_",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": null
|
||||
}
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
"listRule": "@request.auth.id = follower.id || @request.auth.id = followee.id",
|
||||
"viewRule": "@request.auth.id = follower.id || @request.auth.id = followee.id",
|
||||
"createRule": "@request.auth.id = follower.id",
|
||||
"updateRule": "@request.auth.id = follower.id",
|
||||
"deleteRule": "@request.auth.id = follower.id",
|
||||
"options": {}
|
||||
}`
|
||||
|
||||
collection := &core.Collection{}
|
||||
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("8obn1ukumze565i")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return app.Delete(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
jsonData := `{
|
||||
"id": "j6w72f0kb5ivd7x",
|
||||
"created": "2024-12-14 18:20:18.920Z",
|
||||
"updated": "2024-12-14 18:20:18.920Z",
|
||||
"name": "follow_counts",
|
||||
"type": "view",
|
||||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "w81n64il",
|
||||
"name": "followers",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "rfnejpto",
|
||||
"name": "following",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
"listRule": "",
|
||||
"viewRule": "",
|
||||
"createRule": null,
|
||||
"updateRule": null,
|
||||
"deleteRule": null,
|
||||
"options": {
|
||||
"query": "SELECT \n users.id,\n COALESCE(followers.count, 0) AS followers,\n COALESCE(following.count, 0) AS following\nFROM users\nLEFT JOIN (\n SELECT followee AS user_id, COUNT(*) AS count\n FROM follows\n GROUP BY followee\n) AS followers ON users.id = followers.user_id\nLEFT JOIN (\n SELECT follower AS user_id, COUNT(*) AS count\n FROM follows\n GROUP BY follower\n) AS following ON users.id = following.user_id;"
|
||||
}
|
||||
}`
|
||||
|
||||
collection := &core.Collection{}
|
||||
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("j6w72f0kb5ivd7x")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return app.Delete(collection)
|
||||
})
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,117 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
jsonData := `{
|
||||
"id": "khrcci2uqknny8h",
|
||||
"created": "2024-12-20 17:33:49.887Z",
|
||||
"updated": "2024-12-20 20:25:40.071Z",
|
||||
"name": "notifications",
|
||||
"type": "base",
|
||||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "b57prsbu",
|
||||
"name": "type",
|
||||
"type": "select",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
"trail_create",
|
||||
"list_create",
|
||||
"new_follower",
|
||||
"trail_comment"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "1i2ycgle",
|
||||
"name": "metadata",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 2000000
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "pyimxu85",
|
||||
"name": "seen",
|
||||
"type": "bool",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "tmghd4vo",
|
||||
"name": "recipient",
|
||||
"type": "relation",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "_pb_users_auth_",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "exqo1whj",
|
||||
"name": "author",
|
||||
"type": "relation",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "_pb_users_auth_",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": null
|
||||
}
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
"listRule": "@request.auth.id = recipient",
|
||||
"viewRule": "@request.auth.id = recipient",
|
||||
"createRule": null,
|
||||
"updateRule": "@request.auth.id = recipient && @request.data.type = type && @request.data.metadata = metadata && @request.data.recipient = recipient && @request.data.author = author",
|
||||
"deleteRule": null,
|
||||
"options": {}
|
||||
}`
|
||||
|
||||
collection := &core.Collection{}
|
||||
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("khrcci2uqknny8h")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return app.Delete(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("khrcci2uqknny8h")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update
|
||||
edit_type := &core.SelectField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "b57prsbu",
|
||||
"name": "type",
|
||||
"type": "select",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
"trail_create",
|
||||
"t list_create",
|
||||
"new_follower",
|
||||
"trail_comment",
|
||||
"trail_share",
|
||||
"list_share"
|
||||
]
|
||||
}
|
||||
}`), edit_type); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(edit_type)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("khrcci2uqknny8h")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update
|
||||
edit_type := &core.SelectField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "b57prsbu",
|
||||
"name": "type",
|
||||
"type": "select",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
"trail_create",
|
||||
"list_create",
|
||||
"new_follower",
|
||||
"trail_comment"
|
||||
]
|
||||
}
|
||||
}`), edit_type); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(edit_type)
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// add
|
||||
new_notifications := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "sbwmk0q2",
|
||||
"name": "notifications",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 2000000
|
||||
}
|
||||
}`), new_notifications); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_notifications)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("uavt73rsqcn1n13")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("sbwmk0q2")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
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 app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
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 app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("1kot7t9na3hi0gl")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update
|
||||
edit_list := &core.RelationField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "luqrtipy",
|
||||
"name": "list",
|
||||
"type": "relation",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "r6gu2ajyidy1x69",
|
||||
"cascadeDelete": true,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": null
|
||||
}
|
||||
}`), edit_list); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(edit_list)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("1kot7t9na3hi0gl")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update
|
||||
edit_list := &core.RelationField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "luqrtipy",
|
||||
"name": "list",
|
||||
"type": "relation",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "r6gu2ajyidy1x69",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": null
|
||||
}
|
||||
}`), edit_list); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(edit_list)
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("khrcci2uqknny8h")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update
|
||||
edit_type := &core.SelectField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "b57prsbu",
|
||||
"name": "type",
|
||||
"type": "select",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
"trail_create",
|
||||
"list_create",
|
||||
"new_follower",
|
||||
"trail_comment",
|
||||
"trail_share",
|
||||
"list_share"
|
||||
]
|
||||
}
|
||||
}`), edit_type); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(edit_type)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("khrcci2uqknny8h")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update
|
||||
edit_type := &core.SelectField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "b57prsbu",
|
||||
"name": "type",
|
||||
"type": "select",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
"trail_create",
|
||||
"t list_create",
|
||||
"new_follower",
|
||||
"trail_comment",
|
||||
"trail_share",
|
||||
"list_share"
|
||||
]
|
||||
}
|
||||
}`), edit_type); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(edit_type)
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,536 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("t9lphichi5xwyeu")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
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.Fields.RemoveById("zmvj8lcq")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("ujwzemal")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("royuu8hr")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("e5myhqi1")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("twzxntjy")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("mbgymehy")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("jvd9zgrj")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("v6t7ybts")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("vnddbe3a")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("mp9jqukw")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("c6zw4l4h")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("njsy8gsh")
|
||||
|
||||
// add
|
||||
new_trail_id := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "mpcwfh4x",
|
||||
"name": "trail_id",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_trail_id); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_trail_id)
|
||||
|
||||
// add
|
||||
new_date := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "xsxx8b8a",
|
||||
"name": "date",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_date); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_date)
|
||||
|
||||
// add
|
||||
new_name := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "4ybgblqj",
|
||||
"name": "name",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_name); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_name)
|
||||
|
||||
// add
|
||||
new_description := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "f7y3unyx",
|
||||
"name": "description",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_description); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_description)
|
||||
|
||||
// add
|
||||
new_gpx := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "cowkmcyy",
|
||||
"name": "gpx",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_gpx); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_gpx)
|
||||
|
||||
// add
|
||||
new_author := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "dgewwftr",
|
||||
"name": "author",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_author); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_author)
|
||||
|
||||
// add
|
||||
new_photos := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "ugtikydq",
|
||||
"name": "photos",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_photos); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_photos)
|
||||
|
||||
// add
|
||||
new_distance := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "gal6bffx",
|
||||
"name": "distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_distance); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_distance)
|
||||
|
||||
// add
|
||||
new_duration := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "kimwtlps",
|
||||
"name": "duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_duration); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_duration)
|
||||
|
||||
// add
|
||||
new_elevation_gain := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "80vmdusd",
|
||||
"name": "elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_elevation_gain); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_elevation_gain)
|
||||
|
||||
// add
|
||||
new_elevation_loss := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "mrq3rozi",
|
||||
"name": "elevation_loss",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_elevation_loss); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_elevation_loss)
|
||||
|
||||
// add
|
||||
new_type := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "i4dy54g8",
|
||||
"name": "type",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_type); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_type)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("t9lphichi5xwyeu")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
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 := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "zmvj8lcq",
|
||||
"name": "trail_id",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_trail_id); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_trail_id)
|
||||
|
||||
// add
|
||||
del_date := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "ujwzemal",
|
||||
"name": "date",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_date); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_date)
|
||||
|
||||
// add
|
||||
del_name := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "royuu8hr",
|
||||
"name": "name",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_name); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_name)
|
||||
|
||||
// add
|
||||
del_description := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "e5myhqi1",
|
||||
"name": "description",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_description); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_description)
|
||||
|
||||
// add
|
||||
del_gpx := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "twzxntjy",
|
||||
"name": "gpx",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_gpx); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_gpx)
|
||||
|
||||
// add
|
||||
del_author := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "mbgymehy",
|
||||
"name": "author",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_author); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_author)
|
||||
|
||||
// add
|
||||
del_photos := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "jvd9zgrj",
|
||||
"name": "photos",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_photos); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_photos)
|
||||
|
||||
// add
|
||||
del_distance := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "v6t7ybts",
|
||||
"name": "distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_distance); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_distance)
|
||||
|
||||
// add
|
||||
del_duration := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "vnddbe3a",
|
||||
"name": "duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_duration); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_duration)
|
||||
|
||||
// add
|
||||
del_elevation_gain := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "mp9jqukw",
|
||||
"name": "elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_elevation_gain); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_elevation_gain)
|
||||
|
||||
// add
|
||||
del_elevation_loss := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "c6zw4l4h",
|
||||
"name": "elevation_loss",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_elevation_loss); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_elevation_loss)
|
||||
|
||||
// add
|
||||
del_type := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "njsy8gsh",
|
||||
"name": "type",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_type); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_type)
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("mpcwfh4x")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("xsxx8b8a")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("4ybgblqj")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("f7y3unyx")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("cowkmcyy")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("dgewwftr")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("ugtikydq")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("gal6bffx")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("kimwtlps")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("80vmdusd")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("mrq3rozi")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("i4dy54g8")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,536 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("t9lphichi5xwyeu")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
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.Fields.RemoveById("mpcwfh4x")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("xsxx8b8a")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("4ybgblqj")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("f7y3unyx")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("cowkmcyy")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("dgewwftr")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("ugtikydq")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("gal6bffx")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("kimwtlps")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("80vmdusd")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("mrq3rozi")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("i4dy54g8")
|
||||
|
||||
// add
|
||||
new_trail_id := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "nsakta5t",
|
||||
"name": "trail_id",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_trail_id); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_trail_id)
|
||||
|
||||
// add
|
||||
new_date := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "oahimwtf",
|
||||
"name": "date",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_date); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_date)
|
||||
|
||||
// add
|
||||
new_name := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "t9nlksmj",
|
||||
"name": "name",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_name); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_name)
|
||||
|
||||
// add
|
||||
new_description := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "fzfiex8c",
|
||||
"name": "description",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_description); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_description)
|
||||
|
||||
// add
|
||||
new_gpx := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "1vk5125z",
|
||||
"name": "gpx",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_gpx); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_gpx)
|
||||
|
||||
// add
|
||||
new_author := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "skmgodvs",
|
||||
"name": "author",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_author); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_author)
|
||||
|
||||
// add
|
||||
new_photos := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "5rkwvgcy",
|
||||
"name": "photos",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_photos); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_photos)
|
||||
|
||||
// add
|
||||
new_distance := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "xsuyuifg",
|
||||
"name": "distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_distance); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_distance)
|
||||
|
||||
// add
|
||||
new_duration := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "0hsfxjcm",
|
||||
"name": "duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_duration); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_duration)
|
||||
|
||||
// add
|
||||
new_elevation_gain := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "izyphasx",
|
||||
"name": "elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_elevation_gain); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_elevation_gain)
|
||||
|
||||
// add
|
||||
new_elevation_loss := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "bffz6a6t",
|
||||
"name": "elevation_loss",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_elevation_loss); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_elevation_loss)
|
||||
|
||||
// add
|
||||
new_type := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "2xlfylnh",
|
||||
"name": "type",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), new_type); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(new_type)
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
|
||||
collection, err := app.FindCollectionByNameOrId("t9lphichi5xwyeu")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
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 := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "mpcwfh4x",
|
||||
"name": "trail_id",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_trail_id); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_trail_id)
|
||||
|
||||
// add
|
||||
del_date := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "xsxx8b8a",
|
||||
"name": "date",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_date); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_date)
|
||||
|
||||
// add
|
||||
del_name := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "4ybgblqj",
|
||||
"name": "name",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_name); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_name)
|
||||
|
||||
// add
|
||||
del_description := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "f7y3unyx",
|
||||
"name": "description",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_description); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_description)
|
||||
|
||||
// add
|
||||
del_gpx := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "cowkmcyy",
|
||||
"name": "gpx",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_gpx); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_gpx)
|
||||
|
||||
// add
|
||||
del_author := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "dgewwftr",
|
||||
"name": "author",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_author); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_author)
|
||||
|
||||
// add
|
||||
del_photos := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "ugtikydq",
|
||||
"name": "photos",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_photos); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_photos)
|
||||
|
||||
// add
|
||||
del_distance := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "gal6bffx",
|
||||
"name": "distance",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_distance); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_distance)
|
||||
|
||||
// add
|
||||
del_duration := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "kimwtlps",
|
||||
"name": "duration",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_duration); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_duration)
|
||||
|
||||
// add
|
||||
del_elevation_gain := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "80vmdusd",
|
||||
"name": "elevation_gain",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_elevation_gain); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_elevation_gain)
|
||||
|
||||
// add
|
||||
del_elevation_loss := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "mrq3rozi",
|
||||
"name": "elevation_loss",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_elevation_loss); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_elevation_loss)
|
||||
|
||||
// add
|
||||
del_type := &core.JSONField{}
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "i4dy54g8",
|
||||
"name": "type",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 1
|
||||
}
|
||||
}`), del_type); err != nil {
|
||||
return err
|
||||
}
|
||||
collection.Fields.Add(del_type)
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("nsakta5t")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("oahimwtf")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("t9nlksmj")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("fzfiex8c")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("1vk5125z")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("skmgodvs")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("5rkwvgcy")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("xsuyuifg")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("0hsfxjcm")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("izyphasx")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("bffz6a6t")
|
||||
|
||||
// remove
|
||||
collection.Fields.RemoveById("2xlfylnh")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user