mirror of
https://github.com/grassrootseconomics/farmstar-survey-backend.git
synced 2024-11-19 16:26:47 +01:00
54 lines
1.1 KiB
Go
54 lines
1.1 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("no89qd9ku8qo11e")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
// add
|
||
|
new_blockchain_address := &schema.SchemaField{}
|
||
|
json.Unmarshal([]byte(`{
|
||
|
"system": false,
|
||
|
"id": "hlbyntap",
|
||
|
"name": "blockchain_address",
|
||
|
"type": "text",
|
||
|
"required": true,
|
||
|
"presentable": false,
|
||
|
"unique": false,
|
||
|
"options": {
|
||
|
"min": null,
|
||
|
"max": null,
|
||
|
"pattern": ""
|
||
|
}
|
||
|
}`), new_blockchain_address)
|
||
|
collection.Schema.AddField(new_blockchain_address)
|
||
|
|
||
|
return dao.SaveCollection(collection)
|
||
|
}, func(db dbx.Builder) error {
|
||
|
dao := daos.New(db);
|
||
|
|
||
|
collection, err := dao.FindCollectionByNameOrId("no89qd9ku8qo11e")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
// remove
|
||
|
collection.Schema.RemoveField("hlbyntap")
|
||
|
|
||
|
return dao.SaveCollection(collection)
|
||
|
})
|
||
|
}
|