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: 20160701233522_adjust_search_to_use_score.rb
    path of file: ./repos/catarse/db/migrate
    
    the code of the file until where you have to start completion: class AdjustSearchToUseScore < ActiveRecord::Migration
  def change
    execute %{
CREATE OR REPLACE FUNCTION "1".project_search
    
  def change
    execute %{
CREATE OR REPLACE FUNCTION "1".project_search(query text)
 RETURNS SETOF "1".projects
 LANGUAGE sql
 STABLE
AS $function$
        SELECT
            p.*
        FROM
            "1".projects p
        WHERE
            (
                p.full_text_index @@ plainto_tsquery('portuguese', unaccent(query))
                OR
                p.project_name % query
            )
            AND p.state_order >= 'published'
        ORDER BY
            p.score DESC,
            p.open_for_contributions DESC,
            p.state_order,
            ts_rank(p.full_text_index, plainto_tsquery('portuguese', unaccent(query))) DESC,
            p.project_id DESC;
     $function$;
    }
  end