-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
made sure that the student clubs are localised (#438)
* made sure that the student clubs are localised * fixed most of the bugs in the sv scraper and related issues * fixed a remakingly stupid typo * made sure that the manual migration is up to date * tested a different filtering which does not trigger testcases * made sure that the testcase is more happy * fixed formatting issues
- Loading branch information
1 parent
86288f4
commit ede8b2e
Showing
17 changed files
with
672 additions
and
423 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package migration | ||
|
||
import ( | ||
"github.com/go-gormigrate/gormigrate/v2" | ||
"github.com/guregu/null" | ||
"gorm.io/gorm" | ||
) | ||
|
||
// StudentClub stores a student Club | ||
type newStudentClub struct { | ||
gorm.Model | ||
Name string | ||
Language string `gorm:"type:enum('German','English');default:'German'"` | ||
Description null.String | ||
LinkUrl null.String `gorm:"type:varchar(190);unique;"` | ||
ImageID null.Int | ||
Image *File `gorm:"foreignKey:ImageID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"` | ||
ImageCaption null.String | ||
StudentClubCollectionID uint | ||
StudentClubCollection newStudentClubCollection `gorm:"foreignKey:StudentClubCollectionID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"` | ||
} | ||
|
||
// TableName sets the insert table name for this struct type | ||
func (n *newStudentClub) TableName() string { | ||
return "student_clubs" | ||
} | ||
|
||
type newStudentClubCollection struct { | ||
gorm.Model | ||
Name string `gorm:"type:varchar(100)"` | ||
Language string `gorm:"type:enum('German','English');default:'German'"` | ||
Description string | ||
} | ||
|
||
// TableName sets the insert table name for this struct type | ||
func (n *newStudentClubCollection) TableName() string { | ||
return "student_club_collections" | ||
} | ||
|
||
// migrate20241023000000 | ||
// - made sure that student clubs are localised | ||
func migrate20241023000000() *gormigrate.Migration { | ||
return &gormigrate.Migration{ | ||
ID: "20241023000000", | ||
Migrate: func(tx *gorm.DB) error { | ||
if err := tx.Migrator().DropTable(InitialStudentClub{}); err != nil { | ||
return err | ||
} | ||
if err := tx.Migrator().DropTable(InitialStudentClubCollection{}); err != nil { | ||
return err | ||
} | ||
if err := tx.Migrator().AutoMigrate(newStudentClubCollection{}); err != nil { | ||
return err | ||
} | ||
if err := tx.Migrator().AutoMigrate(newStudentClub{}); err != nil { | ||
return err | ||
} | ||
return nil | ||
}, | ||
Rollback: func(tx *gorm.DB) error { | ||
if err := tx.Migrator().DropTable(newStudentClub{}); err != nil { | ||
return err | ||
} | ||
if err := tx.Migrator().DropTable(newStudentClubCollection{}); err != nil { | ||
return err | ||
} | ||
if err := tx.Migrator().AutoMigrate(InitialStudentClubCollection{}); err != nil { | ||
return err | ||
} | ||
if err := tx.Migrator().AutoMigrate(InitialStudentClub{}); err != nil { | ||
return err | ||
} | ||
return nil | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.