[PR #3516] [CLOSED] setup mysql tables as utf8mb4 and convert them #16970

Closed
opened 2025-11-02 12:23:16 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-gitea/gitea/pull/3516
Author: @philfry
Created: 2/15/2018
Status: Closed

Base: masterHead: mysql_utf8mb4


📝 Commits (2)

  • 69016f7 connect to mysql using utf8mb4 and change all indexed cols from varchar(255), which is the default, to varchar(191) in order to deal with utf8mb4/innodb 5.6
  • 278fd66 add migration to convert all tables to utf8mb4

📊 Changes

15 files changed (+87 additions, -18 deletions)

View changed files

📝 models/branches.go (+3 -3)
📝 models/external_login_user.go (+1 -1)
📝 models/issue_reaction.go (+1 -1)
📝 models/lfs.go (+1 -1)
📝 models/login_source.go (+1 -1)
📝 models/migrations/migrations.go (+2 -0)
models/migrations/v65.go (+67 -0)
📝 models/models.go (+2 -2)
📝 models/notification.go (+1 -1)
📝 models/release.go (+1 -1)
📝 models/repo.go (+2 -2)
📝 models/repo_redirect.go (+1 -1)
📝 models/user.go (+2 -2)
📝 models/user_mail.go (+1 -1)
📝 models/user_openid.go (+1 -1)

📄 Description

fixes #3513
looks like these changes in models.go are sufficient for database creation. This PR also adds a migration module for converting the mysql tables to utf8mb4.

Tested so far:

  1. installed gitea 1.4.0-rc1 using mysql with this patch
  2. show create table issue shows
CREATE TABLE `issue` (
-- ...
`name` varchar(255) DEFAULT NULL,          
`content` mediumtext DEFAULT NULL,
-- ...
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4

and

  1. vanilla gitea 1.3.2 installation using mysql
  2. show create table issue shows
CREATE TABLE `issue` (
-- ...
`name` varchar(255) DEFAULT NULL,          
`content` mediumtext DEFAULT NULL,
-- ...
) ENGINE=InnoDB DEFAULT CHARSET=utf8
  1. stopped gitea, updated to 1.4.0-rc1 with this patch
  2. log shows all tables were converted
  3. show create table issue shows
CREATE TABLE `issue` (
-- ...
`name` varchar(255) DEFAULT NULL,          
`content` mediumtext DEFAULT NULL,
-- ...
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/go-gitea/gitea/pull/3516 **Author:** [@philfry](https://github.com/philfry) **Created:** 2/15/2018 **Status:** ❌ Closed **Base:** `master` ← **Head:** `mysql_utf8mb4` --- ### 📝 Commits (2) - [`69016f7`](https://github.com/go-gitea/gitea/commit/69016f717fc4d9764d7ddc39990d1856e1bbc918) connect to mysql using utf8mb4 and change all indexed cols from varchar(255), which is the default, to varchar(191) in order to deal with utf8mb4/innodb 5.6 - [`278fd66`](https://github.com/go-gitea/gitea/commit/278fd665dbb8dd8e737418ecc3cc6e20485c0b4c) add migration to convert all tables to utf8mb4 ### 📊 Changes **15 files changed** (+87 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `models/branches.go` (+3 -3) 📝 `models/external_login_user.go` (+1 -1) 📝 `models/issue_reaction.go` (+1 -1) 📝 `models/lfs.go` (+1 -1) 📝 `models/login_source.go` (+1 -1) 📝 `models/migrations/migrations.go` (+2 -0) ➕ `models/migrations/v65.go` (+67 -0) 📝 `models/models.go` (+2 -2) 📝 `models/notification.go` (+1 -1) 📝 `models/release.go` (+1 -1) 📝 `models/repo.go` (+2 -2) 📝 `models/repo_redirect.go` (+1 -1) 📝 `models/user.go` (+2 -2) 📝 `models/user_mail.go` (+1 -1) 📝 `models/user_openid.go` (+1 -1) </details> ### 📄 Description fixes #3513 looks like these [changes](https://github.com/go-gitea/gitea/issues/3513#issue-297148668) in `models.go` are sufficient for database creation. This PR also adds a migration module for converting the mysql tables to `utf8mb4`. Tested so far: 1. installed gitea 1.4.0-rc1 using mysql with this patch 2. `show create table issue` shows ```sql CREATE TABLE `issue` ( -- ... `name` varchar(255) DEFAULT NULL, `content` mediumtext DEFAULT NULL, -- ... ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ``` and 1. vanilla gitea 1.3.2 installation using mysql 2. `show create table issue` shows ```sql CREATE TABLE `issue` ( -- ... `name` varchar(255) DEFAULT NULL, `content` mediumtext DEFAULT NULL, -- ... ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ``` 3. stopped gitea, updated to 1.4.0-rc1 with this patch 4. log shows all tables were converted 5. `show create table issue` shows ```sql CREATE TABLE `issue` ( -- ... `name` varchar(255) DEFAULT NULL, `content` mediumtext DEFAULT NULL, -- ... ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-02 12:23:16 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#16970