debian-mirror-gitlab/db/post_migrate/20200713071042_confirm_project_bot_users.rb

31 lines
600 B
Ruby
Raw Normal View History

2020-07-28 23:09:34 +05:30
# frozen_string_literal: true
class ConfirmProjectBotUsers < ActiveRecord::Migration[6.0]
DOWNTIME = false
disable_ddl_transaction!
class User < ApplicationRecord
self.table_name = 'users'
include ::EachBatch
USER_TYPE_PROJECT_BOT = 6
scope :project_bots, -> { where(user_type: USER_TYPE_PROJECT_BOT) }
scope :unconfirmed, -> { where(confirmed_at: nil) }
end
def up
User.reset_column_information
User.project_bots.unconfirmed.each_batch do |relation|
relation.update_all('confirmed_at = created_at')
end
end
def down
# no-op
end
end