2016-06-16 23:09:34 +05:30
|
|
|
# rubocop:disable all
|
2019-02-15 15:39:39 +05:30
|
|
|
class MoveSlackServiceToWebhook < ActiveRecord::Migration[4.2]
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
DOWNTIME = true
|
|
|
|
DOWNTIME_REASON = 'Move old fields "token" and "subdomain" to one single field "webhook"'
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
def change
|
|
|
|
SlackService.all.each do |slack_service|
|
|
|
|
if ["token", "subdomain"].all? { |property| slack_service.properties.key? property }
|
|
|
|
token = slack_service.properties['token']
|
|
|
|
subdomain = slack_service.properties['subdomain']
|
|
|
|
webhook = "https://#{subdomain}.slack.com/services/hooks/incoming-webhook?token=#{token}"
|
|
|
|
slack_service.properties['webhook'] = webhook
|
|
|
|
slack_service.properties.delete('token')
|
|
|
|
slack_service.properties.delete('subdomain')
|
|
|
|
# Room is configured on the Slack side
|
|
|
|
slack_service.properties.delete('room')
|
|
|
|
slack_service.save(validate: false)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|