class SetLastPetitionCreatedAt < ActiveRecord::Migration - SetLastPetitionCreatedAt has no descriptive comment
class Petition < ActiveRecord::Base; end - SetLastPetitionCreatedAt::Petition has no descriptive comment
class Site < ActiveRecord::Base; end - SetLastPetitionCreatedAt::Site has no descriptive comment
def up
Site.update_all(last_petition_created_at: last_petition_created_at)
end
def down - SetLastPetitionCreatedAt#down doesn't depend on instance state (maybe move it to another class?)
Site.update_all(last_petition_created_at: nil)
end
private
def last_petition_created_at - SetLastPetitionCreatedAt#last_petition_created_at doesn't depend on instance state (maybe move it to another class?)
Petition.maximum(:created_at) || Time.current
end
end