diff --git a/server/backend/migration/20240311000000.go b/server/backend/migration/20240311000000.go index 31271b9b..0855f9a1 100644 --- a/server/backend/migration/20240311000000.go +++ b/server/backend/migration/20240311000000.go @@ -13,6 +13,9 @@ func migrate20240311000000() *gormigrate.Migration { ID: "20240311000000", Migrate: func(tx *gorm.DB) error { // make sure that dish_rating is FK-bound to dish + if err := tx.Exec("alter table dish_rating modify dishID int").Error; err != nil { + return err + } if err := tx.Exec("alter table dish_rating add constraint dish_rating_dish_dish_fk foreign key (dishID) references dish (dish) on update cascade on delete cascade").Error; err != nil { return err } @@ -28,6 +31,9 @@ func migrate20240311000000() *gormigrate.Migration { if err := tx.Exec("alter table dish_rating drop constraint dish_rating_dish_dish_fk").Error; err != nil { return err } + if err := tx.Exec("alter table dish_rating modify dishID int not null").Error; err != nil { + return err + } // because dishes already have a cafeteria, storing this agiain is not nessesary if err := tx.Exec("alter table dish_rating add column cafeteriaID int not null").Error; err != nil { return err