diff --git a/src/IDF/Migrations/17DownloadMD5.php b/src/IDF/Migrations/17DownloadMD5.php deleted file mode 100644 index 3b86bc2..0000000 --- a/src/IDF/Migrations/17DownloadMD5.php +++ /dev/null @@ -1,63 +0,0 @@ -getSqlTable(); - $sql = array(); - $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"'; - $sql['MySQL'] = 'ALTER TABLE '.$table.' DROP COLUMN `md5`'; - $db = Pluf::db(); - $engine = Pluf::f('db_engine'); - if (!isset($sql[$engine])) { - throw new Exception('SQLite complex migration not supported.'); - } - $db->execute($sql[$engine]); -} diff --git a/src/IDF/Migrations/18DownloadMD5.php b/src/IDF/Migrations/18DownloadMD5.php new file mode 100644 index 0000000..159e909 --- /dev/null +++ b/src/IDF/Migrations/18DownloadMD5.php @@ -0,0 +1,63 @@ +getSqlTable(); + $sql = array(); + $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_18DownloadMD5_down($params=null) +{ + // Remove the row + $table = Pluf::factory('IDF_Upload')->getSqlTable(); + $sql = array(); + $sql['PostgreSQL'] = 'ALTER TABLE '.$table.' DROP COLUMN "md5"'; + $sql['MySQL'] = 'ALTER TABLE '.$table.' DROP COLUMN `md5`'; + $db = Pluf::db(); + $engine = Pluf::f('db_engine'); + if (!isset($sql[$engine])) { + throw new Exception('SQLite complex migration not supported.'); + } + $db->execute($sql[$engine]); +}