diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-13 06:11:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-13 06:11:24 +0300 |
commit | 4b2553fa313516b17e1a267690d95c2f3b6f261c (patch) | |
tree | 45bb522704dedc592728acb986f9b1d1a7c66218 /db | |
parent | 248057a54a1d5fb7db018ef77cda3fee2b0c8ded (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r-- | db/post_migrate/20210407150240_confirm_support_bot_user.rb | 23 | ||||
-rw-r--r-- | db/schema_migrations/20210407150240 | 1 |
2 files changed, 24 insertions, 0 deletions
diff --git a/db/post_migrate/20210407150240_confirm_support_bot_user.rb b/db/post_migrate/20210407150240_confirm_support_bot_user.rb new file mode 100644 index 00000000000..c26ae153128 --- /dev/null +++ b/db/post_migrate/20210407150240_confirm_support_bot_user.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +class ConfirmSupportBotUser < ActiveRecord::Migration[6.0] + SUPPORT_BOT_TYPE = 1 + + def up + users = Arel::Table.new(:users) + um = Arel::UpdateManager.new + um.table(users) + .where(users[:user_type].eq(SUPPORT_BOT_TYPE)) + .where(users[:confirmed_at].eq(nil)) + .set([[users[:confirmed_at], Arel::Nodes::NamedFunction.new('COALESCE', [users[:created_at], Arel::Nodes::SqlLiteral.new('NOW()')])]]) + connection.execute(um.to_sql) + end + + def down + # no op + + # The up migration allows for the possibility that the support user might + # have already been manually confirmed. It's not reversible as this data is + # subsequently lost. + end +end diff --git a/db/schema_migrations/20210407150240 b/db/schema_migrations/20210407150240 new file mode 100644 index 00000000000..cfc187d5dd7 --- /dev/null +++ b/db/schema_migrations/20210407150240 @@ -0,0 +1 @@ +b5f83e3870dc7c70fbde6071725aa2acb3e99f7c2ed050633c34ed35e696ba1e
\ No newline at end of file |