We tried it in a really big database and it lasts hours, so we changed the scripts to faster ones (and it works!):
CREATE TABLE sys_file_new LIKE sys_file; INSERT sys_file_new SELECT tx_phpunit_is_dummy_record, MAX(uid) AS uid, pid, tstamp, last_indexed, missing, storage, type, metadata, identifier, identifier_hash, folder_hash, extension, mime_type, name, sha1, size, creation_date, modification_date FROM sys_file GROUP BY BINARY identifier; SELECT * FROM sys_file_new; RENAME TABLE sys_file TO sys_file_bak; RENAME TABLE sys_file_new TO sys_file; CREATE TABLE sys_file_reference_new LIKE sys_file_reference; INSERT sys_file_reference_new SELECT tx_phpunit_is_dummy_record, MAX(uid) AS uid, pid, tstamp, crdate, cruser_id, sorting, deleted, hidden, t3ver_oid, t3ver_id, t3ver_wsid, t3ver_label, t3ver_state, t3ver_stage, t3ver_count, t3ver_tstamp, t3ver_move_id, t3_origuid, sys_language_uid, l10n_parent, l10n_diffsource, uid_local, uid_foreign, tablenames, fieldname, sorting_foreign, table_local, title, description, alternative, link, downloadname FROM sys_file_reference WHERE deleted=0 GROUP BY pid,uid_local,uid_foreign,tablenames,fieldname; SELECT * FROM sys_file_reference_new; RENAME TABLE sys_file_reference TO sys_file_reference_bak; RENAME TABLE sys_file_reference_new TO sys_file_reference; UPDATE sys_file_reference LEFT OUTER JOIN sys_file ON (sys_file.uid = sys_file_reference.uid_local) SET sys_file_reference.uid_local = sys_file_reference.uid_local + 1 WHERE sys_file.uid IS NULL;
We tried it in a really big database and it lasts hours, so we changed the scripts to faster ones (and it works!):