2

I am supposed to migrate a Paperclip file attachment from a user to a new profile table.

Doing the migration with Active Record takes several hours since the User table is fairly big (400 000 Users).

So I tried to do it via pure MySQL commands inside a Rails migration copying the 4 columns over that are created by the paperclip gem like this:

execute "INSERT INTO profiles 
  (avatar_file_name, 
    avatar_content_type,
    avatar_file_size,
    avatar_updated_at)
  SELECT
    avatar_file_name, 
    avatar_content_type,
    avatar_file_size,
    avatar_updated_at
  FROM users"

Checking the columns after the migration, the data was copied correctly and everything seems alright. However, none of the avatars show up and I get the default picture for non existent paperclip attachments.

I was wondering if someone knows how to copy paperclip file attachgment with pure MySQL or has experience in general with migrating large amounts of paperclip file attachements.

Thx,

Uli

0

Your Answer

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