migratecmd

package
v0.0.0-...-8c22e84 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2024 License: MIT Imports: 20 Imported by: 0

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

This section is empty.

Functions

func 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{})

func Register

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

Register registers the migratecmd plugin to the provided app instance.

Types

type 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL