Skip to content

Make chat_names table migration idempotent

Stan Hu requested to merge sh-fix-chat-names-migration into master

What does this MR do and why?

GitLab 16.5.6, 16.6.4, and 16.7.2 added a migration that added columns chat_names.encrypted_token and chat_names.encrypted_token_iv. Unfortunately, the migration was added as different filenames. As a result, if users upgrade to 16.5.6 or 16.6.4 first, they'll already have those columns, and the next upgrade to 16.7.2 will fail.

To prevent an upgrade failure, we need to make the migration idempotent so that it can be applied again without issues.

For reference, these are the filenames that are used in different versions:

  • 16.8 - db/migrate/20231123160255_add_token_to_chat_names.rb
  • 16.7 - db/migrate/20231219120134_add_token_to_chat_names.rb
  • 16.6 - db/migrate/20231215135014_add_token_to_chat_names.rb
  • 16.5 - db/migrate/20231215145632_add_token_to_chat_names.rb

Relates to omnibus-gitlab#8371 (closed)

How to set up and validate locally

  1. git checkout v16.7.2-ee
  2. bin/rails db:migrate. This will fail if you have already applied the fix from master.
  3. Apply this patch or use !141704 (merged): git checkout sh-fix-chat-names-migration-16-7
  4. Rerun bin/rails db:migrate.
Edited by Stan Hu

Merge request reports