adds elevation loss for trails

This commit is contained in:
Christian Beutel
2024-11-09 12:56:11 +01:00
parent 0ab0eda612
commit 01b0d49913
11 changed files with 108 additions and 19 deletions

View File

@@ -0,0 +1,55 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
if err != nil {
return err
}
// add
new_elevation_loss := &schema.SchemaField{}
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.Schema.AddField(new_elevation_loss)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
if err != nil {
return err
}
// remove
collection.Schema.RemoveField("xutbwpq4")
return dao.SaveCollection(collection)
})
}