fix: types in m2m

This commit is contained in:
2025-03-16 18:59:27 +07:00
parent 4769971b56
commit 4b5580b1c8
17 changed files with 47 additions and 330 deletions

View File

@@ -1,12 +0,0 @@
package foreign_key_check
type User struct {
Name string
CompanyRefer uint
Company Company `gorm:"foreignKey:CompanyRefer"`
}
type Company struct {
ID int
Name string
}

View File

@@ -1,27 +0,0 @@
package foreign_key_check
type PrepTask struct {
Id uint `gorm:"primaryKey"`
Description string
TaskId uint
WorkAreaId uint
WorkArea `gorm:"foreignKey:WorkAreaIds;constraint:OnDelete:CASCADE;"` // want "Foreign key \"WorkAreaIds\" mentioned in tag at field \"WorkArea\" doesn't exist in model \"PrepTask\""
Deadline int64
}
type WorkArea struct {
Id uint `gorm:"primaryKey"`
Name string
Description string
Performance uint
PrepTasks []PrepTask `gorm:"constraint:OnDelete:CASCADE;"`
}
type Shift struct {
Id uint `gorm:"primaryKey"`
Description string
ProductAmount uint
ShiftDate int64
WorkAreaId string // want "Foreign key should have type like int, not \"string\""
WorkArea WorkArea `gorm:"foreignKey:WorkAreaId;"`
}

View File

@@ -1,26 +0,0 @@
package references_check
// TODO: add test with annotations on back-references
type WorkArea struct {
Id uint `gorm:"primaryKey"`
Workshop Workshop `gorm:"foreignKey:WorkshopId;references:Id;"`
WorkshopId uint
}
type Workshop struct {
Id uint `gorm:"primaryKey"`
Name string
WorkAreas []WorkArea `gorm:"constraint:OnDelete:CASCADE;"`
}
type TeamType struct {
Code uint `gorm:"primaryKey"`
Name string `gorm:"not null"`
}
type TeamTask struct {
Id uint `gorm:"primaryKey"`
TeamTypeId uint
TeamType TeamType `gorm:"references:Code;"`
}

View File

@@ -1,21 +0,0 @@
package references_check
// TODO: add test with annotations on back-references
type User struct {
Name string
CompanyID string
Company Company `gorm:"references:code"` // want "Related field \"code\" doesn't exist on model \"Company\""
}
type Company struct {
ID int
Code string
Name string
}
type Order struct {
Id uint `gorm:"primaryKey"`
CompanyID string `gorm:"references:Code"` // want "Related model \"string\" doesn't exist"
Company Company
}