  class CreateAppInterations < ActiveRecord::Migration
    def self.up
      execute(<<-SQL
        CREATE UNLOGGED TABLE public.app_interactions (
          id character varying(64) DEFAULT public.uuid_generate_v4() PRIMARY KEY NOT NULL,
          user_id character varying(64) NOT NULL,
          client character varying(64),
          screen character varying(64),
          action character varying(64),
          action_at timestamp without time zone DEFAULT now()
        );    
      SQL
      )
      execute("CREATE INDEX index_app_interactions_screen_action ON public.app_interactions USING btree (screen, action);")
    end
    def self.down
      execute("DROP INDEX index_app_interactions_screen_action")
      execute("DROP TABLE public.app_interactions")
    end
  end
