Closed
Description
Your Question
When I use AutoMigrate a struct with DEFAULT:0 tag, it will always ALTER TABLE when I restart the program.
type TestTable struct {
ID uint
Name string `gorm:"type:varchar(20);NOT NULL;DEFAULT:''"`
UserID uint `gorm:"type:int;NOT NULL;DEFAULT:0"`
Status uint `gorm:"type:tinyint;NOT NULL;DEFAULT:0"`
}
It will log this
***/vendor/gorm.io/driver/mysql/migrator.go:83
[140.971ms] [rows:0] ALTER TABLE `test_tables` MODIFY COLUMN `user_id` bigint NOT NULL DEFAULT 0
[174.141ms] [rows:0] ALTER TABLE `test_tables` MODIFY COLUMN `status` tinyint NOT NULL DEFAULT 0
But it is in right state when I see the mysql table. And the 'Name' field DEFAULT:'', it wont ALTER table.
Did I use it wrong?
GORM.version: v1.20.5
GORM.driver.mysql.version: v1.0.3
GORM.datatypes.version: v1.0.0
mysql.version: 8.0.14
The document you expected this should be explained
Not ALTER TABLE when restart program
Expected answer
Is that a BUG?
How do I use it?