feat: scheduler (#1108)

This commit is contained in:
Jonas Plum
2024-11-04 22:30:20 +01:00
committed by GitHub
parent 42797509f7
commit a2bdeecb0d
8 changed files with 208 additions and 16 deletions

View File

@@ -0,0 +1,28 @@
package migrations
import (
"fmt"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
"github.com/pocketbase/pocketbase/models/schema"
)
func reactionsUpdateUp(db dbx.Builder) error {
dao := daos.New(db)
triggers := []string{"webhook", "hook", "schedule"}
col, err := dao.FindCollectionByNameOrId(ReactionCollectionName)
if err != nil {
return fmt.Errorf("failed to find collection %s: %w", ReactionCollectionName, err)
}
field := col.Schema.GetFieldByName("trigger")
field.Options = &schema.SelectOptions{MaxSelect: 1, Values: triggers}
col.Schema.AddField(field)
return dao.SaveCollection(col)
}

View File

@@ -13,4 +13,5 @@ func Register() {
migrations.Register(systemuserUp, systemuserDown, "1700000006_systemuser.go")
migrations.Register(searchViewUp, searchViewDown, "1700000007_search_view.go")
migrations.Register(dashboardCountsViewUpdateUp, dashboardCountsViewUpdateDown, "1700000008_dashboardview.go")
migrations.Register(reactionsUpdateUp, nil, "1700000009_reactions_update.go")
}