diff --git a/server/backend/migration/20240317000000.go b/server/backend/migration/20240317000000.go index 354275a3..c3bf39ab 100644 --- a/server/backend/migration/20240317000000.go +++ b/server/backend/migration/20240317000000.go @@ -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 diff --git a/server/utils/db.go b/server/utils/db.go index 35cf56d4..3904cd96 100644 --- a/server/utils/db.go +++ b/server/utils/db.go @@ -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 @@ -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 }