Class: CreateGeonamesFeatures

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/geonames_dump/templates/db/migrate/create_geonames_features.rb

Class Method Summary collapse

Class Method Details

.downObject



61
62
63
# File 'lib/generators/geonames_dump/templates/db/migrate/create_geonames_features.rb', line 61

def self.down
  drop_table :geonames_features
end

.upObject

geonameid : integer id of record in geonames database name : name of geographical point (utf8) varchar(200) asciiname : name of geographical point in plain ascii characters, varchar(200) alternatenames : alternatenames, comma separated varchar(4000) (varchar(5000) for SQL Server) latitude : latitude in decimal degrees (wgs84) longitude : longitude in decimal degrees (wgs84) feature class : see www.geonames.org/export/codes.html, char(1) feature code : see www.geonames.org/export/codes.html, varchar(10) country code : ISO-3166 2-letter country code, 2 characters cc2 : alternate country codes, comma separated, ISO-3166 2-letter country code, 60 characters admin1 code : fipscode (subject to change to iso code), isocode for the us and ch, see file admin1Codes.txt for display names of this code; varchar(20) admin2 code : code for the second administrative division, a county in the US, see file admin2Codes.txt; varchar(80) admin3 code : code for third level administrative division, varchar(20) admin4 code : code for fourth level administrative division, varchar(20) population : bigint (4 byte int) elevation : in meters, integer gtopo30 : average elevation of 30’x30’ (ca 900mx900m) area in meters, integer timezone : the timezone id (see file timeZone.txt) modification date : date of last modification in yyyy-MM-dd format



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/generators/geonames_dump/templates/db/migrate/create_geonames_features.rb', line 22

def self.up
  create_table :geonames_features do |t|
    t.integer :geonameid
    t.string :name
    t.string :asciiname
    t.string :alternatenames
    t.float :latitude
    t.float :longitude
    t.string :feature_class
    t.string :feature
    t.string :country
    t.string :cc2
    t.string :admin1
    t.string :admin2
    t.string :admin3
    t.string :admin4
    t.integer :population
    t.integer :elevation
    t.integer :gtopo30
    t.string :timezone
    t.timestamp :modification
    t.string :type
    # OPTIMIZE: create another table for all names (alternate names)
    t.string :asciiname_first_letters


    t.timestamps
  end

  add_index :geonames_features, :geonameid
  add_index :geonames_features, :name
  add_index :geonames_features, :asciiname
  add_index :geonames_features, :country
  add_index :geonames_features, :population
  add_index :geonames_features, :admin1
  add_index :geonames_features, :type
  add_index :geonames_features, :asciiname_first_letters
end