2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-31 00:06:56 -04:00
|
|
|
class AddHasMessagesToGroups < ActiveRecord::Migration[4.2]
|
2015-12-17 02:06:04 -05:00
|
|
|
def up
|
|
|
|
add_column :groups, :has_messages, :boolean, default: false, null: false
|
|
|
|
|
|
|
|
execute <<SQL
|
|
|
|
UPDATE groups g SET has_messages = true
|
|
|
|
WHERE exists(SELECT group_id FROM topic_allowed_groups WHERE group_id = g.id)
|
|
|
|
SQL
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
remove_column :groups, :has_messages
|
|
|
|
end
|
|
|
|
end
|