␊ |
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]);␊ |
␊ |
}␊ |