adds trail difficulty property
This commit is contained in:
@@ -29,6 +29,7 @@ func indexRecord(r *models.Record, client *meilisearch.Client) error {
|
||||
"distance": r.GetFloat("distance"),
|
||||
"elevation_gain": r.GetFloat("elevation_gain"),
|
||||
"duration": r.GetFloat("duration"),
|
||||
"difficulty": r.Get("difficulty"),
|
||||
"category": r.Get("category"),
|
||||
"completed": len(r.GetStringSlice("summit_logs")) > 0,
|
||||
"created": r.GetDateTime("created"),
|
||||
|
||||
56
db/migrations/1710073788_updated_trails.go
Normal file
56
db/migrations/1710073788_updated_trails.go
Normal file
@@ -0,0 +1,56 @@
|
||||
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_difficulty := &schema.SchemaField{}
|
||||
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.Schema.AddField(new_difficulty)
|
||||
|
||||
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("dywtnynw")
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user