Skip to content

Commit

Permalink
fixed wrong COLLATE in gorm
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderStorm committed Mar 16, 2024
1 parent 89403e6 commit eeb02b0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion server/backend/migration/20240317000000.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

func tablesWithWrongCOLLATE() []string {
return []string{"crontab", "devices", "dish", "files", "kino", "news", "newsSource", "notifications", "notification_types"}
return []string{"crontab", "devices", "dish", "files", "kino", "news", "newsSource", "notification_types"}
}

// migrate20240317000000
Expand Down
3 changes: 2 additions & 1 deletion server/utils/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ func SetupDB() *gorm.DB {
if err != nil {
log.WithError(err).Fatal("failed to connect database")
}
// without this comment, the `COLLATE` will not be set correctly
db = db.Set("gorm:table_options", "ENGINE=InnoDB CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci")

// Migrate the schema
// currently not activated as
Expand All @@ -33,6 +35,5 @@ func SetupDB() *gorm.DB {
log.Info("Exiting after migration")
os.Exit(0)
}
db = db.Set("gorm:table_options", "ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8mb4_unicode_ci")
return db
}

0 comments on commit eeb02b0

Please sign in to comment.