GORM Playground Link
https://github.com/go-gorm/playground/pull/549
Description
DB.AutoMigrate automatically migrates associated tables, which is unexpected.
This led to an intolerable production environment accident. When I published a new feature to production it modified many existing tables.
If this is a feature but not a bug, there should be a configuration to disable it.
Example
There are two tables, T2 is associated with T1, where T1 has a content field of type varchar(xx)
type T1 struct {
gorm.Model
Content string
}
type T2 struct {
gorm.Model
T1ID uint
T1 *T1
}
When I run the following codes
DB.AutoMigrate(&T2{})
The content field type of t1 is changed to longtext
Comment From: Nomango
gorm:"-:migration" is not working either.
E.g.
type T1 struct {
gorm.Model
Content string
}
type T2 struct {
gorm.Model
T1ID uint
T1 *T1 `gorm:"-:migration"`
}
DB.AutoMigrate(&T2{})
T1 is always modified after migrating T2.
Is this as expected?