Welcome to mirror list, hosted at ThFree Co, Russian Federation.

20150204001035_build_missing_services.rb « migrate « ci « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 437ad072eadfd2e10e8c0a657dfa69917a32a2cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class BuildMissingServices < ActiveRecord::Migration
  def up
    Project.find_each do |project|
      # Slack service creation
      slack_service = select_one("SELECT id FROM services WHERE type='SlackService' AND project_id = #{project.id}")
      
      unless slack_service
        execute("INSERT INTO services (type, project_id, active, properties, created_at, updated_at) \
            VALUES ('SlackService', '#{project.id}', false, '{}', NOW(), NOW())")
      end

      # Mail service creation
      mail_service = select_one("SELECT id FROM services WHERE type='MailService' AND project_id = #{project.id}")
      
      unless mail_service
        execute("INSERT INTO services (type, project_id, active, properties, created_at, updated_at) \
            VALUES ('MailService', '#{project.id}', true, '{}', NOW(), NOW())")
      end
    end
  end
end