Skip to content

Commit

Permalink
Fix create_table must be in plural form (#448)
Browse files Browse the repository at this point in the history
Fixes #447
  • Loading branch information
stanislas-m committed Oct 18, 2019
1 parent 88a44ed commit 1c19a1a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions genny/fizz/ctable/create_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ func Test_New(t *testing.T) {
},
`create_table("widgets") {
t.Timestamps()
}`,
},
{
&Options{
TableName: "widget",
Name: "create_widgets",
ForceDefaultTimestamps: true,
},
`create_table("widgets") {
t.Timestamps()
}`,
},
{
Expand Down
3 changes: 2 additions & 1 deletion genny/fizz/ctable/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@ func (opts *Options) Validate() error {
if len(opts.TableName) == 0 {
return errors.New("you must set a name for your table")
}
opts.TableName = name.New(opts.TableName).Tableize().String()
if len(opts.Path) == 0 {
opts.Path = "migrations"
}
if len(opts.Name) == 0 {
timestamp := nowFunc().UTC().Format("20060102150405")
opts.Name = fmt.Sprintf("%s_create_%s", timestamp, name.New(opts.TableName).Tableize())
opts.Name = fmt.Sprintf("%s_create_%s", timestamp, opts.TableName)
}
if len(opts.Type) == 0 {
opts.Type = "fizz"
Expand Down

0 comments on commit 1c19a1a

Please sign in to comment.