github.com/dolanor/pop@v4.13.0+incompatible/genny/fizz/cempty/create_empty.go (about) 1 package cempty 2 3 import ( 4 "fmt" 5 "path/filepath" 6 7 "github.com/gobuffalo/genny" 8 ) 9 10 // New creates a generator to make empty migration files. 11 func New(opts *Options) (*genny.Generator, error) { 12 g := genny.New() 13 14 if err := opts.Validate(); err != nil { 15 return g, err 16 } 17 18 var f genny.File 19 if opts.Type == "sql" { 20 f = genny.NewFileS(filepath.Join(opts.Path, fmt.Sprintf("%s.%s.up.sql", opts.Name, opts.Translator.Name())), "") 21 g.File(f) 22 f = genny.NewFileS(filepath.Join(opts.Path, fmt.Sprintf("%s.%s.down.sql", opts.Name, opts.Translator.Name())), "") 23 g.File(f) 24 } else { 25 f = genny.NewFileS(filepath.Join(opts.Path, opts.Name+".up.fizz"), "") 26 g.File(f) 27 f = genny.NewFileS(filepath.Join(opts.Path, opts.Name+".down.fizz"), "") 28 g.File(f) 29 } 30 return g, nil 31 }