diff options
Diffstat (limited to 'db/post_migrate/20221018232820_add_temp_index_for_user_details_fields.rb')
-rw-r--r-- | db/post_migrate/20221018232820_add_temp_index_for_user_details_fields.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/db/post_migrate/20221018232820_add_temp_index_for_user_details_fields.rb b/db/post_migrate/20221018232820_add_temp_index_for_user_details_fields.rb new file mode 100644 index 00000000000..b46b316981d --- /dev/null +++ b/db/post_migrate/20221018232820_add_temp_index_for_user_details_fields.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +class AddTempIndexForUserDetailsFields < Gitlab::Database::Migration[2.0] + INDEX_NAME = 'tmp_idx_where_user_details_fields_filled' + + disable_ddl_transaction! + + def up + add_concurrent_index :users, :id, name: INDEX_NAME, where: <<~QUERY + (COALESCE(linkedin, '') IS DISTINCT FROM '') + OR (COALESCE(twitter, '') IS DISTINCT FROM '') + OR (COALESCE(skype, '') IS DISTINCT FROM '') + OR (COALESCE(website_url, '') IS DISTINCT FROM '') + OR (COALESCE(location, '') IS DISTINCT FROM '') + OR (COALESCE(organization, '') IS DISTINCT FROM '') + QUERY + end + + def down + remove_concurrent_index_by_name :users, INDEX_NAME + end +end |