2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-31 00:06:56 -04:00
|
|
|
class FixGroupAllowMembershipRequests < ActiveRecord::Migration[4.2]
|
2017-06-02 10:15:57 -04:00
|
|
|
def up
|
|
|
|
execute <<~SQL
|
|
|
|
UPDATE groups g
|
|
|
|
SET allow_membership_requests = 'f'
|
|
|
|
WHERE NOT EXISTS (SELECT 1 FROM group_users gu WHERE gu.owner = 't' AND gu.group_id = g.id LIMIT 1)
|
|
|
|
SQL
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
raise ActiveRecord::IrreversibleMigration
|
|
|
|
end
|
|
|
|
end
|