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 alter_column_nwr_enum :current_relation_members, :member_type
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 add_fulltext_index "current_relation_tags", "v"
29 create_table "current_relations", innodb_table do |t|
30 t.column "id", :bigint_pk_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 create_table "relation_members", myisam_table do |t|
37 t.column "id", :bigint, :limit => 64, :default => 0, :null => false
38 t.column "member_type", :string, :limit => 11, :null => false
39 t.column "member_id", :bigint, :limit => 11, :null => false
40 t.column "member_role", :string
41 t.column "version", :bigint, :limit => 20, :default => 0, :null => false
44 alter_column_nwr_enum :relation_members, :member_type
45 add_primary_key "relation_members", ["id", "version", "member_type", "member_id", "member_role"]
46 add_index "relation_members", ["member_type", "member_id"], :name => "relation_members_member_idx"
48 create_table "relation_tags", myisam_table do |t|
49 t.column "id", :bigint, :limit => 64, :default => 0, :null => false
50 t.column "k", :string, :null => false, :default => ""
51 t.column "v", :string, :null => false, :default => ""
52 t.column "version", :bigint, :limit => 20, :null => false
55 add_index "relation_tags", ["id", "version"], :name => "relation_tags_id_version_idx"
57 create_table "relations", myisam_table do |t|
58 t.column "id", :bigint, :limit => 64, :null => false, :default => 0
59 t.column "user_id", :bigint, :limit => 20, :null => false
60 t.column "timestamp", :datetime, :null => false
61 t.column "version", :bigint, :limit => 20, :null => false
62 t.column "visible", :boolean, :null => false, :default => true
65 add_primary_key "relations", ["id", "version"]
66 add_index "relations", ["timestamp"], :name => "relations_timestamp_idx"
68 change_column "relations", "version", :bigint_auto_20
74 drop_table :current_relations
75 drop_table :relation_tags
76 drop_table :current_relation_tags
77 drop_table :relation_members
78 drop_table :current_relation_members