Commit df7bb131 by liangyuzhe

change rake

parent 4aa1166b
...@@ -4,12 +4,12 @@ namespace :data_migrations do ...@@ -4,12 +4,12 @@ namespace :data_migrations do
desc "batch delete notification_statistics data" desc "batch delete notification_statistics data"
task :v1_batch_delete_notification_statistics_data => :environment do task :v1_batch_delete_notification_statistics_data => :environment do
first_id = NotificationStatistic.first.id first_id = NotificationStatistic.first.id
last_id = NotificationStatistic.where("notification_statistics.created_at < ?", '2020-04-30 16:00:00').last.id last_object = NotificationStatistic.where("notification_statistics.created_at < ?", '2020-04-30 16:00:00').last
first_id.step(last_id, 10000) do |i| first_id.step(last_object.id, 10000) do |i|
NotificationStatistic.where(id: [i...i+10000]).delete_all NotificationStatistic.where(id: [i...i+10000]).delete_all
end end if last_object.present?
end end
end end
end end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment