up

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &cobra.Command{
	Use:   "up",
	Short: "更新数据库",
	Long:  `更新数据库`,
	RunE: func(cmd *cobra.Command, args []string) error {
		var cmdParse clap.YamlConfig
		if clap.GenPath != "" {
			if configFileParams, err := clap.LoadConfigFile(clap.GenPath); err == nil && configFileParams != nil {
				cmdParse = *configFileParams
			}
		} else {

			if sourceURL != "" {
				cmdParse.SourceURL = sourceURL
			}
			if sourceURL == "" && path != "" {
				cmdParse.SourceURL = path
			}
			if databaseURL != "" {
				cmdParse.DatabaseURL = databaseURL
			}
		}
		m, err := migrate.New(cmdParse.SourceURL, cmdParse.DatabaseURL)
		if err != nil {
			return err
		}
		defer func() {
			if _, err := m.Close(); err != nil {
				log.Error(err)
			}
		}()
		if err = m.Up(); err != nil {
			if errors.Is(err, migrate.ErrNoChange) {
				return nil
			}
			return err
		}
		return nil
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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