Indefero

Indefero Commit Details


Date:2011-05-31 07:53:44 (13 years 6 months ago)
Author:William MARTIN
Branch:develop, feature.content-md5, feature.diff-whitespace, feature.download-md5, feature.issue-of-others, feature.issue-summary, feature.search-filter, feature.webrepos, feature.wiki-default-page, release-1.2, release-1.3
Commit:06c57f7da6d20dd5eab8b82639f8faf3e63fbebb
Parents: 4d5418a60177e19d030f1920d182b8a8ce62f07f
Message:Set the SQL type to VARCHAR(32) Process the md5 of each file during the migrationUpdate all IDF_Upload object to process their md5 during the migration

Changes:

File differences

src/IDF/Migrations/17DownloadMD5.php
2727
2828
2929
30
3031
3132
32
33
33
34
3435
3536
3637
3738
3839
3940
41
42
43
44
45
46
47
4048
4149
4250
4351
52
4453
4554
4655
......
5160
5261
5362
54
5563
function IDF_Migrations_17DownloadMD5_up($params=null)
{
// Add the row
$table = Pluf::factory('IDF_Upload')->getSqlTable();
$sql = array();
$sql['PostgreSQL'] = 'ALTER TABLE '.$table.' ADD COLUMN "md5" TEXT DEFAULT \'\'';
$sql['MySQL'] = 'ALTER TABLE '.$table.' ADD COLUMN `md5` LONGTEXT DEFAULT \'\'';
$sql['PostgreSQL'] = 'ALTER TABLE '.$table.' ADD COLUMN "md5" VARCHAR(32) DEFAULT \'\'';
$sql['MySQL'] = 'ALTER TABLE '.$table.' ADD COLUMN `md5` VARCHAR(32) DEFAULT \'\'';
$db = Pluf::db();
$engine = Pluf::f('db_engine');
if (!isset($sql[$engine])) {
throw new Exception('SQLite complex migration not supported.');
}
$db->execute($sql[$engine]);
// Process md5 of already uploaded file
$files = Pluf::factory('IDF_Upload')->getList();
foreach ($files as $f) {
$f->md5 = md5_file (Pluf::f('upload_path') . '/' . $f->get_project()->shortname . '/files/' . $f->file);
$f->update();
}
}
function IDF_Migrations_17DownloadMD5_down($params=null)
{
// Remove the row
$table = Pluf::factory('IDF_Upload')->getSqlTable();
$sql = array();
$sql['PostgreSQL'] = 'ALTER TABLE '.$table.' DROP COLUMN "md5"';
throw new Exception('SQLite complex migration not supported.');
}
$db->execute($sql[$engine]);
}

Archive Download the corresponding diff file

Page rendered in 0.07636s using 13 queries.