23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
# File 'lib/rtm/activerecord/quaaxtm2rtmviews.rb', line 23
def self.up
create_view "topic_maps", "select id, baselocator from qtm_topicmap" do |t|
t.column :id
t.column :base_locator
end
create_view "topics", "select id, topicmap_id, null, null from qtm_topic" do |t|
t.column :id
t.column :topic_map_id
t.column :reified_id
t.column :reified_type
end
create_view "associations", "select id, topicmap_id, type_id from qtm_association" do |t|
t.column :id
t.column :topic_map_id
t.column :ttype_id
end
create_view "roles", "select id, association_id, type_id, reference from qtm_assocrole" do |t|
t.column :id
t.column :association_id
t.column :ttype_id
t.column :topic_id
end
create_view "names", "select id, topic_id, type_id, value from qtm_topicname" do |t|
t.column :id
t.column :topic_id
t.column :ttype_id
t.column :value
end
create_view "occurrence", "select id, topic_id, type_id, value, datatype from qtm_occurrence" do |t|
t.column :id
t.column :topic_id
t.column :ttype_id
t.column :value
t.column :datatype
end
create_view "variants", "select id, topicname_id, value, datatype from qtm_variant" do |t|
t.column :id
t.column :topic_name_id
t.column :value
t.column :datatype
end
rename_table "qtm_topicmapconstructref", "item_identifiers"
rename_column "item_identifiers", "locator", "reference"
add_column :item_identifiers, :topic_map_id, :integer
ItemIdentifier.reset_column_information
ItemIdentifier.find(:all).each do |si|
si.update_attribute :topic_map_id, si.construct.topic_map_id
end
create_table :item_identifiers do |t|
t.column :topic_map_id, :integer, :null => false
t.column :reference, :string, :null => false
t.column :construct_id, :integer
t.column :construct_type, :string
end
SubjectIdentifier.reset_column_information
SubjectIdentifier.find(:all).each do |si|
si.update_attribute :topic_map_id, si.topic.topic_map_id
end
rename_table "qtm_subjectidentifier", "subject_identifiers"
rename_column :subject_identifiers, "locator", "reference"
add_column :subject_identifiers, :topic_map_id, :integer
SubjectIdentifier.reset_column_information
SubjectIdentifier.find(:all).each do |si|
si.update_attribute :topic_map_id, si.topic.topic_map_id
end
rename_table "qtm_subjectlocator", "subject_locators"
rename_column :subject_locators, "locator", "reference"
add_column :subject_locators, :topic_map_id, :integer
Topic.reset_column_information
SubjectLocator.reset_column_information
SubjectLocator.find(:all).each do |si|
si.update_attribute :topic_map_id, si.topic.topic_map_id
end
create_table :scoped_objects_topics do |t|
t.column :scoped_object_id, :integer
t.column :scoped_object_type, :string
t.column :topic_id, :integer
end
end
|