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
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
# File 'lib/worlddb/schema.rb', line 9
def self.up
ActiveRecord::Schema.define do
create_table :countries do |t|
t.string :title, :null => false
t.string :key, :null => false
t.string :code, :null => false t.string :synonyms t.integer :pop, :null => false t.integer :area, :null => false t.references :country
t.boolean :s, :null => false, :default => false t.boolean :c, :null => false, :default => false t.boolean :d, :null => false, :default => false
t.string :motor t.string :iso2 t.string :iso3 t.string :fifa t.string :net t.string :wikipedia
t.timestamps
end
add_index :countries, :key, :unique => true
add_index :countries, :code, :unique => true
create_table :regions do |t|
t.string :title, :null => false
t.string :key, :null => false
t.string :code t.string :synonyms t.references :country, :null => false
t.integer :pop t.integer :area t.timestamps
end
add_index :regions, [:key, :country_id], :unique => true
create_table :cities do |t|
t.string :title, :null => false
t.string :key, :null => false
t.string :code t.string :synonyms t.references :country, :null => false
t.references :region t.references :city t.integer :pop t.integer :popm t.integer :area t.float :lat t.float :lng
t.boolean :m, :null => false, :default => false t.boolean :c, :null => false, :default => false t.boolean :d, :null => false, :default => false
t.timestamps
end
create_table :tags do |t|
t.string :key, :null => false
t.string :slug, :null => false
t.string :title t.timestamps
end
add_index :tags, :key, :unique => true
create_table :taggings do |t|
t.references :tag, :null => false
t.references :taggable, :polymorphic => true
t.timestamps end
add_index :taggings, :tag_id
add_index :taggings, [:taggable_id, :taggable_type]
create_table :props do |t|
t.string :key, :null => false
t.string :value, :null => false
t.timestamps
end
end
Prop.create!( key: 'db.schema.world.version', value: WorldDB::VERSION )
end
|