Skip to content
New issue

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

[#6372] Fixed nullable constraint bug for columns during auto migration #7269

Merged
merged 10 commits into from
Nov 14, 2024
4 changes: 2 additions & 2 deletions migrator/migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,8 @@ func (m Migrator) MigrateColumn(value interface{}, field *schema.Field, columnTy

// check nullable
if nullable, ok := columnType.Nullable(); ok && nullable == field.NotNull {
// not primary key & database is nullable
if !field.PrimaryKey && nullable {
// not primary key & current database is non-nullable(to be nullable)
if !field.PrimaryKey && !nullable {
alterColumn = true
}
}
Expand Down
Loading