-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Closed
Labels
type:feature_requestfeature requestfeature request
Description
Description
type Parent struct {
ParentID uuid.UUID `gorm:"type:uuid;primary_key;" json:"parentId,omitempty"`
Name string `gorm:"type:varchar(255)" json:"name"`
}
type Child struct {
ChildID uuid.UUID `gorm:"type:uuid;primary_key;" json:"childId"`
Name string `gorm:"type:varchar(255)" json:"name"`
// Foreign Key
Parent Parent `gorm:"foreignkey:ParentID;constraint:OnDelete:CASCADE;"`
}
main.go:
func main() {
. . .
// Auto Migrate
//
db.AutoMigrate(
&models.Parent{},
&models.Child{},
)
The existing model contained the FK relation already defined/applied to the DB. When I added the constraint to cascade DELETE (constraint:OnDelete:CASCADE;) and started up the server, I don't see this as having been applied.
Is this by design, or is this a bug? I found the following issue (#4110) which added support for migrating unique constraints. Perhaps OnDelete/OnUpdate require such a fix as well?
alfonmga, philicious and bkmeneguello
Metadata
Metadata
Assignees
Labels
type:feature_requestfeature requestfeature request