Make chat_names table migration idempotent
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
git checkout v16.7.2-ee
-
bin/rails db:migrate
. This will fail if you have already applied the fix frommaster
. - Apply this patch or use !141704 (merged):
git checkout sh-fix-chat-names-migration-16-7
- Rerun
bin/rails db:migrate
.
Edited by Stan Hu