From 1ddd271db627a6122dbe156c31415d4253a830c1 Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Thu, 10 Sep 2020 20:43:28 +0100 Subject: [PATCH] Whilst changing the character set to utf8mb4 we should set ROW_FORMAT=dynamic too Fix #12801 Signed-off-by: Andrew Thornton --- models/convert.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/models/convert.go b/models/convert.go index 025f88b503870..baa63bb388396 100644 --- a/models/convert.go +++ b/models/convert.go @@ -10,7 +10,7 @@ import ( "code.gitea.io/gitea/modules/setting" ) -// ConvertUtf8ToUtf8mb4 converts database and tables from utf8 to utf8mb4 if it's mysql +// ConvertUtf8ToUtf8mb4 converts database and tables from utf8 to utf8mb4 if it's mysql and set ROW_FORMAT=dynamic func ConvertUtf8ToUtf8mb4() error { _, err := x.Exec(fmt.Sprintf("ALTER DATABASE `%s` CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci", setting.Database.Name)) if err != nil { @@ -22,6 +22,10 @@ func ConvertUtf8ToUtf8mb4() error { return err } for _, table := range tables { + if _, err := x.Exec(fmt.Sprintf("ALTER TABLE `%s` ROW_FORMAT=dynamic;", table.Name)); err != nil { + return err + } + if _, err := x.Exec(fmt.Sprintf("ALTER TABLE `%s` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;", table.Name)); err != nil { return err }