Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions projects/gorm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,33 @@
)

// University model
type University struct {

Check warning on line 10 in projects/gorm/main.go

View workflow job for this annotation

GitHub Actions / schema-lint

Table universities must have a unique non-id column
gorm.Model
Name string `gorm:"type:varchar(200);unique;not null"`
Name string `gorm:"type:varchar(200);not null"`
Location string `gorm:"type:varchar(100);not null"`
EstablishedDate time.Time `gorm:"type:date"`
Departments []Department // One-to-Many relationship: A University has many Departments
}

// Department model
type Department struct {

Check warning on line 19 in projects/gorm/main.go

View workflow job for this annotation

GitHub Actions / schema-lint

Foreign key fk_universities_departments must not be nullable
gorm.Model
Name string `gorm:"type:varchar(100);unique;not null"`
HeadOfDepartment string `gorm:"type:varchar(100)"`
UniversityID uint `gorm:"not null"`
Name string `gorm:"type:varchar(100);unique;not null"`
HeadOfDepartment string `gorm:"type:varchar(100)"`
UniversityID uint
University University `gorm:"constraint:OnDelete:CASCADE"`
Students []Student // One-to-Many relationship: A Department has many Students
}

// Student model
type Student struct {

Check warning on line 29 in projects/gorm/main.go

View workflow job for this annotation

GitHub Actions / schema-lint

Foreign key fk_departments_students must have a column name ending with '_id'
gorm.Model
FirstName string `gorm:"type:varchar(50);not null"`
LastName string `gorm:"type:varchar(50);not null"`
StudentIDNumber string `gorm:"type:varchar(20);unique;not null"`
DateOfBirth time.Time `gorm:"type:date"`
Email string `gorm:"type:varchar(255);unique;not null"`
EnrollmentDate time.Time `gorm:"autoCreateTime;type:date"`
DepartmentID *uint
FirstName string `gorm:"type:varchar(50);not null"`
LastName string `gorm:"type:varchar(50);not null"`
StudentIDNumber string `gorm:"type:varchar(20);unique;not null"`
DateOfBirth time.Time `gorm:"type:date"`
Email string `gorm:"type:varchar(255);unique;not null"`
EnrollmentDate time.Time `gorm:"autoCreateTime;type:date"`
DepartmentID *uint `gorm:"column:department_link"`
Department *Department `gorm:"constraint:OnDelete:SET NULL;"` // Belongs-to relationship, SET NULL on delete
}
Loading