Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-11-19 21:09:13 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-11-19 21:09:13 +0300
commit71c85847eb6645f6cca91febd70668d544a4125d (patch)
tree734b225303f3ef27d07a8b1feec5cb94d77c1be1 /db
parenta2f3b3e5cf571da549b34c5500b5dd5723c045de (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r--db/post_migrate/20201030121314_schedule_update_existing_users_that_require_two_factor_auth.rb35
-rw-r--r--db/schema_migrations/202010301213141
-rw-r--r--db/structure.sql2
3 files changed, 38 insertions, 0 deletions
diff --git a/db/post_migrate/20201030121314_schedule_update_existing_users_that_require_two_factor_auth.rb b/db/post_migrate/20201030121314_schedule_update_existing_users_that_require_two_factor_auth.rb
new file mode 100644
index 00000000000..2cb7c9c5250
--- /dev/null
+++ b/db/post_migrate/20201030121314_schedule_update_existing_users_that_require_two_factor_auth.rb
@@ -0,0 +1,35 @@
+# # frozen_string_literal: true
+
+class ScheduleUpdateExistingUsersThatRequireTwoFactorAuth < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ MIGRATION = 'UpdateExistingUsersThatRequireTwoFactorAuth'
+ DELAY_INTERVAL = 2.minutes
+ BATCH_SIZE = 1000
+ INDEX_NAME = 'index_users_on_require_two_factor_authentication_from_group'
+
+ disable_ddl_transaction!
+
+ class User < ActiveRecord::Base
+ include EachBatch
+
+ self.table_name = 'users'
+ end
+
+ def up
+ add_concurrent_index :users,
+ :require_two_factor_authentication_from_group,
+ where: 'require_two_factor_authentication_from_group = TRUE',
+ name: INDEX_NAME
+
+ relation = User.where(require_two_factor_authentication_from_group: true)
+
+ queue_background_migration_jobs_by_range_at_intervals(
+ relation, MIGRATION, DELAY_INTERVAL, batch_size: BATCH_SIZE)
+ end
+
+ def down
+ remove_concurrent_index_by_name :users, INDEX_NAME
+ end
+end
diff --git a/db/schema_migrations/20201030121314 b/db/schema_migrations/20201030121314
new file mode 100644
index 00000000000..b96f100cbd7
--- /dev/null
+++ b/db/schema_migrations/20201030121314
@@ -0,0 +1 @@
+4875c1def91676d73f14c2fbff9318fc4ab1f26535503fd9700044b687e9714e \ No newline at end of file
diff --git a/db/structure.sql b/db/structure.sql
index 1f76fbf430f..acbda95a500 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -22203,6 +22203,8 @@ CREATE INDEX index_users_on_name_trigram ON users USING gin (name gin_trgm_ops);
CREATE INDEX index_users_on_public_email ON users USING btree (public_email) WHERE ((public_email)::text <> ''::text);
+CREATE INDEX index_users_on_require_two_factor_authentication_from_group ON users USING btree (require_two_factor_authentication_from_group);
+
CREATE UNIQUE INDEX index_users_on_reset_password_token ON users USING btree (reset_password_token);
CREATE INDEX index_users_on_state ON users USING btree (state);