MySQL - Add migration from MyISAM to InnoDB? #1314

Closed
opened 2025-11-02 03:56:25 -06:00 by GiteaMirror · 6 comments
Owner

Originally created by @silverwind on GitHub (Dec 2, 2017).

  • Gitea version (or commit ref): 1.3.0 and current master
  • Git version: 2.14.2
  • Operating system: CentOS 6
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log:
2017/12/02 15:19:37 [I] Log Mode: File(Debug)
2017/12/02 15:19:37 [I] XORM Log Mode: File(Debug)
2017/12/02 15:19:37 [I] Cache Service Enabled
2017/12/02 15:19:37 [I] Session Service Enabled
2017/12/02 15:19:37 [I] Mail Service Enabled
2017/12/02 15:19:37 [I] Notify Mail Service Enabled
2017/12/02 15:19:37 [I] Migration: add deleted branches
2017/12/02 15:19:37 [...itea/routers/init.go:60 GlobalInit()] [E] Failed to initialize ORM engine: migrate: do migrate: Sync2: Error 1071: Specified key was too long; max key length is 1000 bytes

Description

I was running gitea on a old MySQL 5.1 and after upgrading to 1.3.0, I was faced with above error which is caused by the table deleted_branch apparently not being compatible with the MyISAM engine. I resolved it by changing the engine of the table to InnoDB, but this is how gitea had initially created this table:

| deleted_branch | CREATE TABLE `deleted_branch` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `repo_id` bigint(20) NOT NULL,
  `name` varchar(255) NOT NULL,
  `commit` varchar(255) NOT NULL,
  `deleted_by_id` bigint(20) NOT NULL,
  `deleted_unix` bigint(20) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `IDX_deleted_branch_deleted_unix` (`deleted_unix`),
  KEY `IDX_deleted_branch_deleted_by_id` (`deleted_by_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 |

I wonder if it might be wise to have a migration that converts all tables to InnoDB (if the database supports it) to avoid such issues in the future, or alternatively maintain support of MyISAM.

Originally created by @silverwind on GitHub (Dec 2, 2017). - Gitea version (or commit ref): 1.3.0 and current master - Git version: 2.14.2 - Operating system: CentOS 6 - Database (use `[x]`): - [ ] PostgreSQL - [x] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [x] Not relevant - Log: ```` 2017/12/02 15:19:37 [I] Log Mode: File(Debug) 2017/12/02 15:19:37 [I] XORM Log Mode: File(Debug) 2017/12/02 15:19:37 [I] Cache Service Enabled 2017/12/02 15:19:37 [I] Session Service Enabled 2017/12/02 15:19:37 [I] Mail Service Enabled 2017/12/02 15:19:37 [I] Notify Mail Service Enabled 2017/12/02 15:19:37 [I] Migration: add deleted branches 2017/12/02 15:19:37 [...itea/routers/init.go:60 GlobalInit()] [E] Failed to initialize ORM engine: migrate: do migrate: Sync2: Error 1071: Specified key was too long; max key length is 1000 bytes ```` ## Description I was running gitea on a old MySQL 5.1 and after upgrading to 1.3.0, I was faced with above error which is caused by the table `deleted_branch` apparently not being compatible with the MyISAM engine. I resolved it by changing the engine of the table to InnoDB, but this is how gitea had initially created this table: ```` | deleted_branch | CREATE TABLE `deleted_branch` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `repo_id` bigint(20) NOT NULL, `name` varchar(255) NOT NULL, `commit` varchar(255) NOT NULL, `deleted_by_id` bigint(20) NOT NULL, `deleted_unix` bigint(20) DEFAULT NULL, PRIMARY KEY (`id`), KEY `IDX_deleted_branch_deleted_unix` (`deleted_unix`), KEY `IDX_deleted_branch_deleted_by_id` (`deleted_by_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 | ```` I wonder if it might be wise to have a migration that converts all tables to InnoDB (if the database supports it) to avoid such issues in the future, or alternatively maintain support of MyISAM.
GiteaMirror added the type/questionissue/confirmed labels 2025-11-02 03:56:25 -06:00
Author
Owner

@lunny commented on GitHub (Dec 2, 2017):

I don't think Gitea should support MyISAM since so many transations needed.

@lunny commented on GitHub (Dec 2, 2017): I don't think Gitea should support MyISAM since so many transations needed.
Author
Owner

@silverwind commented on GitHub (Dec 2, 2017):

I too think it's reasonable to require InnoDB, but gitea should explicitly create tables with it, not rely on the default of MySQL which was MyISAM prior to 5.5.5.

@silverwind commented on GitHub (Dec 2, 2017): I too think it's reasonable to require InnoDB, but gitea should explicitly create tables with it, not rely on the default of MySQL which was MyISAM prior to 5.5.5.
Author
Owner

@lunny commented on GitHub (Dec 2, 2017):

Yes, Gitea should check the engine otherwise it should print fail

@lunny commented on GitHub (Dec 2, 2017): Yes, Gitea should check the engine otherwise it should print fail
Author
Owner

@danbruegge commented on GitHub (Feb 20, 2018):

Had the same problem. Changing deleted_branch to InnoDB engine solved it. Thanks. :)

@danbruegge commented on GitHub (Feb 20, 2018): Had the same problem. Changing `deleted_branch` to InnoDB engine solved it. Thanks. :)
Author
Owner

@stale[bot] commented on GitHub (Feb 8, 2019):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

@stale[bot] commented on GitHub (Feb 8, 2019): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.
Author
Owner

@lunny commented on GitHub (Feb 27, 2019):

You should set database default engine as InnoDB when creating mysql.

@lunny commented on GitHub (Feb 27, 2019): You should set database default engine as InnoDB when creating mysql.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#1314