Skip to content

MySQL DB migration fails from 10.2.5 to 10.3.1

Summary

Getting Mysql-Error when migrating DB from 10.2.5 to 10.3.1

Steps to reproduce

rake db:migrate RAILS_ENV=production

What is the current bug behavior?

Migration fails. Gitlab is not working anymore.

What is the expected correct behavior?

Migration should succeed.

Relevant logs and/or screenshots

== 20171103000000 SetUploadsPathSizeForMysql: migrating ======================= -- change_column(:uploads, :path, :string, {:limit=>511}) rake aborted! StandardError: An error has occurred, all later migrations canceled:

Mysql2::Error: Specified key was too long; max key length is 767 bytes: ALTER TABLE uploads CHANGE path path varchar(511) NOT NULL /srv/www/vhosts/gitlab-ce/config/initializers/connection_fix.rb:20:in execute' /srv/www/vhosts/gitlab-ce/db/migrate/20171103000000_set_uploads_path_size_for_mysql.rb:18:in up'
/usr/bin/rake.ruby2.4:22:in load' /usr/bin/rake.ruby2.4:22:in '

Caused by:
ActiveRecord::StatementInvalid: Mysql2::Error: Specified key was too long; max key length is 767 bytes: ALTER TABLE uploads CHANGE path path varchar(511) NOT NULL
/srv/www/vhosts/gitlab-ce/config/initializers/connection_fix.rb:20:in execute' /srv/www/vhosts/gitlab-ce/db/migrate/20171103000000_set_uploads_path_size_for_mysql.rb:18:in up'
/usr/bin/rake.ruby2.4:22:in load' /usr/bin/rake.ruby2.4:22:in '

Caused by:
Mysql2::Error: Specified key was too long; max key length is 767 bytes
/srv/www/vhosts/gitlab-ce/config/initializers/connection_fix.rb:20:in execute' /srv/www/vhosts/gitlab-ce/db/migrate/20171103000000_set_uploads_path_size_for_mysql.rb:18:in up'
/usr/bin/rake.ruby2.4:22:in load' /usr/bin/rake.ruby2.4:22:in ' Tasks: TOP => db:migrate (See full trace by running task with --trace)

Results of GitLab environment info

System information System: openSUSE project 42.3 Current User: root Using RVM: no Ruby Version: 2.1.9p490 Gem Version: 2.2.5 Bundler Version:1.16.0 Rake Version: 12.3.0
Redis Version: 4.0.2 Git Version: 2.13.6 Sidekiq Version:5.0.5 Go Version: unknown

GitLab information Version: 10.3.0 Revision: fatal: Not a git repository (or any of the parent directories): .git Directory: /srv/www/vhosts/gitlab-ce DB Adapter: mysql2 URL: http://gitlab.server HTTP Clone URL: http://gitlab.server/some-group/some-project.git SSH Clone URL: gitlab@gitlab.server:some-group/some-project.git Using LDAP: no Using Omniauth: no

GitLab Shell Version: 5.10.2 Repository storage paths:

  • default: /srv/gitlab/repositories Hooks: /usr/share/gitlab/shell/hooks Git: /usr/bin/git