Ignore those fields don't have valid sql type when auto migrate

This commit is contained in:
Jinzhu 2013-11-07 13:21:19 +08:00
parent 272ad45943
commit 913757c103
1 changed files with 2 additions and 2 deletions

4
do.go
View File

@ -745,8 +745,8 @@ func (s *Do) autoMigrate() *Do {
s.sqlVars = []interface{}{}
// If column doesn't exist
if len(column_name) == 0 {
s.sql = fmt.Sprintf("ALTER TABLE %v ADD %v %v", s.tableName(), field.DbName, field.SqlType)
if len(column_name) == 0 && len(field.SqlType) > 0 {
s.sql = fmt.Sprintf("ALTER TABLE %v ADD %v %v;", s.tableName(), field.DbName, field.SqlType)
s.exec()
}
}