maxfid) { // Try to grab the record - if it fails, continue. if (($filerec = dbfm_selected_file_record($fidcounter, $path = NULL, $erroron = FALSE)) == FALSE) continue; // If it's a version or a directory, continue. if (($filerec->fmime == 'version') || ($filerec->fmime == 'directory')) continue; // Calculate the MD5 checksum $md5sum = md5($filerec->fblob); $updatequery = sprintf ("UPDATE {dbfm_file} SET fblobmod='%s', fmd5='%s' where fid=%d", $filerec->fcreatedate, $md5sum, $fidcounter); $ret[] = update_sql($updatequery); } $newmaxfid = ($fidrec->maxfid + 1); //the fid's no longer auto-increment. Instead we use the sequence table to issue new file id's $sequencesquery = sprintf("INSERT INTO {sequences} (name, id) VALUES ('dbfm_file_fid', %d)", $newmaxfid); $ret[] = update_sql($sequencesquery); $ret[] = update_sql("CREATE TABLE `dbfm_cronlist` ( `fid` int(10) NOT NULL, `fmd5` varchar(32) default NULL, `crontype` int(2) NOT NULL, `fdate` datetime NOT NULL, `fsize` int(10) default NULL, `fmime` varchar(255) NOT NULL, `fpath` text NOT NULL, `status` varchar(64) default NULL, `retries` int(2) NOT NULL default '0', `fparent` int(10) default NULL, `fversion` int(2) default NULL)"); $ret[] = update_sql("CREATE TABLE {dbfm_data} (select fid, fblob, fcreatedate, fmd5 from dbfm_file where fmime != 'directory' and fmime != 'version')"); $ret[] = update_sql("ALTER TABLE {dbfm_data} ADD PRIMARY KEY (`fid`)"); $ret[] = update_sql("ALTER TABLE {dbfm_data} ADD UNIQUE KEY `fid` (`fid`)"); $ret[] = update_sql("ALTER TABLE {dbfm_data} CHANGE fcreatedate fblobmod datetime NOT NULL"); $ret[] = update_sql("ALTER TABLE {dbfm_file} DROP fblob"); break; default: drupal_set_message('dbfm_update currently supports the MySQL database only', error); break; } return $ret; }