mirror of
https://github.com/grassrootseconomics/farmstar-survey-backend.git
synced 2024-12-12 11:16:10 +01:00
86 lines
1.6 KiB
Go
86 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("uutt9wj7d5ejmhz")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
// update
|
||
|
edit_county := &schema.SchemaField{}
|
||
|
json.Unmarshal([]byte(`{
|
||
|
"system": false,
|
||
|
"id": "murxdavm",
|
||
|
"name": "county",
|
||
|
"type": "select",
|
||
|
"required": true,
|
||
|
"presentable": false,
|
||
|
"unique": false,
|
||
|
"options": {
|
||
|
"maxSelect": 1,
|
||
|
"values": [
|
||
|
"kirinyaga",
|
||
|
"muranga",
|
||
|
"nakuru",
|
||
|
"meru",
|
||
|
"uasin_gishu",
|
||
|
"kajiado",
|
||
|
"kericho",
|
||
|
"elgeyo_marakwet",
|
||
|
"kakamega",
|
||
|
"bungoma",
|
||
|
"nyandarua"
|
||
|
]
|
||
|
}
|
||
|
}`), edit_county)
|
||
|
collection.Schema.AddField(edit_county)
|
||
|
|
||
|
return dao.SaveCollection(collection)
|
||
|
}, func(db dbx.Builder) error {
|
||
|
dao := daos.New(db);
|
||
|
|
||
|
collection, err := dao.FindCollectionByNameOrId("uutt9wj7d5ejmhz")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
// update
|
||
|
edit_county := &schema.SchemaField{}
|
||
|
json.Unmarshal([]byte(`{
|
||
|
"system": false,
|
||
|
"id": "murxdavm",
|
||
|
"name": "county",
|
||
|
"type": "select",
|
||
|
"required": true,
|
||
|
"presentable": false,
|
||
|
"unique": false,
|
||
|
"options": {
|
||
|
"maxSelect": 1,
|
||
|
"values": [
|
||
|
"kirinyaga",
|
||
|
"muranga",
|
||
|
"nakuru",
|
||
|
"meru",
|
||
|
"uasin_gishu",
|
||
|
"kajiado"
|
||
|
]
|
||
|
}
|
||
|
}`), edit_county)
|
||
|
collection.Schema.AddField(edit_county)
|
||
|
|
||
|
return dao.SaveCollection(collection)
|
||
|
})
|
||
|
}
|