We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible to automigrate all structs automatically?
Currently it seems like the name of each struct to migrate needs to be passed to this function https://github.com/jinzhu/gorm/blob/690cb1430c2e27011324c51826301a7daf728e65/main.go#L261
The text was updated successfully, but these errors were encountered:
Because gorm can't know which struct you want to migrate, so can't do this automatically.
But I am doing something like this in my application.
package main import ( "fmt" . "xxx.com/xxxx/xxxx/app/models" . "xxx.com/xxxx/xxxx/db" "reflect" ) func main() { for _, model := range []interface{}{ Payment{}, Invoice{}, Transaction{}, SubscriptionService{}, SubscriptionBenefit{}, Subscription{}, Address{}, User{}, UserService{}, Service{}, } { if err := DB.AutoMigrate(model).Error; err != nil { fmt.Println(err) } else { fmt.Println("Auto migrating", reflect.TypeOf(model).Name(), "...") } } }
Sorry, something went wrong.
Thanks for the tip!
On Thu, Jan 2, 2014 at 1:49 PM, Jinzhu notifications@github.com wrote:
Closed #38 https://github.com/jinzhu/gorm/issues/38. — Reply to this email directly or view it on GitHubhttps://github.com/jinzhu/gorm/issues/38 .
Closed #38 https://github.com/jinzhu/gorm/issues/38.
— Reply to this email directly or view it on GitHubhttps://github.com/jinzhu/gorm/issues/38 .
Now, do you have a new method to solve it ? Thanks. @jinzhu
No branches or pull requests
Is it possible to automigrate all structs automatically?
Currently it seems like the name of each struct to migrate needs to be passed to this function https://github.com/jinzhu/gorm/blob/690cb1430c2e27011324c51826301a7daf728e65/main.go#L261
The text was updated successfully, but these errors were encountered: