From 7b5dddfc06917a009b482821869ec5d03d02a2c2 Mon Sep 17 00:00:00 2001 From: seriousm4x Date: Tue, 15 Aug 2023 18:15:46 +0200 Subject: [PATCH] fix: make sol port non-required --- .../migrations/1692116057_updated_devices.go | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 backend/migrations/1692116057_updated_devices.go diff --git a/backend/migrations/1692116057_updated_devices.go b/backend/migrations/1692116057_updated_devices.go new file mode 100644 index 00000000..6f1c1205 --- /dev/null +++ b/backend/migrations/1692116057_updated_devices.go @@ -0,0 +1,64 @@ +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("z5lghx2r3tm45n1") + if err != nil { + return err + } + + // update + edit_sol_port := &schema.SchemaField{} + json.Unmarshal([]byte(`{ + "system": false, + "id": "6kfqheid", + "name": "sol_port", + "type": "number", + "required": false, + "unique": false, + "options": { + "min": 1, + "max": 65535 + } + }`), edit_sol_port) + collection.Schema.AddField(edit_sol_port) + + return dao.SaveCollection(collection) + }, func(db dbx.Builder) error { + dao := daos.New(db); + + collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1") + if err != nil { + return err + } + + // update + edit_sol_port := &schema.SchemaField{} + json.Unmarshal([]byte(`{ + "system": false, + "id": "6kfqheid", + "name": "sol_port", + "type": "number", + "required": true, + "unique": false, + "options": { + "min": 1, + "max": 65535 + } + }`), edit_sol_port) + collection.Schema.AddField(edit_sol_port) + + return dao.SaveCollection(collection) + }) +}