More improvements to migration script.

This commit is contained in:
Guo Xiang Tan 2017-10-03 15:41:27 +08:00
parent 2d6737ce5c
commit 1a3928b803
1 changed files with 8 additions and 5 deletions

View File

@ -1,8 +1,7 @@
module Jobs module Jobs
class DiscourseChatMigrateFromSlackOfficial < Jobs::Onceoff class DiscourseChatMigrateFromSlackOfficial < Jobs::Onceoff
def execute_onceoff(args) def execute_onceoff(args)
# Check if slack plugin is installed by testing if the sitesetting exists slack_installed = PluginStoreRow.where(plugin_name: 'discourse-slack-official').exists?
slack_installed = defined?(DiscourseSlack)
if slack_installed if slack_installed
already_setup_rules = DiscourseChat::Channel.with_provider('slack').exists? already_setup_rules = DiscourseChat::Channel.with_provider('slack').exists?
@ -17,12 +16,16 @@ module Jobs
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
migrate_settings migrate_settings
migrate_data migrate_data
is_slack_enabled = SiteSetting.slack_enabled
if is_slack_enabled
SiteSetting.slack_enabled = false SiteSetting.slack_enabled = false
SiteSetting.chat_integration_slack_enabled = true SiteSetting.chat_integration_slack_enabled = true
SiteSetting.chat_integration_enabled = true SiteSetting.chat_integration_enabled = true
end end
end end
end end
end
end end