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: 20160517154809_fix_user_details.rb
    path of file: ./repos/catarse/db/migrate
    
    the code of the file until where you have to start completion: class FixUserDetails < ActiveRec
    
  def change
    execute <<-SQL
    create or replace view "1".user_details as
     SELECT u.id,
    u.name,
    u.address_city,
    u.deactivated_at,
    thumbnail_image(u.*) AS profile_img_thumbnail,
    u.facebook_link,
    u.twitter AS twitter_username,
    (CASE WHEN public.is_owner_or_admin(u.id) THEN u.email ELSE NULL::text END) AS email,
    COALESCE(ut.total_contributed_projects, (0)::bigint) AS total_contributed_projects,
    COALESCE(ut.total_published_projects, (0)::bigint) AS total_published_projects,
    ( SELECT json_agg(DISTINCT ul.link) AS json_agg
           FROM user_links ul
          WHERE (ul.user_id = u.id)) AS links
   FROM (users u
     LEFT JOIN "1".user_totals ut ON ((ut.user_id = u.id)));
    SQL
  end