summaryrefslogtreecommitdiffstats
path: root/application/migrations
diff options
context:
space:
mode:
Diffstat (limited to 'application/migrations')
-rw-r--r--application/migrations/019_change_filesize_type.php23
1 files changed, 23 insertions, 0 deletions
diff --git a/application/migrations/019_change_filesize_type.php b/application/migrations/019_change_filesize_type.php
index 327d8dcae..47a998452 100644
--- a/application/migrations/019_change_filesize_type.php
+++ b/application/migrations/019_change_filesize_type.php
@@ -18,6 +18,29 @@ class Migration_change_filesize_type extends CI_Migration {
MODIFY `filesize` bigint;
');
}
+
+ $chunk = 500;
+
+ $total = $this->db->count_all("file_storage");
+
+ for ($limit = 0; $limit < $total; $limit += $chunk) {
+ $query = $this->db->select('hash, id')
+ ->from('file_storage')
+ ->where('filesize', 2147483647)
+ ->limit($chunk, $limit)
+ ->get()->result_array();
+
+ foreach ($query as $key => $item) {
+ $data_id = $item["hash"].'-'.$item['id'];
+ $filesize = filesize($this->mfile->file($data_id));
+
+ $this->db->where('id', $item['id'])
+ ->set(array(
+ 'filesize' => $filesize,
+ ))
+ ->update('file_storage');
+ }
+ }
}
public function down()