generate

package
v4.11.4+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2019 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConfigCmd = &cobra.Command{
	Use:              "config",
	Short:            "Generates a database.yml file for your project.",
	PersistentPreRun: func(c *cobra.Command, args []string) {},
	RunE: func(cmd *cobra.Command, args []string) error {
		cflag := cmd.Flag("config")
		cflagVal := ""
		if cflag != nil {
			cflagVal = cflag.Value.String()
		}
		cfgFile := defaults.String(cflagVal, "database.yml")

		run := genny.WetRunner(context.Background())

		pwd, _ := os.Getwd()
		g, err := config.New(&config.Options{
			Root:     pwd,
			Prefix:   filepath.Base(pwd),
			FileName: cfgFile,
			Dialect:  dialect,
		})
		if err != nil {
			return err
		}
		run.With(g)

		return run.Run()
	},
}

ConfigCmd is the command to generate pop config files

View Source
var FizzCmd = &cobra.Command{
	Use:     "fizz [name]",
	Aliases: []string{"migration"},
	Short:   "Generates Up/Down migrations for your database using fizz.",
	RunE: func(cmd *cobra.Command, args []string) error {
		if len(args) == 0 {
			return errors.New("you must supply a name for your migration")
		}
		cflag := cmd.Flag("path")
		migrationPath := defaults.String(cflag.Value.String(), "./migrations")
		return pop.MigrationCreate(migrationPath, args[0], "fizz", nil, nil)
	},
}

FizzCmd generates a new fizz migration

View Source
var ModelCmd = &cobra.Command{
	Use:     "model [name]",
	Aliases: []string{"m"},
	Short:   "Generates a model for your database",
	RunE: func(cmd *cobra.Command, args []string) error {
		if len(args) == 0 {
			return errors.New("you must supply a name for your model")
		}

		p := cmd.Flag("path")
		e := cmd.Flag("env")
		data := map[string]interface{}{
			"skipMigration": modelCmdConfig.SkipMigration,
			"marshalType":   modelCmdConfig.StructTag,
			"migrationType": modelCmdConfig.MigrationType,
			"modelPath":     modelCmdConfig.ModelPath,
			"path":          p.Value.String(),
			"env":           e.Value.String(),
		}
		return Model(args[0], data, args[1:])
	},
}

ModelCmd is the cmd to generate a model

View Source
var SQLCmd = &cobra.Command{
	Use:   "sql [name]",
	Short: "Generates Up/Down migrations for your database using SQL.",
	RunE: func(cmd *cobra.Command, args []string) error {
		if len(args) == 0 {
			return errors.New("you must supply a name for your migration")
		}
		cflag := cmd.Flag("path")
		migrationPath := defaults.String(cflag.Value.String(), "./migrations")
		return pop.MigrationCreate(migrationPath, args[0], "sql", nil, nil)
	},
}

SQLCmd generates a SQL migration

Functions

func Config

func Config(cfgFile string, data map[string]interface{}) error

Config generates pop configuration files. Deprecated: use github.com/gobuffalo/pop/genny/config instead.

func GenerateConfig deprecated

func GenerateConfig(cfgFile string, data map[string]interface{}) error

GenerateConfig generates pop configuration files.

Deprecated: use github.com/gobuffalo/pop/genny/config instead.

func Model

func Model(name string, opts map[string]interface{}, attributes []string) error

Model generates new model files to work with pop.

Types

This section is empty.

Jump to

Keyboard shortcuts

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