Sha256: 3019ef2b37366570ef9f62ea187ed573bc75b02dcc5b1ac8f88ea651ea5e09c8

Contents?: true

Size: 1.48 KB

Versions: 5

Compression:

Stored size: 1.48 KB

Contents

class <%= migration_class_name %> < ActiveRecord::Migration<%= migration_version %>
  def change
    create_table :ahoy_visits do |t|
      t.string :visit_token
      t.string :visitor_token

      # the rest are recommended but optional
      # simply remove any you don't want

      # user
      t.references :user

      # standard
      t.string :ip
      t.text :user_agent
      t.text :referrer
      t.string :referring_domain
      t.text :landing_page

      # technology
      t.string :browser
      t.string :os
      t.string :device_type

      # location
      t.string :country
      t.string :region
      t.string :city
      t.float :latitude
      t.float :longitude

      # utm parameters
      t.string :utm_source
      t.string :utm_medium
      t.string :utm_term
      t.string :utm_content
      t.string :utm_campaign

      # native apps
      t.string :app_version
      t.string :os_version
      t.string :platform

      t.timestamp :started_at
    end

    add_index :ahoy_visits, [:visit_token], unique: true

    create_table :ahoy_events do |t|
      t.references :visit
      t.references :user

      t.string :name
      t.<%= properties_type %> :properties
      t.timestamp :time
    end

    add_index :ahoy_events, [:name, :time]<% if properties_type == "jsonb" %><% if rails52? %>
    add_index :ahoy_events, :properties, using: :gin, opclass: :jsonb_path_ops<% else %>
    add_index :ahoy_events, "properties jsonb_path_ops", using: "gin"<% end %><% end %>
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ahoy_matey-3.0.4 lib/generators/ahoy/templates/active_record_migration.rb.tt
ahoy_matey-3.0.3 lib/generators/ahoy/templates/active_record_migration.rb.tt
ahoy_matey-3.0.2 lib/generators/ahoy/templates/active_record_migration.rb.tt
ahoy_matey-3.0.1 lib/generators/ahoy/templates/active_record_migration.rb.tt
ahoy_matey-3.0.0 lib/generators/ahoy/templates/active_record_migration.rb.tt