Skip to content

Commit

Permalink
DEV: update migration with correct table names
Browse files Browse the repository at this point in the history
  • Loading branch information
Grubba27 committed Sep 5, 2024
1 parent 96f8da9 commit 5144318
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class MigrateTagAddedFilterToAllProviders < ActiveRecord::Migration[7.1]
def up
if defined?(DiscourseAutomation)
begin
slack_count = DB.exec <<~SQL
slack_usage_rows = DB.query <<~SQL
SELECT plugin_store_rows.* FROM plugin_store_rows
WHERE plugin_store_rows.type_name = 'JSON'
AND plugin_store_rows.plugin_name = 'discourse-chat-integration'
Expand All @@ -16,17 +16,16 @@ def up
WHERE id IN (
SELECT a.id
FROM discourse_automation_automations a
JOIN discourse_automation_automation_fields f ON f.automation_id = a.id
JOIN discourse_automation_fields f ON f.automation_id = a.id
WHERE a.script = 'send_slack_message'
AND a.trigger = 'topic_tags_changed'
AND a.name = 'When tags change in topic'
AND f.name = 'message'
AND f.metadata->>'value' = '${ADDED_AND_REMOVED}'
)
SQL

# Trash old migration
DB.exec old_migration_delete if slack_count > 0
DB.exec old_migration_delete if slack_usage_rows.count > 0

rules_with_tag_added = <<~SQL
SELECT value
Expand Down Expand Up @@ -142,7 +141,7 @@ def up
)
end
rescue StandardError
Rails.logger.warn("Failed to migrate tag_added rule to all providers automations")
puts "Error migrating tag_added filters to all providers"
end
end
end
Expand Down

0 comments on commit 5144318

Please sign in to comment.