0

I switched to Postgres in development and now following error breaks a test case:

PG::Error: ERROR:  column "id" of relation "assets_content_nodes" does not exist
:           SELECT pg_get_serial_sequence($1, $2)

Same error happens in development and production environments but it is not a show stopper and does not affect the import. assets_content_nodes is a join table and I'd rather not add the 'id' column. Any ideas why this may be happening?

0

2 Answers 2

1

This is fixed in activerecord-import -v0.3.1 (or possibly an earlier version, but it was broken in 0.2.11 and earlier). You no longer need an id column on a table to do an import.

Sign up to request clarification or add additional context in comments.

Comments

0

You might also try Upsert.

If you're importing pets:

require 'csv'
require 'upsert'
u = Upsert.new Pet.connection, Pet.table_name
CSV.foreach('pets.csv', headers: :first_row) do |row|
  selector = { name: row['name'] }
  setter = row
  u.row selector, setter
end

My tests show it's 20–30% faster than activerecord-import. Since it's "upserting," it's generally OK if the process gets interrupted and you just start over from the beginning.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.