Add slack service migration.

This commit is contained in:
Marin Jankovski 2014-10-06 16:50:24 +02:00
parent 1db8d3104c
commit eceef546d1
2 changed files with 18 additions and 1 deletions

View file

@ -0,0 +1,17 @@
class MoveSlackServiceToWebhook < ActiveRecord::Migration
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!
end
end
end
end

View file

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20140914173417) do
ActiveRecord::Schema.define(version: 20141006143943) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"