Raw import for post_visibilities
This commit is contained in:
parent
a02eb39bf1
commit
0d80ded2d3
5 changed files with 56 additions and 1 deletions
|
|
@ -3,9 +3,19 @@ module Mongo
|
||||||
"mongo_"
|
"mongo_"
|
||||||
end
|
end
|
||||||
|
|
||||||
class User < ActiveRecord::Base; end
|
|
||||||
class Aspect < ActiveRecord::Base; end
|
class Aspect < ActiveRecord::Base; end
|
||||||
class AspectMembership < ActiveRecord::Base; end
|
class AspectMembership < ActiveRecord::Base; end
|
||||||
class Comment < ActiveRecord::Base; end
|
class Comment < ActiveRecord::Base; end
|
||||||
class Contact < ActiveRecord::Base; end
|
class Contact < ActiveRecord::Base; end
|
||||||
|
#class Invitation < ActiveRecord::Base; end
|
||||||
|
#class Notification < ActiveRecord::Base; end
|
||||||
|
#class Person < ActiveRecord::Base; end
|
||||||
|
#Photo?
|
||||||
|
#Post?
|
||||||
|
class PostVisibility < ActiveRecord::Base; end
|
||||||
|
#class Profile < ActiveRecord::Base; end
|
||||||
|
#class Request < ActiveRecord::Base; end
|
||||||
|
#Service?
|
||||||
|
#StatusMessage?
|
||||||
|
class User < ActiveRecord::Base; end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,14 @@ class CreateImportTables < ActiveRecord::Migration
|
||||||
add_index :mongo_contacts, [:user_mongo_id, :pending]
|
add_index :mongo_contacts, [:user_mongo_id, :pending]
|
||||||
add_index :mongo_contacts, [:person_mongo_id, :pending]
|
add_index :mongo_contacts, [:person_mongo_id, :pending]
|
||||||
|
|
||||||
|
create_table :mongo_post_visibilities do |t|
|
||||||
|
t.string :aspect_mongo_id
|
||||||
|
t.string :post_mongo_id
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
add_index :mongo_post_visibilities, :aspect_mongo_id
|
||||||
|
add_index :mongo_post_visibilities, :post_mongo_id
|
||||||
|
|
||||||
create_table :mongo_users do |t|
|
create_table :mongo_users do |t|
|
||||||
t.string :mongo_id
|
t.string :mongo_id
|
||||||
t.string :username
|
t.string :username
|
||||||
|
|
|
||||||
10
db/schema.rb
10
db/schema.rb
|
|
@ -118,6 +118,16 @@ 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", ["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"
|
add_index "mongo_contacts", ["user_mongo_id", "pending"], :name => "index_mongo_contacts_on_user_mongo_id_and_pending"
|
||||||
|
|
||||||
|
create_table "mongo_post_visibilities", :force => true do |t|
|
||||||
|
t.string "aspect_mongo_id"
|
||||||
|
t.string "post_mongo_id"
|
||||||
|
t.datetime "created_at"
|
||||||
|
t.datetime "updated_at"
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index "mongo_post_visibilities", ["aspect_mongo_id"], :name => "index_mongo_post_visibilities_on_aspect_mongo_id"
|
||||||
|
add_index "mongo_post_visibilities", ["post_mongo_id"], :name => "index_mongo_post_visibilities_on_post_mongo_id"
|
||||||
|
|
||||||
create_table "mongo_users", :force => true do |t|
|
create_table "mongo_users", :force => true do |t|
|
||||||
t.string "mongo_id"
|
t.string "mongo_id"
|
||||||
t.string "username"
|
t.string "username"
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,13 @@ OPTS
|
||||||
(mongo_id, user_mongo_id, person_mongo_id, pending, created_at, updated_at)
|
(mongo_id, user_mongo_id, person_mongo_id, pending, created_at, updated_at)
|
||||||
SQL
|
SQL
|
||||||
end
|
end
|
||||||
|
def import_raw_post_visibilities
|
||||||
|
Mongo::Aspect.connection.execute <<-SQL
|
||||||
|
#{load_string("post_visibilities")}
|
||||||
|
#{infile_opts}
|
||||||
|
(aspect_mongo_id, post_mongo_id)
|
||||||
|
SQL
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,26 @@ describe DataConversion::ImportToMysql do
|
||||||
contact.created_at.should be_nil
|
contact.created_at.should be_nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "post_visibilities" do
|
||||||
|
before do
|
||||||
|
copy_fixture_for("post_visibilities")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "imports data into the mongo_post_visibilities table" do
|
||||||
|
Mongo::PostVisibility.count.should == 0
|
||||||
|
@migrator.import_raw_post_visibilities
|
||||||
|
Mongo::PostVisibility.count.should == 44
|
||||||
|
end
|
||||||
|
|
||||||
|
it "imports all the columns" do
|
||||||
|
@migrator.import_raw_post_visibilities
|
||||||
|
pv = Mongo::PostVisibility.first
|
||||||
|
pv.post_mongo_id.should == "4d0aa87acc8cb4144b000009"
|
||||||
|
pv.aspect_mongo_id.should =="4d0916c2cc8cb40e93000004"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "users" do
|
describe "users" do
|
||||||
before do
|
before do
|
||||||
copy_fixture_for("users")
|
copy_fixture_for("users")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue