Files
wanderer/db/migrations/1712169931_updated_trails.go
Christian Beutel 76522c808a adds comments
2024-04-03 22:28:34 +02:00

56 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("e864strfxo14pm4")
if err != nil {
return err
}
// add
new_comments := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "phhhroww",
"name": "comments",
"type": "relation",
"required": false,
"presentable": false,
"unique": false,
"options": {
"collectionId": "lf06qip3f4d11yk",
"cascadeDelete": false,
"minSelect": null,
"maxSelect": null,
"displayFields": null
}
}`), new_comments)
collection.Schema.AddField(new_comments)
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("phhhroww")
return dao.SaveCollection(collection)
})
}