Skip to content

Commit

Permalink
Fix model generator (#223)
Browse files Browse the repository at this point in the history
* Fix model generator

Move missing options to the opts parameter.

* Fix missing migrationType
  • Loading branch information
stanislas-m authored and mclark4386 committed Sep 28, 2018
1 parent e6c9fe6 commit 1db5e34
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions soda/cmd/generate/model_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ var ModelCmd = &cobra.Command{
p := cmd.Flag("path")
e := cmd.Flag("env")
data := map[string]interface{}{
"marshalType": structTag,
"path": p.Value.String(),
"env": e.Value.String(),
"skipMigration": skipMigration,
"marshalType": structTag,
"migrationType": migrationType,
"path": p.Value.String(),
"env": e.Value.String(),
}
return Model(args[0], data, args[1:])
},
Expand Down Expand Up @@ -82,15 +84,21 @@ func Model(name string, opts map[string]interface{}, attributes []string) error
return err
}

if skipMigration {
sm, found := opts["skipMigration"].(bool)
if found && sm {
return nil
}

p, found := opts["path"].(string)
if !found {
return errors.New("path option is required")
}
switch migrationType {

migrationT, found := opts["migrationType"].(string)
if !found {
return errors.New("migrationType option is required")
}
switch migrationT {
case "sql":
env, found := opts["env"].(string)
if !found {
Expand Down

0 comments on commit 1db5e34

Please sign in to comment.