farmstar-survey-backend/migrations/1714103895_updated_farmer_evergrow.go

98 lines
1.9 KiB
Go
Raw Permalink Normal View History

2024-04-26 06:00:33 +02:00
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("4f0a5b2wec6okxi")
if err != nil {
return err
}
// update
edit_evergrow_crops := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "5kxslfpx",
"name": "evergrow_crops",
"type": "select",
"required": false,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 12,
"values": [
"rice",
"coffee",
"tea",
"sugarcane",
"miraa",
"avocados",
"maize",
"potatoes",
"sorghum",
"other_fruits",
"other_vegetables",
"other_grains",
"dragonfruit",
"hay",
"beans",
"soya"
]
}
}`), edit_evergrow_crops)
collection.Schema.AddField(edit_evergrow_crops)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("4f0a5b2wec6okxi")
if err != nil {
return err
}
// update
edit_evergrow_crops := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "5kxslfpx",
"name": "evergrow_crops",
"type": "select",
"required": false,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 12,
"values": [
"rice",
"coffee",
"tea",
"sugarcane",
"miraa",
"avocados",
"maize",
"potatoes",
"sorghum",
"other_fruits",
"other_vegetables",
"other_grains",
"dragonfruit"
]
}
}`), edit_evergrow_crops)
collection.Schema.AddField(edit_evergrow_crops)
return dao.SaveCollection(collection)
})
}