discourse/plugins/chat/db/migrate/20221117142910_delete_orphaned_channels.rb
Loïc Guitaut 25138db433 DEV: Promote historic post_deploy migrations
This commit promotes all post_deploy migrations which existed in
Discourse v3.0.0 (timestamp <= 20221212234948)
2023-07-26 10:36:37 +02:00

10 lines
316 B
Ruby

# frozen_string_literal: true
class DeleteOrphanedChannels < ActiveRecord::Migration[7.0]
def up
DB.exec(
"DELETE FROM chat_channels WHERE chatable_type = 'Category' AND type = 'CategoryChannel' AND NOT EXISTS (SELECT * FROM categories WHERE categories.id = chat_channels.chatable_id)",
)
end
end