diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-24 12:09:44 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-24 12:09:44 +0300 |
commit | b1b7c2f9a744197a111c81719c546a474adab4e8 (patch) | |
tree | 2fe9d392110fb1fee8a8e6eac1f520425fee1c9c /db | |
parent | 81c305759174e2f55176356e98d264ea1c4b747d (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r-- | db/post_migrate/20200310215714_migrate_saml_identities_to_scim_identities.rb | 29 | ||||
-rw-r--r-- | db/structure.sql | 1 |
2 files changed, 30 insertions, 0 deletions
diff --git a/db/post_migrate/20200310215714_migrate_saml_identities_to_scim_identities.rb b/db/post_migrate/20200310215714_migrate_saml_identities_to_scim_identities.rb new file mode 100644 index 00000000000..e2ec7b62d31 --- /dev/null +++ b/db/post_migrate/20200310215714_migrate_saml_identities_to_scim_identities.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +class MigrateSamlIdentitiesToScimIdentities < ActiveRecord::Migration[6.0] + DOWNTIME = false + + class Identity < ActiveRecord::Base + self.table_name = 'identities' + + include ::EachBatch + end + + def up + Identity + .joins('INNER JOIN saml_providers ON saml_providers.id = identities.saml_provider_id') + .where('saml_providers.group_id IN (SELECT group_id FROM scim_oauth_access_tokens)') + .select('identities.extern_uid, identities.user_id, saml_providers.group_id, TRUE AS active, + identities.created_at, CURRENT_TIMESTAMP AS updated_at') + .each_batch do |batch| + data_to_insert = batch.map do |record| + record.attributes.extract!("extern_uid", "user_id", "group_id", "active", "created_at", "updated_at") + end + + Gitlab::Database.bulk_insert(:scim_identities, data_to_insert, on_conflict: :do_nothing) + end + end + + def down + end +end diff --git a/db/structure.sql b/db/structure.sql index 982af99b2a0..96211531462 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -13285,6 +13285,7 @@ COPY "schema_migrations" (version) FROM STDIN; 20200310135818 20200310135823 20200310145304 +20200310215714 20200311074438 20200311082301 20200311084025 |