# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig. # License: Apache License, Version 2.0 require 'active_record' module RTM module AR module TMDM class Topic < ActiveRecord::Base;end class ItemIdentifier < ActiveRecord::Base belongs_to :topic_map_construct end class SubjectIdentifier < ActiveRecord::Base belongs_to :topic end class SubjectLocator < ActiveRecord::Base belongs_to :topic end class QuaaxTM2RTM < ActiveRecord::Migration 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", "association_roles" rename_column "association_roles", "type_id", "ttype_id" rename_column "association_roles", "reference", "topic_id" rename_table "qtm_topicname", "topic_names" rename_column "topic_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", "topic_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.topic_map_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 :topic_map_construct_id, :integer t.column :topic_map_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 def self.down raise "not supported" end end end end end #if __FILE__ == $0 # puts "Generating SQLite3 Databse tmdm.sqlite3." # ActiveRecord::Base.establish_connection( # :adapter => "sqlite3", # :database => "tmdm.sqlite3" # ) # RTM::AR::TMDM::QuaaxTM2RTM.migrate(:up) #end