Migration from 10.4.5 to v10.5.4 fails with migration already exists error message

Attempting to upgrade a self-installed Gitlab CE instance from 10.4.5 to 10.5.4. Everything goes well up until the db migration, where one of the migrations fails:

rake aborted!
StandardError: An error has occurred, all later migrations canceled:

Index name 'index_lfs_file_locks_on_user_id' on table 'lfs_file_locks' already exists
/var/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/schema_statements.rb:953:in `add_index_options'
/var/git/gitlab/config/initializers/mysql_ignore_postgresql_options.rb:44:in `add_index_options'
...
Caused by:
ArgumentError: Index name 'index_lfs_file_locks_on_user_id' on table 'lfs_file_locks' already exists

This install has been chugging away for quite some time (started out in the 9.x days iirc) and has been upgraded several times; there were a few failed upgrades along the way, however I was careful to follow the “things went south?” procedure. In fact I tried an upgrade to 10.5.0 a few weeks ago that failed for a different reason (I don’t remember what it was) however I did follow the proper downgrade procedure including restoring from my 10.4.x backup. So I’m not entirely sure how this index managed to get in there.

For now I have successfully reverted back to 10.4.5; however I would like to be able to conclude the upgrade to 10.5.x if at all possible. Is there any way of skipping over this one specific migration (since it apparently has already been applied somehow)?

I’m having this same issue. Is there a fix available or do I have to just stay on the old 10.4-stable version?

@dburr @nubzzz
I had the same error yesterday.
Fortunatly it is easy to fix.
The migration creates a new table “lfs_file_locks” and adds a foreign key constraint and an index to it.
To fix the error, delete the constraint and the index, then drop the table.
The migration should work fine after that.

1 Like

Thanks for the reply! After I dropped the tablet and re-ran the upgrade, the entire update (including the migration) ran perfectly. So glad I’m no longer stuck on an “update ASAP” version :slight_smile: