feat: delete constraint for belongs to and has one

This commit is contained in:
2025-03-18 03:29:00 +07:00
parent 4536be4d10
commit ffbeccc4fd
4 changed files with 10 additions and 4 deletions

View File

@@ -65,8 +65,8 @@ type ShoppingCart struct {
// Has one
type Hotel struct {
Id uint `gorm:"primaryKey"`
Office
Id uint `gorm:"primaryKey"`
Office // want "field Office should have a delete constraint"
}
type Office struct {

View File

@@ -45,7 +45,7 @@ type Owner struct {
Id uint `gorm:"primaryKey"`
Name string
CompanyId int
Company Company
Company Company `gorm:"constraint:OnDelete:CASCADE;"`
}
type Company struct {