-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
When i only modify the column type to allow null, AutoMigrate does not work. #6372
Comments
https://github.com/go-gorm/gorm/blob/master/migrator/migrator.go#L485 It seems that we should execute alter column when nullable is different, but from the comments, we ignore the change from not null to null. @jinzhu Is there any reason for this? |
Try passing the table struct, not the address |
@darkoment |
+1, still not effective so far. |
+1, facing same error |
@a631807682 This issue can be closed. Thank you. |
@xxxVitoxxx (cc. @jinzhu @a631807682 ) Lines 525 to 531 in deceebf
In upper code, However, in the opposite case, there are restrictions. Because record may have Do I understand correctly?? I create PR about this. Please review. thx. |
Your Question
according to the document. i should be able to use AutoMigrate to modify the column type to allow null on MySQL5.7, but in practice, AutoMigrate is not working.
at first, i used this structure to create the table.
when i drop
not null
of field GoogleID, and executeAutoMigrate
. field GoogleID is still of type not null.the following is log and table describe.
i tried more tests and found that if you want to change the column type to null, you have to modify other column types together, such as size, length...etc
this case is when i drop
not null
constraint and modify size of the GoogleID field, AutoMigrate is working.the following is log and table describe.
I found the same question on issue, but it has not been solved.
The document you expected this should be explained
https://gorm.io/docs/migration.html
Expected answer
when i only change column type to can be a null, AutiMigrate should be working.
The text was updated successfully, but these errors were encountered: