You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: 20160312023857_generate_lead_for_published_posts.rb
    path of file: ./repos/stories/db/migrate
    
    the code of the file until where you have to start completion: class GenerateLeadForPublishedPosts < ActiveRecord::M
    
  def change
    reversible do |dir|
      dir.up do
        Post.find_each do |post|
          post.generate_lead!
          post.save
        end
      end

      dir.down{ raise ActiveRecord::IrreversibleMigration }
    end
  end