I'm starting this thread after the discussion in #1260938: d6 to d7 update fails on file duplicates '#7061 Integrity constraint violation'. After commenting there, I had a quick discussion with David_Rothstein over IRC where he explained that the issue I have is not in core's, but in CCK's scope. So here we go.

I'm trying to upgrade a D6 site to D7.38. When using content_migrate for migrating several filefields to images, I get similar errors to this:

exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'public://header_imgs/donate_3.jpg' for key 'uri'' in /Users/zadamek/Sites/d67-file/includes/database/database.inc:2171 Stack trace: #0 /Users/zadamek/Sites/d67-file/includes/database/database.inc(2171): PDOStatement->execute(Array) #1 /Users/zadamek/Sites/d67-file/includes/database/database.inc(683): DatabaseStatementBase->execute(Array, Array) #2 /Users/zadamek/Sites/d67-file/includes/database/mysql/query.inc(36): DatabaseConnection->query('INSERT INTO {fi...', Array, Array) #3 /Users/zadamek/Sites/d67-file/includes/database/query.inc(1621): InsertQuery_mysql->execute() #4 /Users/zadamek/Sites/d67-file/sites/all/modules/cck/modules/content_migrate/modules/content_migrate.file.inc(285): MergeQuery->execute() #5 /Users/zadamek/Sites/d67-file/includes/module.inc(1101): file_content_migrate_data_record_alter(Array, Array, Array, NULL) #6 /Users/zadamek/Sites/d67-file/sites/all/modules/cck/modules/content_migrate/includes/content_migrate.admin.inc(410): drupal_alter('content_migrate...', Array, Array, Array) #7 [internal function]: _content_migrate_batch_process_migrate_data('field_header_im...', Array) #8 /Users/zadamek/Sites/d67-file/includes/batch.inc(284): call_user_func_array('_content_migrat...', Array) #9 /Users/zadamek/Sites/d67-file/includes/batch.inc(161): _batch_process() #10 /Users/zadamek/Sites/d67-file/includes/batch.inc(80): _batch_do() #11 /Users/zadamek/Sites/d67-file/modules/system/system.admin.inc(2379): _batch_page() #12 [internal function]: system_batch_page() #13 /Users/zadamek/Sites/d67-file/includes/menu.inc(519): call_user_func_array('system_batch_pa...', Array) #14 /Users/zadamek/Sites/d67-file/index.php(21): menu_execute_active_handler() #15 {main}

and it rolls back of course.

For resolving this, I had to do a manual workaround. I don't have so many duplicates in {files}, so I've manually created copies for the related images and adjusted the paths for the extra entires accordingly. With this, content_migrate proceed fine.

Comments

scorchio’s picture

Title: Filefield D6 -> D7 migration: Integrity constraint violation - Duplicate entry for key 'uri'' i » Filefield D6 -> D7 migration: Integrity constraint violation - Duplicate entry for key 'uri''
scorchio’s picture

Title: Filefield D6 -> D7 migration: Integrity constraint violation - Duplicate entry for key 'uri'' » Filefield D6 -> D7 migration: Integrity constraint violation - Duplicate entry for key 'uri'
David_Rothstein’s picture

Thanks for filing the issue. Looking through the queue I see #1176186: D6 -> D7 upgrade: Duplicate files cause Integrity constraint violation: 1062 Duplicate entry 'xx' for key 'PRIMARY' - this might be a duplicate of that one? I haven't read it carefully though.

pfrenssen’s picture

Issue summary: View changes