diff options
Diffstat (limited to 'db/migrate/20190902131045_replace_indexes_for_counting_active_users.rb')
-rw-r--r-- | db/migrate/20190902131045_replace_indexes_for_counting_active_users.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/db/migrate/20190902131045_replace_indexes_for_counting_active_users.rb b/db/migrate/20190902131045_replace_indexes_for_counting_active_users.rb new file mode 100644 index 00000000000..2c7c47bee96 --- /dev/null +++ b/db/migrate/20190902131045_replace_indexes_for_counting_active_users.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +class ReplaceIndexesForCountingActiveUsers < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + remove_concurrent_index_by_name(:users, 'index_users_on_state_and_internal') + + add_concurrent_index(:users, :state, where: 'ghost IS NOT TRUE', name: 'index_users_on_state_and_internal') + add_concurrent_index(:users, :state, where: 'ghost IS NOT TRUE AND bot_type IS NULL', name: 'index_users_on_state_and_internal_ee') + end + + def down + remove_concurrent_index_by_name(:users, 'index_users_on_state_and_internal_ee') + remove_concurrent_index_by_name(:users, 'index_users_on_state_and_internal') + + add_concurrent_index(:users, :state, where: 'ghost <> true AND bot_type IS NULL', name: 'index_users_on_state_and_internal') + end +end |