From acf5570069fbd597d0cefa1f65a333cc5e4c50eb Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Wed, 13 Mar 2024 22:04:09 +0100 Subject: [PATCH] tested a different migration path --- server/backend/migration/20240311000000.go | 6 ++++++ 1 file changed, 6 insertions(+) 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