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: 20180928105835_add_index_to_tags.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 AddIndexToTags < ActiveRecord::Migration[5.2]
  def up
    # Append ID to any tags that already have duplicate names
    # Super rare case, as this is not possible to do via the UI
    # Might affect some imports
    execute <<~SQL
      UPDATE tags
      SET name = name || id
      WHERE EXISTS(SELEC
    
  def up
    # Append ID to any tags that already have duplicate names
    # Super rare case, as this is not possible to do via the UI
    # Might affect some imports
    execute <<~SQL
      UPDATE tags
      SET name = name || id
      WHERE EXISTS(SELECT * FROM tags t WHERE lower(t.name) = lower(tags.name) AND t.id < tags.id)
    SQL

    add_index :tags, "lower(name)", unique: true
  end

  def down
    raise ActiveRecord::IrreversibleMigration
  end
end