has_geo_lookup 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+ class CreateFeatureCodes < ActiveRecord::Migration<%= migration_version %>
2
+ def change
3
+ return if table_exists?(:feature_codes)
4
+
5
+ create_table :feature_codes do |t|
6
+ t.string :feature_class, limit: 1
7
+ t.string :feature_code, limit: 10
8
+ t.string :name
9
+ t.text :description
10
+
11
+ t.timestamps
12
+ end
13
+
14
+ add_index :feature_codes, [:feature_class, :feature_code], unique: true
15
+ add_index :feature_codes, :feature_class
16
+ end
17
+ end
@@ -0,0 +1,24 @@
1
+ class CreateGeoboundaries < ActiveRecord::Migration<%= migration_version %>
2
+ def change
3
+ return if table_exists?(:geoboundaries)
4
+
5
+ create_table :geoboundaries do |t|
6
+ t.string :name
7
+ t.string :level
8
+ t.string :shape_group
9
+ t.string :shape_iso
10
+ t.string :shape_id
11
+ t.string :source_url
12
+ t.column :boundary, 'geometry NOT NULL SRID 4326'
13
+
14
+ t.timestamps
15
+ end
16
+
17
+ add_index :geoboundaries, :boundary, type: :spatial
18
+ add_index :geoboundaries, :level
19
+ add_index :geoboundaries, :shape_id, unique: true
20
+ add_index :geoboundaries, :name
21
+ add_index :geoboundaries, :shape_iso
22
+ add_index :geoboundaries, :shape_group
23
+ end
24
+ end
@@ -0,0 +1,10 @@
1
+ class CreateGeoboundariesMetros < ActiveRecord::Migration<%= migration_version %>
2
+ def change
3
+ return if table_exists?(:geoboundaries_metros)
4
+
5
+ create_join_table :geoboundaries, :metros do |t|
6
+ t.index [:geoboundary_id, :metro_id]
7
+ t.index [:metro_id, :geoboundary_id], unique: true
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,40 @@
1
+ class CreateGeonames < ActiveRecord::Migration<%= migration_version %>
2
+ def change
3
+ return if table_exists?(:geonames)
4
+
5
+ create_table :geonames do |t|
6
+ t.string :name, limit: 200
7
+ t.string :asciiname, limit: 200
8
+ t.decimal :latitude, precision: 10, scale: 5
9
+ t.decimal :longitude, precision: 10, scale: 5
10
+ t.string :feature_class, limit: 1
11
+ t.string :feature_code, limit: 10
12
+ t.string :country_code, limit: 2
13
+ t.string :cc2, limit: 60
14
+ t.string :admin1_code, limit: 20
15
+ t.string :admin2_code, limit: 20
16
+ t.string :admin3_code, limit: 20
17
+ t.string :admin4_code, limit: 20
18
+ t.integer :population, limit: 8
19
+ t.integer :elevation
20
+ t.integer :dem
21
+ t.string :timezone, limit: 40
22
+ t.datetime :modification_date
23
+
24
+ t.timestamps
25
+ end
26
+
27
+ # All indexes consolidated from incremental migrations
28
+ add_index :geonames, :asciiname
29
+ add_index :geonames, :country_code
30
+ add_index :geonames, :population
31
+ add_index :geonames, [:country_code, :admin1_code]
32
+ add_index :geonames, [:country_code, :admin1_code, :admin2_code]
33
+ add_index :geonames, [:feature_class, :feature_code]
34
+ add_index :geonames, [:feature_class, :feature_code, :latitude, :longitude]
35
+ add_index :geonames, [:latitude, :longitude]
36
+ add_index :geonames, :feature_code
37
+ add_index :geonames, :name
38
+ add_index :geonames, [:admin1_code, :admin2_code]
39
+ end
40
+ end
@@ -0,0 +1,10 @@
1
+ class CreateGeonamesMetros < ActiveRecord::Migration<%= migration_version %>
2
+ def change
3
+ return if table_exists?(:geonames_metros)
4
+
5
+ create_join_table :geonames, :metros do |t|
6
+ t.index [:geoname_id, :metro_id]
7
+ t.index [:metro_id, :geoname_id], unique: true
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,17 @@
1
+ class CreateMetros < ActiveRecord::Migration<%= migration_version %>
2
+ def change
3
+ return if table_exists?(:metros)
4
+
5
+ create_table :metros do |t|
6
+ t.string :name
7
+ t.text :details
8
+ t.string :country_code, limit: 2
9
+ t.integer :population
10
+
11
+ t.timestamps
12
+ end
13
+
14
+ add_index :metros, :name, unique: true
15
+ add_index :metros, :country_code
16
+ end
17
+ end