Gitea: MySQL - Add migration from MyISAM to InnoDB?

Created on 2 Dec 2017  路  6Comments  路  Source: go-gitea/gitea

  • 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.

kinquestion revieweconfirmed

Most helpful comment

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

All 6 comments

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

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.

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

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

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.

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

Was this page helpful?
0 / 5 - 0 ratings