Class: RTM::AR::TMDM::QuaaxTM2RTM

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/rtm/activerecord/quaaxtm2rtm.rb

Class Method Summary collapse

Class Method Details

.downObject



99
100
101
# File 'lib/rtm/activerecord/quaaxtm2rtm.rb', line 99

def self.down
  raise "not supported"
end

.upObject



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
# File 'lib/rtm/activerecord/quaaxtm2rtm.rb', line 23

def self.up
  rename_table("qtm_topicmap", "topic_maps" )
  rename_column("topic_maps", "baselocator", "base_locator")

  rename_table("qtm_topic", "topics")
  rename_column("topics", "topicmap_id", "topic_map_id")

  add_column :topics, :reified_id, :integer
  add_column :topics, :reified_type, :string

  rename_table "qtm_association", "associations"
  rename_column "associations", "type_id", "ttype_id"
  rename_column "associations", "topicmap_id", "topic_map_id"

  rename_table "qtm_assocrole", "roles"
  rename_column "roles", "type_id", "ttype_id"
  rename_column "roles", "reference", "topic_id"
  
  rename_table "qtm_topicname", "names"
  rename_column "names", "type_id", "ttype_id"

  rename_table "qtm_occurrence", "occurrences"
  rename_column "occurrences", "type_id", "ttype_id"
  
  rename_table "qtm_variant", "variants"
  rename_column "variants", "topicname_id", "name_id"
  
  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
  
  # TODO: instance of

  #       scope

  #       reifier

end