mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Update only User who are enterprise owner
This commit is contained in:
committed by
Konrad
parent
56b75ad9fb
commit
f643ba5074
@@ -3,7 +3,18 @@ class AddTermsOfServiceAcceptedAtToSpreeUsers < ActiveRecord::Migration[7.0]
|
||||
add_column :spree_users, :terms_of_service_accepted_at, :datetime
|
||||
|
||||
if Spree::Config.enterprises_require_tos == true
|
||||
Spree::User.update_all(terms_of_service_accepted_at: Time.zone.now)
|
||||
# Update only user who are owners of at least 1 enterprise
|
||||
ActiveRecord::Base.sanitize_sql(["
|
||||
UPDATE spree_users
|
||||
SET terms_of_service_accepted_at = :time
|
||||
WHERE spree_users.id IN(
|
||||
SELECT id FROM spree_users WHERE EXISTS (
|
||||
SELECT 1 FROM enterprises WHERE spree_users.id = enterprises.owner_id
|
||||
)
|
||||
)".squish,
|
||||
time: Time.zone.now
|
||||
])
|
||||
ActiveRecord::Base.connection.execute(sql)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user