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
|