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: 20141020153415_add_public_version_to_posts.rb
    path of file: ./repos/discourse/db/migrate
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

class AddPublicVersionToPosts < ActiveRecord::Migrat
    
  def up
    add_column :posts, :public_version, :integer, null: false, default: 1

    execute <<-SQL
      UPDATE posts
         SET public_version = 1 + (SELECT COUNT(*) FROM post_revisions pr WHERE post_id = posts.id AND pr.hidden = 'f')
       WHERE public_version <> 1 + (SELECT COUNT(*) FROM post_revisions pr WHERE post_id = posts.id AND pr.hidden = 'f')
    SQL
  end