Sha256: 2cdb677353be849f9e74975d1bf231c695d128d58d2a488eb8a47148d8fc6917
Contents?: true
Size: 673 Bytes
Versions: 11
Compression:
Stored size: 673 Bytes
Contents
class AddStartedAtAndEndedAtOnTasks < ActiveRecord::Migration def up add_column :tasks, :started_at, :datetime, null: true add_column :tasks, :ended_at, :datetime, null: true say "Migrating #{Shipit::Task.count} tasks:" Shipit::Task.find_each.with_index do |task, index| unless task.started_at task.update_columns( started_at: task.created_at, ended_at: task.updated_at, # good enough approximation but not perfect ) puts if index % 100 == 0 print '.' end end puts say "Done" end def down remove_column :tasks, :started_at remove_column :tasks, :ended_at end end
Version data entries
11 entries across 11 versions & 1 rubygems