1 class AddRelations < ActiveRecord::Migration
3 # a relation can have members much like a way can have nodes.
5 # way: only nodes / relation: any kind of member
6 # way: ordered sequence of nodes / relation: free-form "role" string
7 create_table "current_relation_members", innodb_table do |t|
8 t.column "id", :bigint, :limit => 64, :null => false
9 t.column "member_type", :string, :limit => 11, :null => false
10 t.column "member_id", :bigint, :limit => 11, :null => false
11 t.column "member_role", :string
13 # enums work like strings but are more efficient
14 execute "alter table current_relation_members change column member_type member_type enum('node','way','relation');"
16 add_primary_key "current_relation_members", ["id", "member_type", "member_id", "member_role"]
17 add_index "current_relation_members", ["member_type", "member_id"], :name => "current_relation_members_member_idx"
18 # the following is obsolete given the primary key, is it not?
19 # add_index "current_relation_members", ["id"], :name => "current_relation_members_id_idx"
20 create_table "current_relation_tags", myisam_table do |t|
21 t.column "id", :bigint, :limit => 64, :null => false
22 t.column "k", :string, :default => "", :null => false
23 t.column "v", :string, :default => "", :null => false
26 add_index "current_relation_tags", ["id"], :name => "current_relation_tags_id_idx"
27 execute "CREATE FULLTEXT INDEX `current_relation_tags_v_idx` ON `current_relation_tags` (`v`)"
29 create_table "current_relations", innodb_table do |t|
30 t.column "id", :bigint, :limit => 64, :null => false
31 t.column "user_id", :bigint, :limit => 20, :null => false
32 t.column "timestamp", :datetime, :null => false
33 t.column "visible", :boolean, :null => false
36 add_primary_key "current_relations", ["id"]
37 change_column "current_relations", "id", :bigint, :limit => 64, :null => false, :options => "AUTO_INCREMENT"
39 create_table "relation_members", myisam_table do |t|
40 t.column "id", :bigint, :limit => 64, :default => 0, :null => false
41 t.column "member_type", :string, :limit => 11, :null => false
42 t.column "member_id", :bigint, :limit => 11, :null => false
43 t.column "member_role", :string
44 t.column "version", :bigint, :limit => 20, :default => 0, :null => false
47 execute "alter table relation_members change column member_type member_type enum('node','way','relation');"
48 add_primary_key "relation_members", ["id", "version", "member_type", "member_id", "member_role"]
49 add_index "relation_members", ["member_type", "member_id"], :name => "relation_members_member_idx"
51 create_table "relation_tags", myisam_table do |t|
52 t.column "id", :bigint, :limit => 64, :default => 0, :null => false
53 t.column "k", :string, :null => false, :default => ""
54 t.column "v", :string, :null => false, :default => ""
55 t.column "version", :bigint, :limit => 20, :null => false
58 add_index "relation_tags", ["id", "version"], :name => "relation_tags_id_version_idx"
60 create_table "relations", myisam_table do |t|
61 t.column "id", :bigint, :limit => 64, :null => false, :default => 0
62 t.column "user_id", :bigint, :limit => 20, :null => false
63 t.column "timestamp", :datetime, :null => false
64 t.column "version", :bigint, :limit => 20, :null => false
65 t.column "visible", :boolean, :null => false, :default => true
68 add_primary_key "relations", ["id", "version"]
69 add_index "relations", ["timestamp"], :name => "relations_timestamp_idx"
71 change_column "relations", "version", :bigint, :limit => 20, :null => false, :options => "AUTO_INCREMENT"
77 drop_table :current_relations
78 drop_table :relation_tags
79 drop_table :current_relation_tags
80 drop_table :relation_members
81 drop_table :current_relation_members