Closed (duplicate)
Project:
Content Construction Kit (CCK)
Version:
7.x-2.x-dev
Component:
General
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
13 Dec 2011 at 16:05 UTC
Updated:
30 Jan 2012 at 16:18 UTC
Hi,
Found needed to clean the data before migrate as there were some duplicate path entries, added a hook_install to clean out duplicate enties and leave the most recent ones:
function xxxx_update_7025() {
// remove dupicate entries
$query = db_select('files', 'f');
$query->addField('f', 'filepath', 'filepath');
$query->addField('f', 'fid', 'fid');
$query->addExpression('COUNT(*)', 'count');
$query->groupBy('filepath');
$query->orderBy('fid', 'ASC');
$results = $query->execute();
foreach ($results as $result) {
if($result->count>1){
db_delete('files')->condition(fid, $result->fid, '!=')->execute();
}
}
}
Comments
Comment #1
seaneffel commentedPick this up here: http://drupal.org/node/1176186