mirror of
https://github.com/grassrootseconomics/farmstar-survey-backend.git
synced 2024-12-04 15:36:48 +01:00
80 lines
1.6 KiB
Go
80 lines
1.6 KiB
Go
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_purchase_channels := &schema.SchemaField{}
|
|
json.Unmarshal([]byte(`{
|
|
"system": false,
|
|
"id": "fl4s3aca",
|
|
"name": "purchase_channels",
|
|
"type": "select",
|
|
"required": true,
|
|
"presentable": false,
|
|
"unique": false,
|
|
"options": {
|
|
"maxSelect": 5,
|
|
"values": [
|
|
"manufacturers",
|
|
"distributors",
|
|
"resellers",
|
|
"farmers",
|
|
"other",
|
|
"ncpb"
|
|
]
|
|
}
|
|
}`), edit_purchase_channels)
|
|
collection.Schema.AddField(edit_purchase_channels)
|
|
|
|
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_purchase_channels := &schema.SchemaField{}
|
|
json.Unmarshal([]byte(`{
|
|
"system": false,
|
|
"id": "fl4s3aca",
|
|
"name": "purchase_channels",
|
|
"type": "select",
|
|
"required": true,
|
|
"presentable": false,
|
|
"unique": false,
|
|
"options": {
|
|
"maxSelect": 5,
|
|
"values": [
|
|
"manufacturers",
|
|
"distributors",
|
|
"resellers",
|
|
"farmers",
|
|
"other"
|
|
]
|
|
}
|
|
}`), edit_purchase_channels)
|
|
collection.Schema.AddField(edit_purchase_channels)
|
|
|
|
return dao.SaveCollection(collection)
|
|
})
|
|
}
|