migratecmd
import migratecmd "ganigeorgiev.com/pocketbase/pocketbase/plugins/migratecmd"
Package migratecmd adds a new "migrate" command support to a PocketBase instance.
It also comes with automigrations support and templates generation (both for JS and GO migration files).
Example usage:
migratecmd.MustRegister(app, app.RootCmd, migratecmd.Config{
TemplateLang: migratecmd.TemplateLangJS, // default to migratecmd.TemplateLangGo
Automigrate: true,
Dir: "/custom/migrations/dir", // optional template migrations path; default to "pb_migrations" (for JS) and "migrations" (for Go)
})
Note: To allow running JS migrations you'll need to enable first
[jsvm.MustRegister()].
Source: plugins/migratecmd.
Constants
const (
TemplateLangJS = "js"
TemplateLangGo = "go"
)
Variables
var ErrEmptyTemplate = errors.New("empty template")
Functions
MustRegister
func MustRegister(app core.App, rootCmd *cobra.Command, config Config)
MustRegister registers the migratecmd plugin to the provided app instance and panic if it fails.
Example usage:
migratecmd.MustRegister(app, app.RootCmd, migratecmd.Config{})
Register
func Register(app core.App, rootCmd *cobra.Command, config Config) error
Register registers the migratecmd plugin to the provided app instance.
Types
Config
type Config struct {
// Dir specifies the directory with the user defined migrations.
//
// If not set it fallbacks to a relative "pb_data/../pb_migrations" (for js)
// or "pb_data/../migrations" (for go) directory.
Dir string
// Automigrate specifies whether to enable automigrations.
Automigrate bool
// TemplateLang specifies the template language to use when
// generating migrations - js or go (default).
TemplateLang string
}
Config defines the config options of the migratecmd plugin.
Questions and comments
Comments are a GitHub Discussions thread; sign in with GitHub to post.