]> git.openstreetmap.org Git - rails.git/blob - db/migrate/001_create_osm_db.rb
fix indentation. Get teh api version from the constant, rather than hard coding it...
[rails.git] / db / migrate / 001_create_osm_db.rb
1 require 'lib/migrate'
2
3 class CreateOsmDb < ActiveRecord::Migration
4   def self.up
5     create_table "current_nodes", innodb_table do |t|
6       t.column "id",        :bigint,   :limit => 64,                 :null => false
7       t.column "latitude",  :double
8       t.column "longitude", :double
9       t.column "user_id",   :bigint,   :limit => 20
10       t.column "visible",   :boolean
11       t.column "tags",      :text,                   :default => "", :null => false
12       t.column "timestamp", :datetime
13     end
14
15     add_index "current_nodes", ["id"], :name => "current_nodes_id_idx"
16     add_index "current_nodes", ["latitude", "longitude"], :name => "current_nodes_lat_lon_idx"
17     add_index "current_nodes", ["timestamp"], :name => "current_nodes_timestamp_idx"
18
19     change_column "current_nodes", "id", :bigint, :limit => 64, :null => false, :options => "AUTO_INCREMENT"
20
21     create_table "current_segments", innodb_table do |t|
22       t.column "id",        :bigint,   :limit => 64,                 :null => false
23       t.column "node_a",    :bigint,   :limit => 64
24       t.column "node_b",    :bigint,   :limit => 64
25       t.column "user_id",   :bigint,   :limit => 20
26       t.column "visible",   :boolean
27       t.column "tags",      :text,                   :default => "", :null => false
28       t.column "timestamp", :datetime
29     end
30
31     add_index "current_segments", ["id", "visible"], :name => "current_segments_id_visible_idx"
32     add_index "current_segments", ["node_a"], :name => "current_segments_a_idx"
33     add_index "current_segments", ["node_b"], :name => "current_segments_b_idx"
34
35     change_column "current_segments", "id", :bigint, :limit => 64, :null => false, :options => "AUTO_INCREMENT"
36
37     create_table "current_way_segments", innodb_table do |t|
38       t.column "id",          :bigint, :limit => 64
39       t.column "segment_id",  :bigint, :limit => 11
40       t.column "sequence_id", :bigint, :limit => 11
41     end
42
43     add_index "current_way_segments", ["segment_id"], :name => "current_way_segments_seg_idx"
44     add_index "current_way_segments", ["id"], :name => "current_way_segments_id_idx"
45
46     create_table "current_way_tags", myisam_table do |t|
47       t.column "id", :bigint, :limit => 64
48       t.column "k",  :string,                :default => "", :null => false
49       t.column "v",  :string,                :default => "", :null => false
50     end
51
52     add_index "current_way_tags", ["id"], :name => "current_way_tags_id_idx"
53     execute "CREATE FULLTEXT INDEX `current_way_tags_v_idx` ON `current_way_tags` (`v`)"
54
55     create_table "current_ways", myisam_table do |t|
56       t.column "id",        :bigint,   :limit => 64, :null => false
57       t.column "user_id",   :bigint,   :limit => 20
58       t.column "timestamp", :datetime
59       t.column "visible",   :boolean
60     end
61
62     add_primary_key "current_ways", ["id"]
63
64     change_column "current_ways", "id", :bigint, :limit => 64, :null => false, :options => "AUTO_INCREMENT"
65
66     create_table "diary_entries", myisam_table do |t|
67       t.column "id",         :bigint,   :limit => 20, :null => false
68       t.column "user_id",    :bigint,   :limit => 20, :null => false
69       t.column "title",      :string
70       t.column "body",       :text
71       t.column "created_at", :datetime
72       t.column "updated_at", :datetime
73     end
74
75     add_primary_key "diary_entries", ["id"]
76
77     change_column "diary_entries", "id", :bigint, :limit => 20, :null => false, :options => "AUTO_INCREMENT"
78
79     create_table "friends", myisam_table do |t|
80       t.column "id",             :bigint,  :limit => 20, :null => false
81       t.column "user_id",        :bigint,  :limit => 20, :null => false
82       t.column "friend_user_id", :bigint,  :limit => 20, :null => false
83     end
84
85     add_primary_key "friends", ["id"]
86     add_index "friends", ["friend_user_id"], :name => "user_id_idx"
87
88     change_column "friends", "id", :bigint, :limit => 20, :null => false, :options => "AUTO_INCREMENT"
89
90     create_table "gps_points", myisam_table do |t|
91       t.column "altitude",  :float
92       t.column "user_id",   :integer,  :limit => 20
93       t.column "trackid",   :integer
94       t.column "latitude",  :integer
95       t.column "longitude", :integer
96       t.column "gpx_id",    :integer,  :limit => 20
97       t.column "timestamp", :datetime
98     end
99
100     add_index "gps_points", ["latitude", "longitude", "user_id"], :name => "points_idx"
101     add_index "gps_points", ["user_id"], :name => "points_uid_idx"
102     add_index "gps_points", ["gpx_id"], :name => "points_gpxid_idx"
103
104     create_table "gpx_file_tags", myisam_table do |t|
105       t.column "gpx_id", :bigint,  :limit => 64, :default => 0, :null => false
106       t.column "tag",    :string
107       t.column "id",     :integer, :limit => 20, :null => false
108     end
109
110     add_primary_key "gpx_file_tags", ["id"]
111     add_index "gpx_file_tags", ["gpx_id"], :name => "gpx_file_tags_gpxid_idx"
112
113     change_column "gpx_file_tags", "id", :integer, :limit => 20, :null => false, :options => "AUTO_INCREMENT"
114
115     create_table "gpx_files", myisam_table do |t|
116       t.column "id",          :bigint,   :limit => 64,                   :null => false
117       t.column "user_id",     :bigint,   :limit => 20
118       t.column "visible",     :boolean,                :default => true, :null => false
119       t.column "name",        :string,                 :default => "",   :null => false
120       t.column "size",        :bigint,   :limit => 20
121       t.column "latitude",    :double
122       t.column "longitude",   :double
123       t.column "timestamp",   :datetime
124       t.column "public",      :boolean,                :default => true, :null => false
125       t.column "description", :string,                 :default => ""
126       t.column "inserted",    :boolean
127     end
128
129     add_primary_key "gpx_files", ["id"]
130     add_index "gpx_files", ["timestamp"], :name => "gpx_files_timestamp_idx"
131     add_index "gpx_files", ["visible", "public"], :name => "gpx_files_visible_public_idx"
132
133     change_column "gpx_files", "id", :bigint, :limit => 64, :null => false, :options => "AUTO_INCREMENT"
134
135     create_table "gpx_pending_files", myisam_table do |t|
136       t.column "originalname", :string
137       t.column "tmpname",      :string
138       t.column "user_id",      :bigint,  :limit => 20
139     end
140
141     create_table "messages", myisam_table do |t|
142       t.column "id",                :bigint,   :limit => 20,                    :null => false
143       t.column "user_id",           :bigint,   :limit => 20,                    :null => false
144       t.column "from_user_id",      :bigint,   :limit => 20,                    :null => false
145       t.column "from_display_name", :string,                 :default => ""
146       t.column "title",             :string
147       t.column "body",              :text
148       t.column "sent_on",           :datetime
149       t.column "message_read",      :boolean,                :default => false
150       t.column "to_user_id",        :bigint,   :limit => 20,                    :null => false
151     end
152
153     add_primary_key "messages", ["id"]
154     add_index "messages", ["from_display_name"], :name => "from_name_idx"
155
156     change_column "messages", "id", :bigint, :limit => 20, :null => false, :options => "AUTO_INCREMENT"
157
158     create_table "meta_areas", myisam_table do |t|
159       t.column "id",        :bigint,  :limit => 64, :null => false
160       t.column "user_id",   :bigint,  :limit => 20
161       t.column "timestamp", :datetime
162     end
163
164     add_primary_key "meta_areas", ["id"]
165
166     change_column "meta_areas", "id", :bigint, :limit => 64, :null => false, :options => "AUTO_INCREMENT"
167
168     create_table "nodes", myisam_table do |t|
169       t.column "id",        :bigint,  :limit => 64
170       t.column "latitude",  :double
171       t.column "longitude", :double
172       t.column "user_id",   :bigint,  :limit => 20
173       t.column "visible",   :boolean
174       t.column "tags",      :text,                  :default => "", :null => false
175       t.column "timestamp", :datetime
176     end
177
178     add_index "nodes", ["id"], :name => "nodes_uid_idx"
179     add_index "nodes", ["latitude", "longitude"], :name => "nodes_latlon_idx"
180
181     create_table "segments", myisam_table do |t|
182       t.column "id",        :bigint,  :limit => 64
183       t.column "node_a",    :bigint,  :limit => 64
184       t.column "node_b",    :bigint,  :limit => 64
185       t.column "user_id",   :bigint,  :limit => 20
186       t.column "visible",   :boolean
187       t.column "tags",      :text,                  :default => "", :null => false
188       t.column "timestamp", :datetime
189     end
190
191     add_index "segments", ["node_a"], :name => "street_segments_nodea_idx"
192     add_index "segments", ["node_b"], :name => "street_segments_nodeb_idx"
193     add_index "segments", ["id"], :name => "street_segment_uid_idx"
194
195     create_table "users", innodb_table do |t|
196       t.column "email",         :string
197       t.column "id",            :bigint,   :limit => 20,                    :null => false
198       t.column "token",         :string
199       t.column "active",        :integer,                :default => 0,     :null => false
200       t.column "pass_crypt",    :string
201       t.column "creation_time", :datetime
202       t.column "timeout",       :datetime
203       t.column "display_name",  :string,                 :default => ""
204       t.column "preferences",   :text
205       t.column "data_public",   :boolean,                :default => false
206       t.column "description",   :text,                   :default => "",    :null => false
207       t.column "home_lat",      :double,                 :default => 1
208       t.column "home_lon",      :double,                 :default => 1
209       t.column "within_lon",    :double
210       t.column "within_lat",    :double
211       t.column "home_zoom",     :integer,  :limit => 2,  :default => 3
212     end
213
214     add_primary_key "users", ["id"]
215     add_index "users", ["email"], :name => "users_email_idx"
216     add_index "users", ["display_name"], :name => "users_display_name_idx"
217
218     change_column "users", "id", :bigint, :limit => 20, :null => false, :options => "AUTO_INCREMENT"
219
220     create_table "way_segments", myisam_table do |t|
221       t.column "id",          :bigint,  :limit => 64, :default => 0, :null => false
222       t.column "segment_id",  :integer
223       t.column "version",     :bigint,  :limit => 20, :default => 0, :null => false
224       t.column "sequence_id", :bigint,  :limit => 11,                :null => false
225     end
226
227     add_primary_key "way_segments", ["id", "version", "sequence_id"]
228
229     change_column "way_segments", "sequence_id", :bigint, :limit => 11, :null => false, :options => "AUTO_INCREMENT"
230
231     create_table "way_tags", myisam_table do |t|
232       t.column "id",      :bigint,  :limit => 64, :default => 0, :null => false
233       t.column "k",       :string
234       t.column "v",       :string
235       t.column "version", :bigint,  :limit => 20
236     end
237
238     add_index "way_tags", ["id", "version"], :name => "way_tags_id_version_idx"
239
240     create_table "ways", myisam_table do |t|
241       t.column "id",        :bigint,   :limit => 64, :default => 0, :null => false
242       t.column "user_id",   :bigint,   :limit => 20
243       t.column "timestamp", :datetime
244       t.column "version",   :bigint,   :limit => 20,                   :null => false
245       t.column "visible",   :boolean,                :default => true
246     end
247
248     add_primary_key "ways", ["id", "version"]
249     add_index "ways", ["id"], :name => "ways_id_version_idx"
250
251     change_column "ways", "version", :bigint, :limit => 20, :null => false, :options => "AUTO_INCREMENT"
252   end
253
254   def self.down
255     
256   end
257 end