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: 20161018235724_fixes_project_search_order_again.rb
    path of file: ./repos/catarse/db/migrate
    
    the code of the file until where you have to start completion: class FixesProjectSearchOrderAgain < ActiveRecord::Migration
    def up
    execute <<-SQL
      DROP FUNCTION "1".project_search(query text);
      CREATE 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
    
    def up
    execute <<-SQL
      DROP FUNCTION "1".project_search(query text);
      CREATE 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.open_for_contributions DESC,
            p.score DESC NULLS LAST,
            p.state DESC,
            ts_rank(p.full_text_index, plainto_tsquery('portuguese', unaccent(query))) DESC,
            p.project_id DESC;
     $function$
    SQL
    end