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("dd2l9a4vxpy2ni8") if err != nil { return err } // update edit_photos := &schema.SchemaField{} if err := json.Unmarshal([]byte(`{ "system": false, "id": "ixnksbkt", "name": "photos", "type": "file", "required": false, "presentable": false, "unique": false, "options": { "mimeTypes": [ "image/jpeg", "image/png", "image/vnd.mozilla.apng", "image/webp", "image/svg+xml", "image/heic" ], "thumbs": [], "maxSelect": 99, "maxSize": 20971520, "protected": false } }`), edit_photos); err != nil { return err } collection.Schema.AddField(edit_photos) // update edit_author := &schema.SchemaField{} if err := json.Unmarshal([]byte(`{ "system": false, "id": "r0mj3tkr", "name": "author", "type": "relation", "required": true, "presentable": false, "unique": false, "options": { "collectionId": "_pb_users_auth_", "cascadeDelete": false, "minSelect": null, "maxSelect": 1, "displayFields": null } }`), edit_author); err != nil { return err } collection.Schema.AddField(edit_author) return dao.SaveCollection(collection) }, func(db dbx.Builder) error { dao := daos.New(db); collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8") if err != nil { return err } // update edit_photos := &schema.SchemaField{} if err := json.Unmarshal([]byte(`{ "system": false, "id": "ixnksbkt", "name": "photos", "type": "file", "required": false, "presentable": false, "unique": false, "options": { "mimeTypes": [ "image/jpeg", "image/png", "image/vnd.mozilla.apng", "image/webp", "image/svg+xml", "image/heic" ], "thumbs": [], "maxSelect": 99, "maxSize": 5242880, "protected": false } }`), edit_photos); err != nil { return err } collection.Schema.AddField(edit_photos) // update edit_author := &schema.SchemaField{} if err := json.Unmarshal([]byte(`{ "system": false, "id": "r0mj3tkr", "name": "author", "type": "relation", "required": true, "presentable": false, "unique": false, "options": { "collectionId": "_pb_users_auth_", "cascadeDelete": true, "minSelect": null, "maxSelect": 1, "displayFields": null } }`), edit_author); err != nil { return err } collection.Schema.AddField(edit_author) return dao.SaveCollection(collection) }) }