mirror of https://github.com/go-gorm/gorm.git
Fix create with ignore migration (#4571)
This commit is contained in:
parent
82fe815303
commit
21e85b89d6
|
@ -167,10 +167,12 @@ func (m Migrator) CreateTable(values ...interface{}) error {
|
||||||
|
|
||||||
for _, dbName := range stmt.Schema.DBNames {
|
for _, dbName := range stmt.Schema.DBNames {
|
||||||
field := stmt.Schema.FieldsByDBName[dbName]
|
field := stmt.Schema.FieldsByDBName[dbName]
|
||||||
createTableSQL += "? ?"
|
if !field.IgnoreMigration {
|
||||||
hasPrimaryKeyInDataType = hasPrimaryKeyInDataType || strings.Contains(strings.ToUpper(string(field.DataType)), "PRIMARY KEY")
|
createTableSQL += "? ?"
|
||||||
values = append(values, clause.Column{Name: dbName}, m.DB.Migrator().FullDataTypeOf(field))
|
hasPrimaryKeyInDataType = hasPrimaryKeyInDataType || strings.Contains(strings.ToUpper(string(field.DataType)), "PRIMARY KEY")
|
||||||
createTableSQL += ","
|
values = append(values, clause.Column{Name: dbName}, m.DB.Migrator().FullDataTypeOf(field))
|
||||||
|
createTableSQL += ","
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !hasPrimaryKeyInDataType && len(stmt.Schema.PrimaryFields) > 0 {
|
if !hasPrimaryKeyInDataType && len(stmt.Schema.PrimaryFields) > 0 {
|
||||||
|
|
Loading…
Reference in New Issue