Documentation ¶
Overview ¶
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()].
Index ¶
Constants ¶
View Source
const ( TemplateLangJS = "js" TemplateLangGo = "go" )
Variables ¶
View Source
var ErrEmptyTemplate = errors.New("empty template")
Functions ¶
func MustRegister ¶
MustRegister registers the migratecmd plugin to the provided app instance and panic if it fails.
Example usage:
migratecmd.MustRegister(app, app.RootCmd, migratecmd.Config{})
Types ¶
type Config ¶ added in v0.17.0
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.
Click to show internal directories.
Click to hide internal directories.