Skip to content

Instantly share code, notes, and snippets.

@adambair
Forked from gkilmain/expires_at migration
Last active December 19, 2015 13:59
Show Gist options
  • Save adambair/5966409 to your computer and use it in GitHub Desktop.
Save adambair/5966409 to your computer and use it in GitHub Desktop.
class AddExpiresAtToOffer < ActiveRecord::Migration
def change
add_column :offers, :expires_at, :date
Offer.reset_column_information
puts 'Setting expiration dates...'
Offer.find_each do |offer|
expiration_date = offer.created_at + 6.months
offer.update_column(:expires_at, expiration_date)
print '.'
end
puts 'Done.'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment