anlek / mongify

Mongify allows you to map your data from a sql database and into a mongodb document database.
http://github.com/anlek/mongify
MIT License
317 stars 82 forks source link

Update failed error in - mongify process command #124

Open jyotman opened 7 years ago

jyotman commented 7 years ago

I'm getting an error using the mongify process command. All the data is copied to MongoDB from PostgreSQL but the respective foreign key ids are not updated.

This is the error I get -

Copying projects (1/1): (1387/1387) 100% |oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo| Time: 00:00:00 Copying users (1/1): (1763/1763) 100% |oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo| Time: 00:00:00 Updating References projects: (1387/1387) 100% |oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo| Time: 00:00:03 Updating References users: (1763/1763) 100% |oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo| Time: 00:00:02 /var/lib/gems/2.3.0/gems/mongo-1.12.5/lib/mongo/db.rb:610:in 'rescue in command': Database command 'update' failed: Unknown option to update command: multi (Mongo::OperationFailure) from /var/lib/gems/2.3.0/gems/mongo-1.12.5/lib/mongo/db.rb:606:in 'command' from /var/lib/gems/2.3.0/gems/mongo-1.12.5/lib/mongo/collection_writer.rb:314:in 'block in send_write_command' from /var/lib/gems/2.3.0/gems/mongo-1.12.5/lib/mongo/functional/logging.rb:55:in 'block in instrument' from /var/lib/gems/2.3.0/gems/mongo-1.12.5/lib/mongo/functional/logging.rb:20:in 'instrument' from /var/lib/gems/2.3.0/gems/mongo-1.12.5/lib/mongo/functional/logging.rb:54:in 'instrument' from /var/lib/gems/2.3.0/gems/mongo-1.12.5/lib/mongo/collection_writer.rb:313:in 'send_write_command' from /var/lib/gems/2.3.0/gems/mongo-1.12.5/lib/mongo/collection.rb:1104:in 'send_write' from /var/lib/gems/2.3.0/gems/mongo-1.12.5/lib/mongo/collection.rb:497:in 'update' from /var/lib/gems/2.3.0/gems/mongify-1.3.1/lib/mongify/database/no_sql_connection.rb:145:in 'remove_pre_mongified_ids' from /var/lib/gems/2.3.0/gems/mongify-1.3.1/lib/mongify/translation/processor_common.rb:116:in 'block in remove_pre_mongified_ids' from /var/lib/gems/2.3.0/gems/mongify-1.3.1/lib/mongify/translation/processor_common.rb:114:in 'each' from /var/lib/gems/2.3.0/gems/mongify-1.3.1/lib/mongify/translation/processor_common.rb:114:in 'remove_pre_mongified_ids' from /var/lib/gems/2.3.0/gems/mongify-1.3.1/lib/mongify/translation/process.rb:18:in 'process' from /var/lib/gems/2.3.0/gems/mongify-1.3.1/lib/mongify/cli/command/worker.rb:72:in 'execute' from /var/lib/gems/2.3.0/gems/mongify-1.3.1/lib/mongify/cli/application.rb:28:in 'execute!' from /var/lib/gems/2.3.0/gems/mongify-1.3.1/bin/mongify:15:in '<top (required)>' from /usr/local/bin/mongify:23:in 'load' from /usr/local/bin/mongify:23:in '<main>'

This is my translation file -

table "projects" do
    column "project_id", :integer, :references => "projects"
    column "projectname", :string
    column "description", :text
    column "link", :string
    column "created_on", :datetime
    column "updated_on", :datetime
    column "project_image_ratio", :float
    column "project_image_url", :string
    column "owner_id", :integer, :references => "users"
end

table "users" do
    column "user_id", :integer, :references => "users"
    column "username", :string
    column "email", :string
    column "location", :string
    column "about_me", :text
    column "created_on", :datetime
    column "updated_on", :datetime
    column "password_hash", :string
    column "user_image_ratio", :float
    column "user_image_url", :string
    column "phone_number", :string
    column "email_verified", :boolean
    column "registered", :boolean
    column "phone_number_verified", :boolean
    column "feedback_message", :string
    column "first_name", :string
    column "last_name", :string
    column "handle", :string
    column "city", :string
    column "country", :string
    column "extension", :string
    column "fcm_token", :string
    column "feedback", :string
    column "is_new_user", :string
    column "new_user_status", :string
    column "show_feedback_dialog", :string
    column "current_app_version", :integer
    column "last_notification_time", :string
end

This is the database.config file -

sql_connection do
  adapter     "postgresql"
  host        "localhost"
  username    "******"
  password    "******"
  database    "*******"
  batch_size  10000
end

mongodb_connection do
  host        "localhost"
  database    "**********"
end
ibotdotout commented 7 years ago

I got the same problem. I try to rollback Mongo database from version 3.4 to 3.2 and the error is gone.

artjomg commented 7 years ago

any fixes planned for this?

anlek commented 7 years ago

Hey @artjomg, I'm unable to dedicate time to fix this at the moment, but will gladly review pull requests.

optimus93 commented 7 years ago

Done ... downgrading to 3.2 works.. no more errors...evrything running smooth ..thnks

optimus93 commented 7 years ago

@anlek - hey brother... can we merge columns of two different tables in mongify ?

anlek commented 7 years ago

@optimus93 Yes, you can, by embedding one into the other, and using the before_save method and pushing the values to parent_row. Read the docs to learn more.

rodrigotrombeta commented 3 years ago

Dear @anlek , Nowadays MongoDB lowest version is 4.4 (and it's not possible to use MongoDB version 3.2 anymore due to it's end of life being on 2018). Given that the problem mentioned in this issue came up again and once the downgrade is not a solution anymore. Is it possible to have another fix/workaround for that issue? Thanks in advance.

anlek commented 3 years ago

Unfortunately, I don't have a solution at this time. If I had more time, I might be able to upgrade the dependencies. However, life is a bit busier these days then it used to be.