]> git.openstreetmap.org Git - rails.git/blob - db/migrate/001_create_osm_db.rb
Merging 17846:17904 from trunk.
[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_auto_64
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_auto_64
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     add_fulltext_index "current_way_tags", "v"
54
55     create_table "current_ways", myisam_table do |t|
56       t.column "id",        :bigint_pk_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     create_table "diary_entries", myisam_table do |t|
63       t.column "id",         :bigint_pk, :null => false
64       t.column "user_id",    :bigint,   :limit => 20, :null => false
65       t.column "title",      :string
66       t.column "body",       :text
67       t.column "created_at", :datetime
68       t.column "updated_at", :datetime
69     end
70
71     create_table "friends", myisam_table do |t|
72       t.column "id",             :bigint_pk, :null => false
73       t.column "user_id",        :bigint,  :limit => 20, :null => false
74       t.column "friend_user_id", :bigint,  :limit => 20, :null => false
75     end
76
77     add_index "friends", ["friend_user_id"], :name => "user_id_idx"
78
79     create_table "gps_points", myisam_table do |t|
80       t.column "altitude",  :float
81       t.column "user_id",   :integer,  :limit => 20
82       t.column "trackid",   :integer
83       t.column "latitude",  :integer
84       t.column "longitude", :integer
85       t.column "gpx_id",    :integer,  :limit => 20
86       t.column "timestamp", :datetime
87     end
88
89     add_index "gps_points", ["latitude", "longitude", "user_id"], :name => "points_idx"
90     add_index "gps_points", ["user_id"], :name => "points_uid_idx"
91     add_index "gps_points", ["gpx_id"], :name => "points_gpxid_idx"
92
93     create_table "gpx_file_tags", myisam_table do |t|
94       t.column "gpx_id", :bigint,  :limit => 64, :default => 0, :null => false
95       t.column "tag",    :string
96       t.column "id",     :bigint_pk, :null => false
97     end
98
99     add_index "gpx_file_tags", ["gpx_id"], :name => "gpx_file_tags_gpxid_idx"
100
101     create_table "gpx_files", myisam_table do |t|
102       t.column "id",          :bigint_pk_64,                   :null => false
103       t.column "user_id",     :bigint,   :limit => 20
104       t.column "visible",     :boolean,                :default => true, :null => false
105       t.column "name",        :string,                 :default => "",   :null => false
106       t.column "size",        :bigint,   :limit => 20
107       t.column "latitude",    :double
108       t.column "longitude",   :double
109       t.column "timestamp",   :datetime
110       t.column "public",      :boolean,                :default => true, :null => false
111       t.column "description", :string,                 :default => ""
112       t.column "inserted",    :boolean
113     end
114
115     add_index "gpx_files", ["timestamp"], :name => "gpx_files_timestamp_idx"
116     add_index "gpx_files", ["visible", "public"], :name => "gpx_files_visible_public_idx"
117
118     create_table "gpx_pending_files", myisam_table do |t|
119       t.column "originalname", :string
120       t.column "tmpname",      :string
121       t.column "user_id",      :bigint,  :limit => 20
122     end
123
124     create_table "messages", myisam_table do |t|
125       t.column "id",                :bigint_pk,                                 :null => false
126       t.column "user_id",           :bigint,   :limit => 20,                    :null => false
127       t.column "from_user_id",      :bigint,   :limit => 20,                    :null => false
128       t.column "from_display_name", :string,                 :default => ""
129       t.column "title",             :string
130       t.column "body",              :text
131       t.column "sent_on",           :datetime
132       t.column "message_read",      :boolean,                :default => false
133       t.column "to_user_id",        :bigint,   :limit => 20,                    :null => false
134     end
135
136     add_index "messages", ["from_display_name"], :name => "from_name_idx"
137
138     create_table "meta_areas", myisam_table do |t|
139       t.column "id",        :bigint_pk_64, :null => false
140       t.column "user_id",   :bigint,  :limit => 20
141       t.column "timestamp", :datetime
142     end
143
144     create_table "nodes", myisam_table do |t|
145       t.column "id",        :bigint,  :limit => 64
146       t.column "latitude",  :double
147       t.column "longitude", :double
148       t.column "user_id",   :bigint,  :limit => 20
149       t.column "visible",   :boolean
150       t.column "tags",      :text,                  :default => "", :null => false
151       t.column "timestamp", :datetime
152     end
153
154     add_index "nodes", ["id"], :name => "nodes_uid_idx"
155     add_index "nodes", ["latitude", "longitude"], :name => "nodes_latlon_idx"
156
157     create_table "segments", myisam_table do |t|
158       t.column "id",        :bigint,  :limit => 64
159       t.column "node_a",    :bigint,  :limit => 64
160       t.column "node_b",    :bigint,  :limit => 64
161       t.column "user_id",   :bigint,  :limit => 20
162       t.column "visible",   :boolean
163       t.column "tags",      :text,                  :default => "", :null => false
164       t.column "timestamp", :datetime
165     end
166
167     add_index "segments", ["node_a"], :name => "street_segments_nodea_idx"
168     add_index "segments", ["node_b"], :name => "street_segments_nodeb_idx"
169     add_index "segments", ["id"], :name => "street_segment_uid_idx"
170
171     create_table "users", innodb_table do |t|
172       t.column "email",         :string
173       t.column "id",            :bigint_pk,                    :null => false
174       t.column "token",         :string
175       t.column "active",        :integer,                :default => 0,     :null => false
176       t.column "pass_crypt",    :string
177       t.column "creation_time", :datetime
178       t.column "timeout",       :datetime
179       t.column "display_name",  :string,                 :default => ""
180       t.column "preferences",   :text
181       t.column "data_public",   :boolean,                :default => false
182       t.column "description",   :text,                   :default => "",    :null => false
183       t.column "home_lat",      :double,                 :default => 1
184       t.column "home_lon",      :double,                 :default => 1
185       t.column "within_lon",    :double
186       t.column "within_lat",    :double
187       t.column "home_zoom",     :integer,  :limit => 2,  :default => 3
188     end
189
190     add_index "users", ["email"], :name => "users_email_idx"
191     add_index "users", ["display_name"], :name => "users_display_name_idx"
192
193     create_table "way_segments", myisam_table do |t|
194       t.column "id",          :bigint,  :limit => 64, :default => 0, :null => false
195       t.column "segment_id",  :integer
196       t.column "version",     :bigint,  :limit => 20, :default => 0, :null => false
197       t.column "sequence_id", :bigint,  :limit => 11,                :null => false
198     end
199
200     add_primary_key "way_segments", ["id", "version", "sequence_id"]
201
202     change_column "way_segments", "sequence_id", :bigint_auto_11
203
204     create_table "way_tags", myisam_table do |t|
205       t.column "id",      :bigint,  :limit => 64, :default => 0, :null => false
206       t.column "k",       :string
207       t.column "v",       :string
208       t.column "version", :bigint,  :limit => 20
209     end
210
211     add_index "way_tags", ["id", "version"], :name => "way_tags_id_version_idx"
212
213     create_table "ways", myisam_table do |t|
214       t.column "id",        :bigint,   :limit => 64, :default => 0, :null => false
215       t.column "user_id",   :bigint,   :limit => 20
216       t.column "timestamp", :datetime
217       t.column "version",   :bigint,   :limit => 20,                   :null => false
218       t.column "visible",   :boolean,                :default => true
219     end
220
221     add_primary_key "ways", ["id", "version"]
222     add_index "ways", ["id"], :name => "ways_id_version_idx"
223
224     change_column "ways", "version", :bigint_auto_20
225   end
226
227   def self.down
228     
229   end
230 end