From 49c8b94e5a2839da7fb9c370ce199b9c06b4a6cf Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sat, 18 Jul 2015 16:25:34 +0200 Subject: Implement migration 14 for postgres Signed-off-by: Florian Pritz --- .../015_actually_deduplicate_file_storage.php | 49 +++++++++++----------- 1 file changed, 24 insertions(+), 25 deletions(-) (limited to 'application/migrations/015_actually_deduplicate_file_storage.php') diff --git a/application/migrations/015_actually_deduplicate_file_storage.php b/application/migrations/015_actually_deduplicate_file_storage.php index 2fea26dab..267afc1fe 100644 --- a/application/migrations/015_actually_deduplicate_file_storage.php +++ b/application/migrations/015_actually_deduplicate_file_storage.php @@ -8,8 +8,7 @@ class Migration_actually_deduplicate_file_storage extends CI_Migration { $prefix = $this->db->dbprefix; if ($this->db->dbdriver == 'postgre') { - // likely no need for this migration since 14 won't be buggy - throw new \exceptions\ApiException("migration/postgres/not-implemented", "migration 15 not yet implemented for postgres"); + // no need for this query since 14 is not buggy } else { // XXX: This query also exists in migration 14 $this->db->query(' @@ -25,32 +24,32 @@ class Migration_actually_deduplicate_file_storage extends CI_Migration { GROUP BY x.hash ) AND `'.$prefix.'files`.id IS NULL - '); - - $chunk = 500; - $total = $this->db->count_all("file_storage"); - $consistent = true; - - for ($limit = 0; $limit < $total; $limit += $chunk) { - $query = $this->db->select('hash, id') - ->from('file_storage') - ->limit($chunk, $limit) - ->get()->result_array(); - - foreach ($query as $key => $item) { - $data_id = $item["hash"].'-'.$item["id"]; - $file = $this->mfile->file($data_id); - if (!file_exists($file)) { - echo "Warning: no file found for $data_id\n"; - $consistent = false; - } + '); + } + + $chunk = 500; + $total = $this->db->count_all("file_storage"); + $consistent = true; + + for ($limit = 0; $limit < $total; $limit += $chunk) { + $query = $this->db->select('hash, id') + ->from('file_storage') + ->limit($chunk, $limit) + ->get()->result_array(); + + foreach ($query as $key => $item) { + $data_id = $item["hash"].'-'.$item["id"]; + $file = $this->mfile->file($data_id); + if (!file_exists($file)) { + echo "Warning: no file found for $data_id\n"; + $consistent = false; } } + } - if (!$consistent) { - echo "Your database is not consistent with your file system.\n"; - echo "Please report this as it is most likely a bug.\n"; - } + if (!$consistent) { + echo "Your database is not consistent with your file system.\n"; + echo "Please report this as it is most likely a bug.\n"; } } -- cgit v1.2.3-24-g4f1b