Skip to content

Commit

Permalink
tested a different migration path
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderStorm committed Mar 13, 2024
1 parent 121b2d5 commit acf5570
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions server/backend/migration/20240311000000.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
Expand Down

0 comments on commit acf5570

Please sign in to comment.