+/* this script when run on the current db migrates it to rails */
+
drop table meta_nodes;
alter table current_nodes modify tags text not null;
alter table current_nodes modify id bigint(64) not null auto_increment;
alter table gpx_files change private public boolean default 1 not null;
update gpx_files set public = !public;
+create index gpx_files_visible_public_idx on gpx_files(visible, public);
alter table gpx_file_tags change sequence_id sequence_id int(11);
alter table gpx_file_tags drop primary key;
alter table gpx_file_tags add id int(20) auto_increment not null, add primary key(id);
alter table users add preferences text;
+create index users_display_name_idx on users(display_name);
+
+alter table users add data_public boolean default false;
+
+alter table gpx_files drop column tmpname;
+
+alter table users add column description text not null;
+create table diary_entries(id bigint not null auto_increment, user_id bigint not null, title varchar(255), body text, primary key(id));
+alter table diary_entries add created_at datetime;
+alter table diary_entries add updated_at datetime;
+
+alter table users add column (home_lat double default 0);
+alter table users add column (home_lon double default 0);
+alter table users add column home_zoom int(2) default 3);
+alter table users add column within_lon double default 2;
+alter table users add column within_lat double default 2;
+
+create table messages (id bigint not null auto_increment, user_id bigint(20) not null, from_user_id bigint(20) not null, from_display_name varchar(255) default "", to_user_id bigint(20) not null, title varchar(255), body text, sent_on datetime, message_read boolean default 0, primary key(id));
+create index from_name_idx on messages(from_display_name);
+
+create table friends (id bigint not null auto_increment, user_id bigint(20) not null, friend_user_id bigint(20) not null, primary key(id));
+create index user_id_idx on friends(friend_user_id);