raw import of Invitation
This commit is contained in:
parent
a1419b9dc0
commit
564dd993b7
5 changed files with 62 additions and 8 deletions
|
|
@ -7,7 +7,7 @@ module Mongo
|
|||
class AspectMembership < ActiveRecord::Base; end
|
||||
class Comment < ActiveRecord::Base; end
|
||||
class Contact < ActiveRecord::Base; end
|
||||
#class Invitation < ActiveRecord::Base; end
|
||||
class Invitation < ActiveRecord::Base; end
|
||||
#class Notification < ActiveRecord::Base; end
|
||||
class Person < ActiveRecord::Base; end
|
||||
#Photo?
|
||||
|
|
|
|||
|
|
@ -53,6 +53,16 @@ class CreateImportTables < ActiveRecord::Migration
|
|||
add_index :mongo_people, :owner_mongo_id, :unique => true
|
||||
add_index :mongo_people, :diaspora_handle, :unique => true
|
||||
|
||||
create_table :mongo_invitations do |t|
|
||||
t.string :mongo_id
|
||||
t.text :message
|
||||
t.string :sender_mongo_id
|
||||
t.string :recipient_mongo_id
|
||||
t.string :aspect_mongo_id
|
||||
t.timestamps
|
||||
end
|
||||
add_index :mongo_invitations, :sender_mongo_id
|
||||
|
||||
create_table :mongo_post_visibilities do |t|
|
||||
t.string :aspect_mongo_id
|
||||
t.string :post_mongo_id
|
||||
|
|
|
|||
12
db/schema.rb
12
db/schema.rb
|
|
@ -118,6 +118,18 @@ ActiveRecord::Schema.define(:version => 20110105051803) do
|
|||
add_index "mongo_contacts", ["person_mongo_id", "pending"], :name => "index_mongo_contacts_on_person_mongo_id_and_pending"
|
||||
add_index "mongo_contacts", ["user_mongo_id", "pending"], :name => "index_mongo_contacts_on_user_mongo_id_and_pending"
|
||||
|
||||
create_table "mongo_invitations", :force => true do |t|
|
||||
t.string "mongo_id"
|
||||
t.text "message"
|
||||
t.string "sender_mongo_id"
|
||||
t.string "recipient_mongo_id"
|
||||
t.string "aspect_mongo_id"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
add_index "mongo_invitations", ["sender_mongo_id"], :name => "index_mongo_invitations_on_sender_mongo_id"
|
||||
|
||||
create_table "mongo_people", :force => true do |t|
|
||||
t.string "mongo_id"
|
||||
t.string "guid"
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ module DataConversion
|
|||
|
||||
def import_raw_aspect_memberships
|
||||
log "Loading aspect memberships file..."
|
||||
Mongo::Aspect.connection.execute <<-SQL
|
||||
Mongo::AspectMembership.connection.execute <<-SQL
|
||||
#{load_string("aspect_memberships")}
|
||||
#{infile_opts}
|
||||
(contact_mongo_id, aspect_mongo_id)
|
||||
|
|
@ -66,7 +66,7 @@ module DataConversion
|
|||
|
||||
def import_raw_comments
|
||||
log "Loading comments file..."
|
||||
Mongo::Aspect.connection.execute <<-SQL
|
||||
Mongo::Comment.connection.execute <<-SQL
|
||||
#{load_string("comments")}
|
||||
#{infile_opts}
|
||||
(mongo_id, post_mongo_id, person_mongo_id, @diaspora_handle, text, youtube_titles)
|
||||
|
|
@ -77,7 +77,7 @@ module DataConversion
|
|||
|
||||
def import_raw_contacts
|
||||
log "Loading contacts file..."
|
||||
Mongo::Aspect.connection.execute <<-SQL
|
||||
Mongo::Contact.connection.execute <<-SQL
|
||||
#{load_string("contacts")}
|
||||
#{infile_opts}
|
||||
(mongo_id, user_mongo_id, person_mongo_id, pending, created_at, updated_at)
|
||||
|
|
@ -87,7 +87,7 @@ module DataConversion
|
|||
|
||||
def import_raw_post_visibilities
|
||||
log "Loading post visibilities file..."
|
||||
Mongo::Aspect.connection.execute <<-SQL
|
||||
Mongo::PostVisibility.connection.execute <<-SQL
|
||||
#{load_string("post_visibilities")}
|
||||
#{infile_opts}
|
||||
(aspect_mongo_id, post_mongo_id)
|
||||
|
|
@ -97,17 +97,25 @@ module DataConversion
|
|||
|
||||
def import_raw_requests
|
||||
log "Loading requests file..."
|
||||
Mongo::Aspect.connection.execute <<-SQL
|
||||
Mongo::Request.connection.execute <<-SQL
|
||||
#{load_string("requests")}
|
||||
#{infile_opts}
|
||||
(mongo_id, recipient_mongo_id, sender_mongo_id, aspect_mongo_id)
|
||||
SQL
|
||||
log "Finished. Imported #{Mongo::Request.count} requests."
|
||||
end
|
||||
|
||||
def import_raw_invitations
|
||||
log "Loading invitations file..."
|
||||
Mongo::Invitation.connection.execute <<-SQL
|
||||
#{load_string("invitations")}
|
||||
#{infile_opts}
|
||||
(mongo_id, recipient_mongo_id, sender_mongo_id, aspect_mongo_id, message)
|
||||
SQL
|
||||
log "Finished. Imported #{Mongo::Invitation.count} invitations."
|
||||
end
|
||||
def import_raw_people
|
||||
log "Loading people file..."
|
||||
Mongo::Aspect.connection.execute <<-SQL
|
||||
Mongo::Person.connection.execute <<-SQL
|
||||
#{load_string("people")}
|
||||
#{infile_opts}
|
||||
(created_at,updated_at,serialized_public_key,url,mongo_id,@owner_mongo_id_var,diaspora_handle)
|
||||
|
|
|
|||
|
|
@ -100,6 +100,30 @@ describe DataConversion::ImportToMysql do
|
|||
contact.created_at.should be_nil
|
||||
end
|
||||
end
|
||||
describe "invitations" do
|
||||
before do
|
||||
copy_fixture_for("invitations")
|
||||
end
|
||||
|
||||
it "imports data into the mongo_invitations table" do
|
||||
Mongo::Invitation.count.should == 0
|
||||
@migrator.import_raw_invitations
|
||||
Mongo::Invitation.count.should == 1
|
||||
end
|
||||
|
||||
it "imports all the columns" do
|
||||
@migrator.import_raw_invitations
|
||||
invitation = Mongo::Invitation.first
|
||||
invitation.mongo_id.should == "4d262131cc8cb44df2000022"
|
||||
invitation.recipient_mongo_id.should =="4d26212fcc8cb44df2000021"
|
||||
invitation.sender_mongo_id.should == "4d26212acc8cb44df2000005"
|
||||
invitation.aspect_mongo_id.should == '4d26212bcc8cb44df2000006'
|
||||
invitation.message.should == "Hello!"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
describe "people" do
|
||||
before do
|
||||
copy_fixture_for("people")
|
||||
|
|
|
|||
Loading…
Reference in a new issue