2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/generators/us_zipcode/templates/migration.rb', line 2
def self.up
create_table :zipcodes do |t|
t.string :code
t.string :city
t.integer :state_id, foreign_key: true
t.integer :county_id, foreign_key: true
t.decimal :lat, :precision => 15, :scale => 10
t.decimal :lon, :precision => 15, :scale => 10
t.timestamps
end
add_index :zipcodes, :code
add_index :zipcodes, :county_id
add_index :zipcodes, :state_id
add_index :zipcodes, [:lat, :lon]
create_table :states do |t|
t.string :abbr, :limit => 2
t.string :name
t.timestamps
end
add_index :states, :abbr
create_table :counties do |t|
t.integer :state_id
t.string :name
t.timestamps
end
add_index :counties, :name
add_index :counties, :state_id
end
|