We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
go-gorm/playground#549
DB.AutoMigrate automatically migrates associated tables, which is unexpected.
DB.AutoMigrate
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.
There are two tables, T2 is associated with T1, where T1 has a content field of type varchar(xx)
content
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
longtext
The text was updated successfully, but these errors were encountered:
gorm:"-:migration" is not working either.
gorm:"-:migration"
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.
T1
T2
Is this as expected?
Sorry, something went wrong.
fix(migrator): ignore relationships when migrating go-gorm#5913
1124d83
97faea8
969e2a0
fix(migrator): ignore relationships when migrating #5913 (#5946)
da2b286
jinzhu
Successfully merging a pull request may close this issue.
GORM Playground Link
go-gorm/playground#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 typevarchar(xx)
When I run the following codes
The
content
field type of t1 is changed tolongtext
The text was updated successfully, but these errors were encountered: