Skip to content

Commit

Permalink
Whilst changing the character set to utf8mb4 we should set ROW_FORMAT…
Browse files Browse the repository at this point in the history
…=dynamic too

Fix go-gitea#12801

Signed-off-by: Andrew Thornton <[email protected]>
  • Loading branch information
zeripath committed Sep 10, 2020
1 parent 4f8dad3 commit 1ddd271
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion models/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
Expand Down

0 comments on commit 1ddd271

Please sign in to comment.