migratecmd

package
v0.16.6 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2023 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.Options{
	TemplateLang: migratecmd.TemplateLangJS, // default to migratecmd.TemplateLangGo
	Automigrate:  true,
	Dir:          "migrations_dir_path", // 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.MustRegisterMigrations].

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, options *Options)

func Register

func Register(app core.App, rootCmd *cobra.Command, options *Options) error

Types

type Options

type Options 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
}

Options defines optional struct to customize the default plugin behavior.

Jump to

Keyboard shortcuts

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