Feature Template Module Titles (Test)

This commit is contained in:
survellow
2023-10-18 00:53:06 +02:00
parent 01e32448c9
commit ccd164bb07
8 changed files with 289 additions and 24 deletions

View File

@@ -0,0 +1,52 @@
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("7her4515qsmrxe8")
if err != nil {
return err
}
// add
new_Compulsory := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "vgmhhgcz",
"name": "Compulsory",
"type": "text",
"required": false,
"unique": false,
"options": {
"min": null,
"max": null,
"pattern": ""
}
}`), new_Compulsory)
collection.Schema.AddField(new_Compulsory)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("7her4515qsmrxe8")
if err != nil {
return err
}
// remove
collection.Schema.RemoveField("vgmhhgcz")
return dao.SaveCollection(collection)
})
}