newscripts

package
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2025 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NextScriptCmd added in v0.0.13

func NextScriptCmd(config *Config) *cobra.Command

Types

type Config added in v0.0.13

type Config struct {
	Migration *migrate.Migrate
	Options   *Options
	DB        *gorm.DB
	Objects   []interface{} // object list of your gorm models
}

type NextScriptInfo added in v0.0.15

type NextScriptInfo struct {
	Action      ScriptAction
	ForwardName string
	ReverseName string
}

func GetNextScriptInfo added in v0.0.15

func GetNextScriptInfo(migration *migrate.Migrate, options *Options, naming *ScriptNaming) *NextScriptInfo

func (*NextScriptInfo) GetScriptNames added in v0.0.17

func (scriptInfo *NextScriptInfo) GetScriptNames() *NextScriptNames

func (*NextScriptInfo) ScriptExists added in v0.0.15

func (scriptInfo *NextScriptInfo) ScriptExists(options *Options) bool

func (*NextScriptInfo) WriteScripts added in v0.0.15

func (scriptInfo *NextScriptInfo) WriteScripts(migrationOps checkmigration.MigrationOps, options *Options)

type NextScriptNames added in v0.0.17

type NextScriptNames struct {
	ForwardName string
	ReverseName string
}

type Options

type Options struct {
	ScriptsInRoot string
	DryRun        bool
	SurveyWritten bool
	DefaultSuffix string
}

func NewOptions

func NewOptions(scriptsInRoot string) *Options

type ScriptAction

type ScriptAction string
const (
	CreateScript ScriptAction = "create-script"
	UpdateScript ScriptAction = "update-script"
)

type ScriptNaming added in v0.0.13

type ScriptNaming struct {
	VersionType VersionPattern
	Description string // {version}_{description}.up.sql {version}_{description}.down.sql 里的 description
}

func NewScriptNaming added in v0.0.13

func NewScriptNaming() *ScriptNaming

func (*ScriptNaming) NewScriptPrefix added in v0.0.13

func (T *ScriptNaming) NewScriptPrefix(version uint) string

type VersionPattern added in v0.0.13

type VersionPattern string
const (
	VersionNext VersionPattern = "NEXT" // 自动递增编号,例如 00001, 00002
	VersionUnix VersionPattern = "UNIX" // 以 Unix 时间戳为版本号,例如 1678693920
	VersionTime VersionPattern = "TIME" // 格式化时间,纯数字的 年月日+时分秒 版本号,例如 20250621103045
)

Jump to

Keyboard shortcuts

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