Skip to content

Commit

Permalink
made sure that the manual migration is up to date
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderStorm committed Sep 23, 2024
1 parent 2232e8f commit facf576
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions server/backend/migration/20241023000000.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package migration

import (
"github.com/TUM-Dev/Campus-Backend/server/model"
"github.com/go-gormigrate/gormigrate/v2"
"github.com/guregu/null"
"gorm.io/gorm"
"time"
)

// StudentClub stores a student Club
Expand All @@ -16,9 +14,9 @@ type newStudentClub struct {
Description null.String
LinkUrl null.String `gorm:"type:varchar(190);unique;"`
ImageID null.Int
Image *model.File `gorm:"foreignKey:ImageID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
Image *File `gorm:"foreignKey:ImageID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
ImageCaption null.String
StudentClubCollectionID string `gorm:"type:varchar(100)"`
StudentClubCollectionID uint
StudentClubCollection newStudentClubCollection `gorm:"foreignKey:StudentClubCollectionID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
}

Expand All @@ -28,12 +26,10 @@ func (n *newStudentClub) TableName() string {
}

type newStudentClubCollection struct {
ID string `gorm:"primaryKey;type:varchar(100)"`
gorm.Model
Name string `gorm:"type:varchar(100)"`
Language string `gorm:"type:enum('German','English');default:'German'"`
Description string
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}

// TableName sets the insert table name for this struct type
Expand All @@ -47,10 +43,10 @@ func migrate20241023000000() *gormigrate.Migration {
return &gormigrate.Migration{
ID: "20241023000000",
Migrate: func(tx *gorm.DB) error {
if err := tx.Migrator().DropTable(newStudentClub{}); err != nil {
if err := tx.Migrator().DropTable(InitialStudentClub{}); err != nil {
return err
}
if err := tx.Migrator().DropTable(newStudentClubCollection{}); err != nil {
if err := tx.Migrator().DropTable(InitialStudentClubCollection{}); err != nil {
return err
}
if err := tx.Migrator().AutoMigrate(newStudentClubCollection{}); err != nil {
Expand Down

0 comments on commit facf576

Please sign in to comment.