Class: GeocoderMaxmindGeoliteCity

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/geocoder/maxmind/templates/migration/geolite_city.rb

Class Method Summary collapse

Class Method Details

.downObject



24
25
26
27
# File 'lib/generators/geocoder/maxmind/templates/migration/geolite_city.rb', line 24

def self.down
  drop_table :maxmind_geolite_city_location
  drop_table :maxmind_geolite_city_blocks
end

.upObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/generators/geocoder/maxmind/templates/migration/geolite_city.rb', line 2

def self.up
  create_table :maxmind_geolite_city_blocks, id: false do |t|
    t.column :start_ip_num, :bigint, null: false
    t.column :end_ip_num, :bigint, null: false
    t.column :loc_id, :bigint, null: false
  end
  add_index :maxmind_geolite_city_blocks, :start_ip_num, unique: true

  create_table :maxmind_geolite_city_location, id: false do |t|
    t.column :loc_id, :bigint, null: false
    t.string :country, null: false
    t.string :region, null: false
    t.string :city
    t.string :postal_code, null: false
    t.float :latitude
    t.float :longitude
    t.integer :metro_code
    t.integer :area_code
  end
  add_index :maxmind_geolite_city_location, :loc_id, unique: true
end