Class: Gitlab::BackgroundMigration::BackfillPushRulesIdInProjects

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/background_migration/backfill_push_rules_id_in_projects.rb

Overview

Class that will insert record into project_push_rules for each existing push_rule

Defined Under Namespace

Classes: ProjectSetting

Instance Method Summary collapse

Instance Method Details

#perform(start_id, stop_id) ⇒ Object


13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/gitlab/background_migration/backfill_push_rules_id_in_projects.rb', line 13

def perform(start_id, stop_id)
  ProjectSetting.connection.execute(<<~SQL)
    UPDATE project_settings ps1
    SET push_rule_id = pr.id
    FROM project_settings ps2
    INNER JOIN push_rules pr
    ON ps2.project_id = pr.project_id
    WHERE pr.is_sample = false
    AND pr.id BETWEEN #{start_id} AND #{stop_id}
    AND ps1.project_id = ps2.project_id
  SQL
end