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: 20180529181144_show_contact_message_origin.rb
    path of file: ./repos/catarse/db/migrate
    
    the code of the file until where you have to start completion: class ShowContactMessageOrigin < ActiveRecord::Migration
  def up
    execute <<-SQL
      ALTER TABLE "direct_messages"
      ADD "data" JSON NOT NULL DEFAULT E'{}';
      
      CREATE OR REPLACE VIEW "1"."direct_messages" AS 
      SELECT dm.user_id,
          dm.to_user_id,
          dm.project_id,
          dm.from_email,
          dm.from_name,
          dm.content,
          dm.data
        FROM direct_mess
    
  def up
    execute <<-SQL
      ALTER TABLE "direct_messages"
      ADD "data" JSON NOT NULL DEFAULT E'{}';
      
      CREATE OR REPLACE VIEW "1"."direct_messages" AS 
      SELECT dm.user_id,
          dm.to_user_id,
          dm.project_id,
          dm.from_email,
          dm.from_name,
          dm.content,
          dm.data
        FROM direct_messages dm
        WHERE is_owner_or_admin(dm.to_user_id);

      grant select on "1".direct_messages to web_user, admin, anonymous;
      grant insert on "1"."direct_messages" to web_user, admin, anonymous;

      CREATE OR REPLACE FUNCTION public.insert_direct_message()
      RETURNS trigger
      LANGUAGE plpgsql
      AS $function$
                    declare
                      direct_message "1".direct_messages;
                    begin
                      insert into public.direct_messages (user_id, to_user_id, project_id, from_email, from_name, content, data)
                      values (current_user_id(), NEW.to_user_id, NEW.project_id, NEW.from_email, NEW.from_name, NEW.content, NEW.data);
                      
                      return new;
                    end;
                  $function$      
    SQL
  end