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
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrate/20201222151823_update_trusted_apps_to_confidential.rb')
-rw-r--r--db/migrate/20201222151823_update_trusted_apps_to_confidential.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/db/migrate/20201222151823_update_trusted_apps_to_confidential.rb b/db/migrate/20201222151823_update_trusted_apps_to_confidential.rb
new file mode 100644
index 00000000000..bcb94c65125
--- /dev/null
+++ b/db/migrate/20201222151823_update_trusted_apps_to_confidential.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+class UpdateTrustedAppsToConfidential < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ INDEX_NAME = 'tmp_index_oauth_applications_on_id_where_trusted'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :oauth_applications, :id, where: 'trusted = true', name: INDEX_NAME
+
+ execute('UPDATE oauth_applications SET confidential = true WHERE trusted = true')
+ end
+
+ def down
+ # We won't be able to tell which trusted applications weren't confidential before the migration
+ # and setting all trusted applications are not confidential would introduce security issues
+
+ remove_concurrent_index_by_name :oauth_applications, INDEX_NAME
+ end
+end