MCPcopy
hub / github.com/pocketbase/pocketbase / Register

Function Register

plugins/migratecmd/migratecmd.go:61–89  ·  view source on GitHub ↗

Register registers the migratecmd plugin to the provided app instance.

(app core.App, rootCmd *cobra.Command, config Config)

Source from the content-addressed store, hash-verified

59
60// Register registers the migratecmd plugin to the provided app instance.
61func Register(app core.App, rootCmd *cobra.Command, config Config) error {
62 p := &plugin{app: app, config: config}
63
64 if p.config.TemplateLang == "" {
65 p.config.TemplateLang = TemplateLangGo
66 }
67
68 if p.config.Dir == "" {
69 if p.config.TemplateLang == TemplateLangJS {
70 p.config.Dir = filepath.Join(p.app.DataDir(), "../pb_migrations")
71 } else {
72 p.config.Dir = filepath.Join(p.app.DataDir(), "../migrations")
73 }
74 }
75
76 // attach the migrate command
77 if rootCmd != nil {
78 rootCmd.AddCommand(p.createCommand())
79 }
80
81 // watch for collection changes
82 if p.config.Automigrate {
83 p.app.OnCollectionCreateRequest().BindFunc(p.automigrateOnCollectionChange)
84 p.app.OnCollectionUpdateRequest().BindFunc(p.automigrateOnCollectionChange)
85 p.app.OnCollectionDeleteRequest().BindFunc(p.automigrateOnCollectionChange)
86 }
87
88 return nil
89}
90
91type plugin struct {
92 app core.App

Callers 1

MustRegisterFunction · 0.70

Calls 6

createCommandMethod · 0.95
DataDirMethod · 0.65
BindFuncMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…