Module: ActiveRecord::ConnectionAdapters::SchemaStatements

Defined in:
lib/activerecord-postgres-earthdistance/activerecord.rb

Instance Method Summary collapse

Instance Method Details

#add_earthdistance_index(table_name, options = {}) ⇒ Object



6
7
8
# File 'lib/activerecord-postgres-earthdistance/activerecord.rb', line 6

def add_earthdistance_index(table_name, options = {})
  execute("CREATE INDEX %s_earthdistance_ix ON %s USING gist (ll_to_earth(%s, %s));" % [table_name, table_name, (options[:lat] || "lat"), (options[:lng] || "lng")])
end

#remove_earthdistance_index(table_name) ⇒ Object



10
11
12
# File 'lib/activerecord-postgres-earthdistance/activerecord.rb', line 10

def remove_earthdistance_index(table_name)
  execute("DROP INDEX %s_earthdistance_ix;" % [table_name])
end