diff --git a/migrator/migrator.go b/migrator/migrator.go index 075b5ca6..1800ab54 100644 --- a/migrator/migrator.go +++ b/migrator/migrator.go @@ -295,10 +295,13 @@ func (m Migrator) RenameTable(oldName, newName interface{}) error { func (m Migrator) AddColumn(value interface{}, field string) error { return m.RunWithValue(value, func(stmt *gorm.Statement) error { if field := stmt.Schema.LookUpField(field); field != nil { - return m.DB.Exec( - "ALTER TABLE ? ADD ? ?", - m.CurrentTable(stmt), clause.Column{Name: field.DBName}, m.DB.Migrator().FullDataTypeOf(field), - ).Error + if !field.IgnoreMigration { + return m.DB.Exec( + "ALTER TABLE ? ADD ? ?", + m.CurrentTable(stmt), clause.Column{Name: field.DBName}, m.DB.Migrator().FullDataTypeOf(field), + ).Error + } + return nil } return fmt.Errorf("failed to look up field with name: %s", field) })