debian-mirror-gitlab/db/migrate/20210428151144_update_invalid_web_hooks.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

25 lines
503 B
Ruby
Raw Normal View History

2021-06-08 01:23:25 +05:30
# frozen_string_literal: true
class UpdateInvalidWebHooks < ActiveRecord::Migration[6.0]
disable_ddl_transaction!
class WebHook < ActiveRecord::Base
include EachBatch
self.table_name = 'web_hooks'
end
def up
WebHook.each_batch(of: 10_000, column: :id) do |relation|
relation.where(type: 'ProjectHook')
.where.not(project_id: nil)
.where.not(group_id: nil)
.update_all(group_id: nil)
end
end
def down
# no-op
end
end