class <%= migration_class_name %> < ActiveRecord::Migration<%= migration_version %> def change create_table :ahoy_events do |t| t.integer :visit_id # user t.integer :user_id # add t.string :user_type if polymorphic t.string :name t.<% case @database when "postgresql" %>json<% when "postgresql-jsonb" %>jsonb<% else %>text<% end %> :properties t.timestamp :time end add_index :ahoy_events, [:visit_id, :name] add_index :ahoy_events, [:user_id, :name] add_index :ahoy_events, [:name, :time] <% if @database == "postgresql-jsonb" && ActiveRecord::VERSION::MAJOR >= 5 %>add_index :ahoy_events, 'properties jsonb_path_ops', using: 'gin'<% end %> end end