diff --git a/ruby/db/migrate/20250227125441_add_profile_complete_columns_to_users.rb b/ruby/db/migrate/20250227125441_add_profile_complete_columns_to_users.rb index ca64edcc7..3d6a08c66 100644 --- a/ruby/db/migrate/20250227125441_add_profile_complete_columns_to_users.rb +++ b/ruby/db/migrate/20250227125441_add_profile_complete_columns_to_users.rb @@ -7,7 +7,10 @@ execute "ALTER TABLE users ADD COLUMN profile_complete_reminder2_sent_at TIMESTAMP" execute "ALTER TABLE users ADD COLUMN profile_complete_reminder3_sent_at TIMESTAMP" - User.where('users.id IN (SELECT player_id FROM musicians_instruments) OR users.id IN (SELECT player_id FROM genre_players)').update_all(profile_completed_at: Time.now) + User.find_each(batch_size:100) do |user| + User.where(id:user.id).update_all(profile_completed_at: Time.now) + end + #User.where('users.id IN (SELECT player_id FROM musicians_instruments) OR users.id IN (SELECT player_id FROM genre_players)').update_all(profile_completed_at: Time.now) end def self.down execute "ALTER TABLE users DROP COLUMN profile_completed_at" @@ -17,10 +20,10 @@ end end =begin - ALTER TABLE users ADD COLUMN profile_completed_at TIMESTAMP - CREATE INDEX index_users_on_profile_completed_at ON users USING btree (profile_completed_at) - ALTER TABLE users ADD COLUMN profile_complete_reminder1_sent_at TIMESTAMP - ALTER TABLE users ADD COLUMN profile_complete_reminder2_sent_at TIMESTAMP - ALTER TABLE users ADD COLUMN profile_complete_reminder3_sent_at TIMESTAMP + ALTER TABLE users ADD COLUMN profile_completed_at TIMESTAMP; + CREATE INDEX index_users_on_profile_completed_at ON users USING btree (profile_completed_at); + ALTER TABLE users ADD COLUMN profile_complete_reminder1_sent_at TIMESTAMP; + ALTER TABLE users ADD COLUMN profile_complete_reminder2_sent_at TIMESTAMP; + ALTER TABLE users ADD COLUMN profile_complete_reminder3_sent_at TIMESTAMP; UPDATE users set profile_completed_at=NOW() WHERE users.id IN (SELECT player_id FROM musicians_instruments) OR users.id IN (SELECT player_id FROM genre_players); end \ No newline at end of file