From 7ba6d8a32bacb5c93625e4370ceeb8a8b8e40d48 Mon Sep 17 00:00:00 2001 From: Kevin Date: Tue, 27 Aug 2024 07:25:15 +0100 Subject: [PATCH] Chore: Add example data migration (#4790) Because: - When I need to write a new data migration, I want to have an example migration I can reference and use to copy/paste the boilerplate. --- lib/tasks/data_migrations/example.rake | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 lib/tasks/data_migrations/example.rake diff --git a/lib/tasks/data_migrations/example.rake b/lib/tasks/data_migrations/example.rake new file mode 100644 index 0000000000..2a08bfcedd --- /dev/null +++ b/lib/tasks/data_migrations/example.rake @@ -0,0 +1,21 @@ +# create new data migration rake task file and copy the contents of this file into it +# +# namespace :data_migrations do +# +# desc "" +# task example_data_migration_name: :environment do +# puts "Processing #{Lesson.count} lessons" +# +# progressbar = ProgressBar.create(total: Lesson.count, format: '%t: |%w%i| Completed: %c %a %e') +# +# Lesson.find_each do |lesson| +# begin +# # do something +# rescue StandardError => e +# progressbar.log "There was an error with lesson ##{lesson.id}: #{e.message}" +# ensure +# progressbar.increment +# end +# end +# end +# end