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>2021-11-22 12:10:28 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-11-22 12:10:28 +0300
commit56274bbb7424bcecbd43bd5f884b11a85322044e (patch)
treee911361b80ca921260aa57d36f8445c0898f195b /db
parent8e3f09c43583788e68c593c406e3de6bb443f8a6 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r--db/post_migrate/20211117084814_migrate_remaining_u2f_registrations.rb26
-rw-r--r--db/schema_migrations/202111170848141
2 files changed, 27 insertions, 0 deletions
diff --git a/db/post_migrate/20211117084814_migrate_remaining_u2f_registrations.rb b/db/post_migrate/20211117084814_migrate_remaining_u2f_registrations.rb
new file mode 100644
index 00000000000..ae9dba32a4a
--- /dev/null
+++ b/db/post_migrate/20211117084814_migrate_remaining_u2f_registrations.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+class MigrateRemainingU2fRegistrations < Gitlab::Database::Migration[1.0]
+ BATCH_SIZE = 100
+
+ disable_ddl_transaction!
+
+ def up
+ # We expect only a few number of records satisfying these conditions.
+ # on gitlab.com database, this number is 70 as on 17th Nov, 2021.
+ define_batchable_model('u2f_registrations')
+ .joins("LEFT JOIN webauthn_registrations ON webauthn_registrations.u2f_registration_id = u2f_registrations.id")
+ .where(webauthn_registrations: { u2f_registration_id: nil })
+ .each_batch(of: BATCH_SIZE) do |batch, index|
+ batch.each do |record|
+ Gitlab::BackgroundMigration::MigrateU2fWebauthn.new.perform(record.id, record.id)
+ rescue StandardError => e
+ Gitlab::ErrorTracking.track_exception(e, u2f_registration_id: record.id)
+ end
+ end
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/schema_migrations/20211117084814 b/db/schema_migrations/20211117084814
new file mode 100644
index 00000000000..d24eb0a0c04
--- /dev/null
+++ b/db/schema_migrations/20211117084814
@@ -0,0 +1 @@
+d6b0ca9d1e88e9e531ee0da5c82723309d746b6d83ea5dfb8326d3cc718a31b6 \ No newline at end of file