Skip to content

Commit 8d3f3db

Browse files
projects/gorm: example updates violate rules
1 parent 43e8ad2 commit 8d3f3db

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

projects/gorm/main.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
// University model
1010
type University struct {
1111
gorm.Model
12-
Name string `gorm:"type:varchar(200);unique;not null"`
12+
Name string `gorm:"type:varchar(200);not null"`
1313
Location string `gorm:"type:varchar(100);not null"`
1414
EstablishedDate time.Time `gorm:"type:date"`
1515
Departments []Department // One-to-Many relationship: A University has many Departments
@@ -18,22 +18,22 @@ type University struct {
1818
// Department model
1919
type Department struct {
2020
gorm.Model
21-
Name string `gorm:"type:varchar(100);unique;not null"`
22-
HeadOfDepartment string `gorm:"type:varchar(100)"`
23-
UniversityID uint `gorm:"not null"`
21+
Name string `gorm:"type:varchar(100);unique;not null"`
22+
HeadOfDepartment string `gorm:"type:varchar(100)"`
23+
UniversityID uint
2424
University University `gorm:"constraint:OnDelete:CASCADE"`
2525
Students []Student // One-to-Many relationship: A Department has many Students
2626
}
2727

2828
// Student model
2929
type Student struct {
3030
gorm.Model
31-
FirstName string `gorm:"type:varchar(50);not null"`
32-
LastName string `gorm:"type:varchar(50);not null"`
33-
StudentIDNumber string `gorm:"type:varchar(20);unique;not null"`
34-
DateOfBirth time.Time `gorm:"type:date"`
35-
Email string `gorm:"type:varchar(255);unique;not null"`
36-
EnrollmentDate time.Time `gorm:"autoCreateTime;type:date"`
37-
DepartmentID *uint
31+
FirstName string `gorm:"type:varchar(50);not null"`
32+
LastName string `gorm:"type:varchar(50);not null"`
33+
StudentIDNumber string `gorm:"type:varchar(20);unique;not null"`
34+
DateOfBirth time.Time `gorm:"type:date"`
35+
Email string `gorm:"type:varchar(255);unique;not null"`
36+
EnrollmentDate time.Time `gorm:"autoCreateTime;type:date"`
37+
DepartmentID *uint `gorm:"column:department_link"`
3838
Department *Department `gorm:"constraint:OnDelete:SET NULL;"` // Belongs-to relationship, SET NULL on delete
3939
}

0 commit comments

Comments
 (0)